Android Question PhonePe API Convertion

Hari Haran

Member
Licensed User
Hi All,

As I have already mention, im not good in java , so can anyone help me converting the PhonePe API Integration for accepting payment from my app.

PhonePe Convertions:
String apiEndPoint = "/v3/debit";
PhonePe Convertions:
HashMap<String, Object> data = new HashMap<>();
data.put("merchantId", “M2306160483220675579140”); //String. Mandatory
data.put("transactionId", “TX123456789”); //String. Mandatory.
data.put("amount", 100); //Long. Mandatory

//Note: Don't pass this if you are passing userAuthToken.
data.put("merchantUserId", “U123456789”); //String. Mandatory. Needed for linking

//Note : Used only for OTP linking flow.
data.put("userAuthToken", <userAuthToken>); //String. Optional. Needed for linking

data.put("merchantOrderId", “OD1234”); //String. Mandatory
data.put("message", “Payment for order placed 001234”); //String. Optional
data.put("mobileNumber", “9xxxxxxxxx”); //String. Optional
data.put("email", “amit***75@gmail.com”); //String. Optional
data.put("shortName",  “Amit”); //String. Optional
data.put("subMerchant", “DemoMerchant”); //String. ONLY if a submerchant id has been allocated to you.

// transactionId length should be less than 38 characters.
// merchantOrderId length should be less than 48 characters.
// Put more info as intimated. Nesting is allowed

String base64Body = Base64(new GSON().toJson(data));

PhonePe Convertions:
String checksum = sha256(base64Body + apiEndPoint + salt) + ### + saltIndex;
PhonePe Convertions:
TransactionRequest debitRequest = new TransactionRequestBuilder()
    .setData(base64Body)
    .setChecksum(checksum)
    .setUrl(apiEndPoint)
    .build();

try {
    startActivityForResult(PhonePe.getTransactionIntent(/* Context */ this, debitRequest),DEBIT_REQUEST_CODE);
} catch(PhonePeInitException e){
}
PhonePe Convertions:
private static int DEBIT_REQUEST_CODE = 777;
 
[USER=69643]@override[/USER]
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
 
    if (requestCode == DEBIT_REQUEST_CODE) {
      
      /*This callback indicates only about completion of UI flow.
            Inform your server to make the transaction
            status call to get the status. Update your app with the
            success/failure status.*/
    }   
}
 

MicroDrie

Well-Known Member
Licensed User
Longtime User
I don't understand why you would need Java with the given information so far.

I would first try a mail sample program like Get file from server and send to email automatically or search in the right upper corner on email for an alternative solution. Beware that Android has increased security rules so take not to old examples from the past to prevent all kind of Android security errors.

This should give you an idea how you can send and read messages on the phone via the mail service client. Do not send an email message in quick succession to the same recipient like I did ?. In such situation you will be classified as a spammer and you have the risk that you email account will be blocked. In such blocked situation ? your program will give hard to solved errors ?.

You can think of all kinds of great solutions, but a simple ? web server solution gives you the best chance of the widest possible range of phones on which your app can run smoothly. Perhaps retrieving an email payment conformation is not necessary, it depends which payment system provider choice you have made.

So far I don't think you need Java for those steps. When you study and build the example(s) from this forum, you will quickly see the points where you can merge the given short program information in the forum examples.
 
Upvote 0

Hari Haran

Member
Licensed User
Hi MicroDrie,

Thanks and I accept your points and you are absolutely right,i can convert certain code but i have stuck up with some part


can't find the PhonePe and TransactionRequestBuilder:
TransactionRequest debitRequest = new TransactionRequestBuilder()
    .setData(base64Body)
    .setChecksum(checksum)
    .setUrl(apiEndPoint)
    .build();

try {
    startActivityForResult(PhonePe.getTransactionIntent(/* Context */ this, debitRequest),DEBIT_REQUEST_CODE);
} catch(PhonePeInitException e){
}

so i hope you understand the difficulties i face
 
Upvote 0

Biswajit

Active Member
Licensed User
Longtime User
Download and import phonepe.thinsdk.android.snapshot:merchantsdk
 
Upvote 0
Top