我想在我的 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
}
});
}};
}