我已经从https://github.com/bluesnap/bluesnap-android-int下载了 BlueSnap Demo App 。我已经创建了沙盒帐户。我希望 Google Pay 作为付款方式。当我通过 bluesnap 选择卡支付时,它成功收取金额并且该金额显示在 BlueSnap 沙盒仪表板上,但是当我单击 BlueSnap App 中的“GPay”按钮时,它显示“意外的开发人员错误,请稍后再试”。我被困在这里,无法理解出了什么问题。
onPaySubmit()
是当我单击结帐按钮时调用的方法。我可以提供更多代码和细节。
public void onPaySubmit(View view) {
if (shopperConfigSwitch.isChecked()) {
SdkRequestShopperRequirements sdkRequest = new SdkRequestShopperRequirements(billingSwitch.isChecked(), emailSwitch.isChecked(), shippingSwitch.isChecked());
try {
bluesnapService.setSdkRequest(sdkRequest);
Intent intent = new Intent(getApplicationContext(), BluesnapChoosePaymentMethodActivity.class);
startActivityForResult(intent, BluesnapChoosePaymentMethodActivity.REQUEST_CODE_DEFAULT);
} catch (BSPaymentRequestException e) {
Log.e(TAG, "payment request not validated: ", e);
finish();
}
} else {
String productPriceStr = AndroidUtil.stringify(productPriceEditText.getText());
if (TextUtils.isEmpty(productPriceStr)) {
Toast.makeText(getApplicationContext(), "null payment", Toast.LENGTH_LONG).show();
return;
}
Double productPrice = Double.valueOf(productPriceStr);
if (productPrice <= 0D) {
Toast.makeText(getApplicationContext(), "0 payment", Toast.LENGTH_LONG).show();
return;
}
readCurencyFromSpinner(ratesSpinner.getSelectedItem().toString());
Double taxAmount = 0D;
// You can set the Amouut solely
SdkRequest sdkRequest = new SdkRequest(productPrice, ratesSpinner.getSelectedItem().toString(), billingSwitch.isChecked(), emailSwitch.isChecked(), shippingSwitch.isChecked());
// // Or you can set the Amount with tax, this will override setAmount()
// // The total purchase amount will be the sum of both numbers
// if (taxAmountPrecentage > 0D) {
// sdkRequest.setAmountWithTax(productPrice, productPrice * (taxAmountPrecentage / 100));
// } else {
// sdkRequest.setAmountNoTax(productPrice);
// }
Switch googlePayTestModeSwitch = findViewById(R.id.googlePayTestModeSwitch);
sdkRequest.setGooglePayTestMode(googlePayTestModeSwitch.isChecked());
sdkRequest.setAllowCurrencyChange(allowCurrencyChangeSwitch.isChecked());
try {
sdkRequest.verify();
} catch (BSPaymentRequestException e) {
showDialog("SdkRequest error:" + e.getMessage());
Log.d(TAG, sdkRequest.toString());
finish();
}
// Set special tax policy: non-US pay no tax; MA pays 10%, other US states pay 5%
sdkRequest.setTaxCalculator(new TaxCalculator() {
@Override
public void updateTax(String shippingCountry, String shippingState, PriceDetails priceDetails) {
if ("us".equalsIgnoreCase(shippingCountry)) {
Double taxRate = 0.05;
if ("ma".equalsIgnoreCase(shippingState)) {
taxRate = 0.1;
}
priceDetails.setTaxAmount(priceDetails.getSubtotalAmount() * taxRate);
} else {
priceDetails.setTaxAmount(0D);
}
}
});
try {
bluesnapService.setSdkRequest(sdkRequest);
Intent intent = new Intent(getApplicationContext(), BluesnapCheckoutActivity.class);
startActivityForResult(intent, BluesnapCheckoutActivity.REQUEST_CODE_DEFAULT);
} catch (BSPaymentRequestException e) {
Log.e(TAG, "payment request not validated: ", e);
finish();
}
}
}
protected void startGooglePayActivityForResult() {
Log.d(TAG, "start GooglePay flow");
// Disables the button to prevent multiple clicks.
LinearLayout googlePayButton = findViewById(R.id.googlePayButton);
if (googlePayButton != null) {
googlePayButton.setClickable(false);
}
Task<PaymentData> futurePaymentData = GooglePayService.getInstance().createPaymentDataRequest(googlePayClient);
// Since loadPaymentData may show the UI asking the user to select a payment method, we use
// AutoResolveHelper to wait for the user interacting with it. Once completed,
// onActivityResult will be called with the result.
AutoResolveHelper.resolveTask(futurePaymentData, this, GOOGLE_PAY_PAYMENT_DATA_REQUEST_CODE);
}
public Task<PaymentData> createPaymentDataRequest(PaymentsClient googlePayClient) {
BlueSnapService blueSnapService = BlueSnapService.getInstance();
SdkRequestBase sdkRequest = blueSnapService.getSdkRequest();
Long merchantId = blueSnapService.getsDKConfiguration().getMerchantId();
if (merchantId == null) {
Log.e(TAG, "Missing merchantId from SDK init data");
return null;
}
List<Pair<String, String>> GATEWAY_TOKENIZATION_PARAMETERS = Arrays.asList(
Pair.create("gatewayMerchantId", merchantId.toString())
);
PaymentMethodTokenizationParameters.Builder paramsBuilder =
PaymentMethodTokenizationParameters.newBuilder()
.setPaymentMethodTokenizationType(
WalletConstants.PAYMENT_METHOD_TOKENIZATION_TYPE_PAYMENT_GATEWAY)
.addParameter("gateway", GATEWAY_TOKENIZATION_NAME);
for (Pair<String, String> param : GATEWAY_TOKENIZATION_PARAMETERS) {
paramsBuilder.addParameter(param.first, param.second);
}
PaymentDataRequest request = createPaymentDataRequest(paramsBuilder.build(), sdkRequest);
Task<PaymentData> futurePaymentData = googlePayClient.loadPaymentData(request);
return futurePaymentData;
}
我希望 Bluesnap 处理 Google 支付付款,这些付款应反映在 Bluesnap 沙盒仪表板上。