I want to implement Google pay in my android application and I want BlueSnap
as Google Pay
processor. I have implemented Google Pay
in may app and have also created BlueSnap
sandbox account. When I enter my live card details i receive this toast Successfully received payment data. I have also written bluesnap in gateway and sandbox merchant id in GatewayMerchantId
. Now I am stuck, can someone help me out on how to send this payment data to BlueSnap
and get payment confirmation from BlueSnap
so that my payment would show on BlueSnap
sandbox dashboard.
Thank you.
I have uploaded my handlePaymentSuccess()
code where I am receiving toast and gatewatTokenization()
method where I have written gateway and merchantId. If you need more code, I can upload it.
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
}
});
}};
}