3

我想在我的 android 应用程序中实现 Google pay,我想BlueSnap作为Google Pay处理器。我已经Google Pay在可能的应用程序中实现并且还创建了BlueSnap沙盒帐户。当我输入我的实时卡详细信息时,我会收到此祝酒词,已成功收到付款数据。我还在网关中写了 bluesnap,在GatewayMerchantId. 现在我被卡住了,有人可以帮我解决如何将此付款数据发送到BlueSnap并从中获取付款确认,BlueSnap以便我的付款将显示在BlueSnap沙盒仪表板上。

谢谢你。

我已经上传了handlePaymentSuccess()接收 toast 的代码和gatewatTokenization()编写网关和商家 ID 的方法。如果您需要更多代码,我可以上传。

private void handlePaymentSuccess(PaymentData paymentData) {

        String paymentInformation = paymentData.toJson();

        // Token will be null if PaymentDataRequest was not constructed using fromJson(String).
        if (paymentInformation == null) {
            return;
        }
        JSONObject paymentMethodData;

        try {

            paymentMethodData = new JSONObject(paymentInformation).getJSONObject("paymentMethodData");
            // If the gateway is set to "example", no payment information is returned - instead, the
            // token will only consist of "examplePaymentMethodToken".
            if (paymentMethodData
                    .getJSONObject("tokenizationData")
                    .getString("type")
                    .equals("PAYMENT_GATEWAY")
                    && paymentMethodData
                    .getJSONObject("tokenizationData")
                    .getString("token")
                    .equals("examplePaymentMethodToken")) {
                android.app.AlertDialog alertDialog =
                        new android.app.AlertDialog.Builder(this)
                                .setTitle("Warning")
                                .setMessage(
                                        "Gateway name set to \"example\" - please modify "
                                                + "Constants.java and replace it with your own gateway.")
                                .setPositiveButton("OK", null)
                                .create();
                alertDialog.show();
            }

            String billingName =
                    paymentMethodData.getJSONObject("info").getJSONObject("billingAddress").getString("name");

            JSONObject testing =
                    paymentMethodData.getJSONObject("info");

            JSONObject testingNew =
                    paymentMethodData;

            try {
                String paymentToken = createBlsTokenFromGooglePayPaymentData(paymentData);
                //Toast.makeText(this, String.valueOf(paymentToken), Toast.LENGTH_LONG).show();
            } catch (Exception e) {
                e.printStackTrace();
            }

            Log.d("BillingName", billingName);
            Toast.makeText(this, getString(R.string.payments_show_name, billingName), Toast.LENGTH_LONG).show();
            //Toast.makeText(this, String.valueOf(testing), Toast.LENGTH_LONG).show();


            // Logging token string.
            Log.d("GooglePaymentToken", paymentMethodData.getJSONObject("tokenizationData").getString("token"));
        } catch (JSONException e) {
            Log.e("handlePaymentSuccess", "Error: " + e.toString());
            return;
        }
    }
private static JSONObject getGatewayTokenizationSpecification() throws JSONException {
    return new JSONObject(){{
      put("type", "PAYMENT_GATEWAY");
      put("parameters", new JSONObject(){{
        put("gateway", "bluesnap");
        put("gatewayMerchantId", "######");//i've hidden MerchantId
        }
      });
    }};
  }
4

1 回答 1

0

根据BlueSnap 的文档

paymentToken应该发送到 BlueSnap API,在处理事务部分中有详细说明。

我认为相关的部分是向 BlueSnap 发出 HTTP POST,其中包含paymentToken您收到的以下内容createBlsTokenFromGooglePayPaymentData

curl -v -X POST https://sandbox.bluesnap.com/services/2/transactions \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \ 
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-d '
{
    "cardTransactionType": "AUTH_CAPTURE",
    "softDescriptor": "DescTest",
    "amount": 11.00,
    "currency": "USD",
    "wallet": {
      "walletType": "GOOGLE_PAY",
      "encodedPaymentToken": "ImRhdGEiOiJuY1AvRitIUy8zeG5bXhCMFd"
    }
}

wherepaymentToken被赋值给 的值encodedPaymentToken

于 2019-11-05T00:54:22.033 回答