0

I have downloaded BlueSnap Demo App from https://github.com/bluesnap/bluesnap-android-int. I have created sandbox account. I want Google Pay as a payment method. When I am selecting card payment through bluesnap it successfully charges amount and that amount is showing on BlueSnap sandbox dashboard, but when I click "GPay" button in BlueSnap App, it shows "Unexpected developer error, please try again later". I am stuck here and unable to understand what is going wrong.

onPaySubmit() is a method called when I click on the checkout button. I can provide more code and details.

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;
    }

I want Google pay payments to be processed by Bluesnap and those payments should reflect on Bluesnap sandbox dashboard.

Rumit Patel
  • 8,830
  • 18
  • 51
  • 70
Asad Alii
  • 31
  • 5
  • This seems like a general question about their workflow. Have you tried contacting their support ? – Randy May 09 '19 at 13:13
  • No i haven't tried contacting their support yet. But thank you for guiding me, i'll definitely contact them. – Asad Alii May 10 '19 at 05:35

0 Answers0