Unexpected response code 400
Closed this issue · 14 comments
Hey, Im implementing saving to google pay Loyalty card. Im following tutorial with using the native Android SDK.
After building request and sending by AutoResolverHelper result code is allways 1. In logcat console I have error:
2018-09-25 13:28:58.151 3686-4458/? E/Volley: [51418] BasicNetwork.performRequest: Unexpected response code 400 for https://wallet.google.com/payments/apis/instantbuy/android/v1/createWalletObjects
2018-09-25 13:28:58.156 3686-3699/? E/ServerConnection: Exception sending Volley request
java.util.concurrent.ExecutionException: com.android.volley.ClientError
at com.android.volley.toolbox.RequestFuture.a(:com.google.android.gms@13280019@13.2.80 (040400-211705629):4)
at com.android.volley.toolbox.RequestFuture.get(:com.google.android.gms@13280019@13.2.80 (040400-211705629):1)
at arwj.a(:com.google.android.gms@13280019@13.2.80 (040400-211705629):34)
at arwj.a(:com.google.android.gms@13280019@13.2.80 (040400-211705629):30)
at asph.a(:com.google.android.gms@13280019@13.2.80 (040400-211705629):8)
at aspb.a(:com.google.android.gms@13280019@13.2.80 (040400-211705629):19)
at asfj.a(:com.google.android.gms@13280019@13.2.80 (040400-211705629):5)
at aspa.a(:com.google.android.gms@13280019@13.2.80 (040400-211705629):4)
at aspk.a(:com.google.android.gms@13280019@13.2.80 (040400-211705629):2)
at asou.a(Unknown Source:2)
at asoy.a(:com.google.android.gms@13280019@13.2.80 (040400-211705629):1)
at wwt.a(:com.google.android.gms@13280019@13.2.80 (040400-211705629):3)
at cgv.onTransact(:com.google.android.gms@13280019@13.2.80 (040400-211705629):5)
at asou.onTransact(Unknown Source:0)
at android.os.Binder.transact(Binder.java:622)
at djf.onTransact(:com.google.android.gms@13280019@13.2.80 (040400-211705629):3)
at android.os.Binder.execTransact(Binder.java:692)
Caused by: com.android.volley.ClientError
at com.android.volley.toolbox.BasicNetwork.performRequest(:com.google.android.gms@13280019@13.2.80 (040400-211705629):53)
at pwh.performRequest(:com.google.android.gms@13280019@13.2.80 (040400-211705629):14)
at com.android.volley.NetworkDispatcher.a(:com.google.android.gms@13280019@13.2.80 (040400-211705629):6)
at com.android.volley.NetworkDispatcher.run(:com.google.android.gms@13280019@13.2.80 (040400-211705629):2)
Hi i am having the same issue. did you manage to fix this?
I'm not solving this issue. Still waiting.
damm ok
Hi, I have the same problem :(
There are new ideas?
I wrote in support, but they say check query parameters :(
guys got any solution? same problem here SO https://stackoverflow.com/questions/53320259/add-loyalty-card-to-google-pay-via-google-play-services-api, please upvote! is there any way to enable debugging for google wallet api? like someobject.setenablelogging()
public void saveToAndroid(View view) {
OfferWalletObject wob = generateOfferWalletObject();
//CreateWalletObjectsRequest request = new CreateWalletObjectsRequest(wob);
// CreateWalletObjectsRequest request = new CreateWalletObjectsRequest.newBuilder().build();
// request.getOfferWalletObject(wob);
// CreateWalletObjectsRequest request = CreateWalletObjectsRequest.newBuilder().build();
// request.getOfferWalletObject(wob);
CreateWalletObjectsRequest request= CreateWalletObjectsRequest.newBuilder()
.setCreateMode(SHOW_SAVE_PROMPT)
.setOfferWalletObject(wob)
.build();
Wallet.WalletOptions walletOptions = new Wallet.WalletOptions.Builder()
.setTheme(WalletConstants.THEME_LIGHT)
.setEnvironment(WalletConstants.ENVIRONMENT_PRODUCTION)
.build();
walletObjectsClient = Wallet.getWalletObjectsClient(this, walletOptions);
Task<AutoResolvableVoidResult> task = walletObjectsClient.createWalletObjects(request);
AutoResolveHelper.resolveTask(task, this, SAVE_TO_ANDROID);
}
Hi to all. I've successfully implemented app with play-services-wallet
library.
Try to check the environment setup for complience with the following list:
Merchant center
- Check that all of required fields are filled with relevant data;
- Check your
loyalty class
. VerifyStatus
field value. It must be selected as UNDER_REVIEW (will change automatically to APPROVED after save); - Be sure you've tied google API service account and your Merchant Center. Add it in Share Account settings. Value:
sugar-s2w-prod@system.gserviceaccount.com
. Can edit; - Note your Issuer Name, Issuer ID, Class ID and Program name.
Application. Wallet request builder
- Check your
LoyaltyWalletObjectBuilder
. Here is example (minimum working version):
//Replace "${something}" with your values noted previously
final LoyaltyWalletObject loyaltyWalletObject = LoyaltyWalletObject.newBuilder()
.setClassId("${your_issuer_id}.${your_class_id}")
.setId("${your_issuer_id}.${some_unque_name}")
.setIssuerName("${your_issuer_name}")
.setProgramName("${your_program_name}")
.setState(WalletObjectsConstants.State.ACTIVE)
.setAccountId("1000") //Your user id
.setAccountName("John Doe") //User name
.setBarcodeType("qrCode")
.setBarcodeValue("Hello world!")
.build();
Whitelist your app with SHA1 fingerprint
Explained here: https://developers.google.com/pay/passes/guides/get-started/basic-setup/get-access-to-android-sdk#obtain-credentials-to-whitelist-your-app
Then contact Google team via form https://support.google.com/pay/merchants/contact/instore_merchant_support (Technical/API Integration) with request to start whitelisting process. Pass them necessary information: package name and SHA1.
Note: you can whitelist your debug key (for testing purposes) without restrictions.
These key points helped me successfully add a loyalty card to Google Pay from my app.
package com.google.checkout.android.demo;
public class MainActivity extends FragmentActivity
implements GoogleApiClient.OnConnectionFailedListener {
private static final String TAG = "MainActivity";
public static final int SAVE_TO_ANDROID = 888;
private String ISSUER_ID;
private String LOYALTY_CLASS_ID;
private String LOYALTY_OBJECT_ID;
private String SUCCESS_RESPONSE_TEXT;
private String CANCELED_RESPONSE_TEXT;
private String ERROR_PREFIX_TEXT;
// public static final Scope WOB =
new Scope("https://www.googleapis.com/auth/wallet_object.issuer");
private WalletObjectsClient walletObjectsClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ISSUER_ID = getResources().getString(R.string.ISSUER_ID);
LOYALTY_CLASS_ID = getResources().getString(R.string.LOYALTY_CLASS_ID);
LOYALTY_OBJECT_ID= getResources().getString(R.string.LOYALTY_OBJECT_ID);
SUCCESS_RESPONSE_TEXT= getResources().getString(R.string.SUCCESS_RESPONSE_TEXT);
CANCELED_RESPONSE_TEXT= getResources().getString(R.string.CANCELED_RESPONSE_TEXT);
ERROR_PREFIX_TEXT = getResources().getString(R.string.ERROR_PREFIX_TEXT);
}
@Override
public void onConnectionFailed(ConnectionResult result) {
Log.w(TAG, "onConnectionFailed: " + result);
}
public void saveToAndroid(View view) {
LoyaltyWalletObject wob = generateLoyaltyWalletObject();
CreateWalletObjectsRequest request = new CreateWalletObjectsRequest(wob);
Wallet.WalletOptions walletOptions = new Wallet.WalletOptions.Builder()
.setTheme(WalletConstants.THEME_LIGHT)
.setEnvironment(WalletConstants.ENVIRONMENT_PRODUCTION)
.build();
walletObjectsClient = Wallet.getWalletObjectsClient(this, walletOptions);
Task<AutoResolvableVoidResult> task = walletObjectsClient.createWalletObjects(request);
AutoResolveHelper.resolveTask(task, this, SAVE_TO_ANDROID);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
EditText textBox = (EditText) findViewById(R.id.s2wResponse);
switch (requestCode) {
case SAVE_TO_ANDROID:
switch (resultCode) {
case Activity.RESULT_OK:
textBox.setText(SUCCESS_RESPONSE_TEXT);
break;
case Activity.RESULT_CANCELED:
textBox.setText(CANCELED_RESPONSE_TEXT);
break;
default:
int errorCode =
data.getIntExtra(
WalletConstants.EXTRA_ERROR_CODE, -1);
textBox.setText(ERROR_PREFIX_TEXT + errorCode);
break;
}
}
}
public LoyaltyWalletObject generateLoyaltyWalletObject() {
LoyaltyPoints points = LoyaltyPoints.newBuilder()
.setLabel("Points")
.setType("points")
.setBalance(LoyaltyPointsBalance.newBuilder().setString("500").build()).build();
List textModulesData = new ArrayList();
TextModuleData textModuleData = new TextModuleData("Jane's Baconrista Rewards",
"Save more at your local Mountain View store Jane." +
" You get 1 bacon fat latte for every 5 coffees purchased." +
" Also just for you, 10% off all pastries in the Mountain View store.");
textModulesData.add(textModuleData);
List uris = new ArrayList();
UriData uri1 = new UriData("https://www.hubbell.com","My Hubbell");
// UriData uri1 = new UriData("https://www.hubbell.com",
// "My Hubbell Account");
uris.add(uri1);
List imageUris = new ArrayList();
UriData uri2 = new UriData("https://www.sctsoftware.com/wp-content/uploads/2017/01/customer-logo-hubbell.png", "Image Description");
imageUris.add(uri2);
List row0cols = new ArrayList();
LabelValue row0col0 = new LabelValue("Next Reward in", "2 coffees");
LabelValue row0col1 = new LabelValue("Member Since", "01/15/2013");
row0cols.add(row0col0);
row0cols.add(row0col1);
List row1cols = new ArrayList();
LabelValue row1col0 = new LabelValue("Local Store", "Mountain View");
row1cols.add(row1col0);
List rows = new ArrayList();
LabelValueRow row0 = LabelValueRow.newBuilder().addColumns(row0cols).build();
LabelValueRow row1 = LabelValueRow.newBuilder().addColumns(row1cols).build();
rows.add(row0);
rows.add(row1);
List messages = new ArrayList();
WalletObjectMessage message = WalletObjectMessage.newBuilder()
.setHeader("Hi Prasanth!")
.setBody("Thanks for joining our program. Show this message to " +
"our hubbell for your checkout!")
.build();
messages.add(message);
LatLng location = new LatLng(37.422601, -122.085286);
List locations = new ArrayList();
locations.add(location);
LoyaltyWalletObject wob = LoyaltyWalletObject.newBuilder()
.setClassId(ISSUER_ID+"."+LOYALTY_CLASS_ID)
.setId(ISSUER_ID+"."+LOYALTY_OBJECT_ID)
.setState(WalletObjectsConstants.State.ACTIVE)
.setAccountId("1234")
.setAccountName("Hubbell Incorporated")
.setIssuerName("Test")
.setProgramName("Test")
.setLoyaltyPoints(points)
.addTextModulesData(textModulesData)
.addLinksModuleDataUris(uris)
.addInfoModuleDataLabelValueRows(rows)
.addImageModuleDataMainImageUris(imageUris)
.addMessages(messages)
.addLocations(locations)
.build();
return wob;
}
}
Above one is my code, i am getting error code:-1. I have whitelisted the app and included service account in merchant center also. But still i am getting the same error code. Can you please someone help me out?
Hi trombocit,
Now i am getting the below error.
E/Volley: [352] BasicNetwork.performRequest: Unexpected response code 400 for https://wallet.google.com/payments/apis/instantbuy/android/v1/createWalletObjects
2019-06-04 16:07:23.682 5614-5985/? E/ServerConnection: Exception sending Volley request
java.util.concurrent.ExecutionException: com.android.volley.ClientError
at com.android.volley.toolbox.RequestFuture.a(:com.google.android.gms@17455022@17.4.55 (040700-248795830):4)
at com.android.volley.toolbox.RequestFuture.get(:com.google.android.gms@17455022@17.4.55 (040700-248795830):1)
at axkv.a(:com.google.android.gms@17455022@17.4.55 (040700-248795830):17)
at axkv.a(:com.google.android.gms@17455022@17.4.55 (040700-248795830):13)
at ayei.a(:com.google.android.gms@17455022@17.4.55 (040700-248795830):9)
at axjq.a(Unknown Source:1)
at ayec.a(:com.google.android.gms@17455022@17.4.55 (040700-248795830):16)
at axuj.a(:com.google.android.gms@17455022@17.4.55 (040700-248795830):4)
at ayed.a(:com.google.android.gms@17455022@17.4.55 (040700-248795830):4)
at ayen.a(:com.google.android.gms@17455022@17.4.55 (040700-248795830):2)
at aydx.a(Unknown Source:2)
at ayeb.a(Unknown Source:19)
at aahy.a(:com.google.android.gms@17455022@17.4.55 (040700-248795830):1)
at cwc.onTransact(:com.google.android.gms@17455022@17.4.55 (040700-248795830):4)
at aydx.onTransact(:com.google.android.gms@17455022@17.4.55 (040700-248795830):1)
at android.os.Binder.transact(Binder.java:627)
at edn.onTransact(:com.google.android.gms@17455022@17.4.55 (040700-248795830):3)
at android.os.Binder.transact(Binder.java:627)
at aaiz.onTransact(:com.google.android.gms@17455022@17.4.55 (040700-248795830):25)
at android.os.Binder.execTransact(Binder.java:697)
Caused by: com.android.volley.ClientError
at com.android.volley.toolbox.BasicNetwork.performRequest(:com.google.android.gms@17455022@17.4.55 (040700-248795830):58)
at sfj.performRequest(:com.google.android.gms@17455022@17.4.55 (040700-248795830):13)
at com.android.volley.NetworkDispatcher.a(:com.google.android.gms@17455022@17.4.55 (040700-248795830):7)
at com.android.volley.NetworkDispatcher.run(:com.google.android.gms@17455022@17.4.55 (040700-248795830):2)
I finally got it woking. I was signing the apk with the debug key and not release key.
What I noticed is, if I use .setBarcodeType("codebar") instead of .setBarcodeType("qrCode") I get the same 400 response error.
I finally got it woking. I was signing the apk with the debug key and not release key.
What I noticed is, if I use .setBarcodeType("codebar") instead of .setBarcodeType("qrCode") I get the same 400 response error.
My bad, I was able to set a bar code by setting .setBarcodeType("code128")
We are facing this issue on one of your project, but oddly, only on build from appcenter.
I must say that we use the exact same keystore, and so the same sha1 ... I don't get why it doesn't work on appcenter but it does from a build download from playstore, but this error is happenning since we switcher to AAB instead of APKs, and when we bumped to Android 11/12 target.
Hello,
My apologies, this repository is being deprecated. Please refer to the following repositories going forward. If there is anything you would like assistance with, please feel free to submit an issue.