I am integrating all steps based on the link https://developer.phonepe.com/v1/docs/android-pg-sdk-integration.Now I am getting "Something went wrong:400"
Expect:trying to open the upi apps,And after payment Success Response Required.Here my inegrated codes
data.put("merchantTransactionId", getTransactionId);
data.put("merchantId", R.string.merchantid);
data.put("merchantUserId","ABC12345"));
data.put("amount", 2);
data.put("mobileNumber", "123456789");
data.put("callbackUrl", "https://webhook.site/callback-url");
data.put("redirectMode", "POST");
data.put("redirectUrl", "https://webhook.site/redirect-url");
PaymentInstrument mPaymentInstrument = new PaymentInstrument();
mPaymentInstrument.setType("UPI_INTENT");
mPaymentInstrument.setTargetApp("com.phonepe.app");
data.put("paymentInstrument", mPaymentInstrument);
DeviceContext mDeviceContext = new DeviceContext();
mDeviceContext.setDeviceOs("ANDROID");
data.put("deviceContext", mDeviceContext);
String json = gson.toJson(data);
String getdatas = new String(Base64.encode(json.getBytes(),Base64.DEFAULT), Base64.DEFAULT);
try {
md = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
String input = (getdatas + apiEndPoint + salt) ;
// compute the hash of the input string
byte[] hash = md.digest(input.getBytes());
// convert the hash to a hexadecimal string
StringBuilder hexString = new StringBuilder();
for (byte b : hash) {
hexString.append(String.format("%02x", b));
}
String checksum = String.valueOf(hexString);
String checkSumResult=checksum+ "###" + saltIndex;
B2BPGRequest b2BPGRequest = new B2BPGRequestBuilder().setData(getdatas).setChecksum(checkSumResult).setUrl(apiEndPoint)
.build();
try {
startActivityForResult(PhonePe.getImplicitIntent(this, b2BPGRequest, "com.phonepe.app"), B2B_PG_REQUEST_CODE);
} catch (PhonePeInitException e) {
}
Here my Manifest File
<meta-data
android:name="com.phonepe.android.sdk.Debuggable"
android:value="true"/>
<!-- Keep it true in UAT environment for both the flags-->
<meta-data
android:name="com.phonepe.android.sdk.isUAT"
android:value="true"/>
<meta-data
android:name="com.phonepe.android.sdk.isSimulator"
android:value="true"/>
<!-- The value will be the MID-->
<meta-data
android:name="com.phonepe.android.sdk.MerchantId"
android:value="@string/merchantid"/>
You are using testing integration for that you have to use simulator app package name. For access of simualtor mail phonepe team they will provide you. Once u will use it with that it will work.
Also here is an youtube video you can check it help https://youtu.be/NJsmpk42QKs?si=HMWkyk7aORBt0kXO
Here is github repo https://github.com/1902shubh/PhonepeSdkAndroid
Also from android app don't try to use api hitting directly of phonepe it will not work. For that you have to user server side integration. IN Android you have to only use SDK integration. If you have any confusion let me know.