3

I am building a flutter app which involves online payment from users of app.

I am planning to use Paytm payment gateway. I was planning to achieve this using WebView. I understand that for this I need to set up a server to generate checksum.

Now what I want to understand is how do I set up the server? According to this article: https://medium.com/@iqan/flutter-payments-using-paytm-7c48539dfdee I have to clone this github project: https://github.com/iqans/paytm-checksum-api-nodejs

Where do I upload this node.js project? Can this be uploaded to Firebase?

Or does it have to be uploaded on website hosting platform like hostgator?

Please explain this a bit, I don't now much about servers, I have just started using flutter.

Aman Kataria
  • 586
  • 2
  • 12
  • 24
  • why not use web view? what are the challenges you are facing to implement web based payment? – Darish Jul 16 '19 at 05:42
  • @Darish I have updated my question to be more specific. Also, someone downvoted this question, and as a result I am banned from asking question. Now I have updated the question, is it fine now? – Aman Kataria Jul 16 '19 at 08:33
  • is your app is an offline app without a server backend? I hope you already have one server back end to store the user data. – Darish Jul 16 '19 at 12:43
  • @Darish Yes, it has firebase Firestore as backend – Aman Kataria Jul 16 '19 at 14:59
  • Then you can use the firebase to host those files – Darish Jul 17 '19 at 05:29
  • @Darish Can you write this as an answer, Ill accept the answer. I think it will unban me from asking questions. – Aman Kataria Jul 17 '19 at 12:17
  • @Darish I am sorry to constantly bug you, but can you upvote my question? My account is still banned. This will definitely unban the account. – Aman Kataria Jul 18 '19 at 09:12

2 Answers2

4

For your convenience, it is more easy for you to implement the payment gateway using webview.

Host the files provided by the payment SDK on your server to calculate the checksum.

Then you can initiate the transaction from your mobile app and calculate the checksum by calling your server side scripts. Then pass those values to the payment SDK.

Darish
  • 11,032
  • 5
  • 50
  • 70
0

I think more than webview use of paytm sdk is best option for you because when you start transection its take a data from paytm app which is install in customers mobile.

There is a one plugin available for doing this called paytmkaro you use this but it's only work with production keys.

Before starting upload the server side code on server which is available on their documentation which is available here please don't make any changes on server side code it's used to generate a txn token on paytm server.

Change the minimum sdk version to 19

and just copy paste this code

` try {
  PaytmResponse paymentResponse = await _paytmKaro.startTransaction(
    url: serverside code url e.g. https://arcane-temple-61754.herokuapp.com/intiateTansection.php,
    mid: your Production merchant id,
    mkey: your merchant key,
    customerId:customer id (must be unique for every customer),
    amount: transection amount,
    orderId: Order Id (Order id must be unique Everytime for every order),
  );

  if(paymentResponse.status=="TXN_SUCCESS"){
    Navigator.push(context, MaterialPageRoute(builder: (context)=>txnSuccessful(paytmResponse: paymentResponse,)));
  }
  else if(paymentResponse.status=="TXN_FAILURE"){
    Navigator.push(context, MaterialPageRoute(builder: (context)=>txnFailed(paytmResponse: paymentResponse,)));
  }
} 
catch(e){
  print(e);
  key.currentState.showSnackBar(SnackBar(content: Text(e.toString())));      // platformVersion = 'Failed to get platform version.'
}`

and you are done.