2

While creating the transaction token for paytm business, I am receiving the below error as response from paytm.

CURL request ( as per docs, https://developer.paytm.com/docs/initiate-transaction-api/?ref=payments )

curl -X POST 'https://securegw-stage.paytm.in/theia/api/v1/initiateTransaction?mid=hkmbcA45014017456710&orderId=ORDERID_2' \
--header 'Content-Type: application/json' \
--data '{"body":{"requestType":"Payment","mid":"hkmbcA45014017456710","websiteName":"WEBSTAGING","orderId":"ORDERID_2","txnAmount":{"value":"1.00","currency":"INR"},"userInfo":{"custId":"CUST_001"},"callbackUrl":"https://merchant.com/callback"},"head":{"signature":"E3g+4XifD5/XwcD/tJ9ePYJTlJGZL7BneqY4Vf32faqEJ8zkSvgM+pMWfCAfmb0VwQaT3M4p6e+grMXjeqsRScF7en86MjLY1ieA9WRf4w="}}'

Response

{"head":{"requestId":null,"responseTimestamp":"1596714537669","version":"v1"},"body":{"extraParamsMap":null,"resultInfo":{"resultStatus":"F","resultCode":"2005","resultMsg":"Checksum provided is invalid"}}}

I have generated the checksum in ruby using https://github.com/paytm/Paytm_Ruby_Checksum/blob/master/PaytmChecksum.rb

Answers and small suggestions also are most welcome !!!

Bharathiraja
  • 91
  • 2
  • 7

4 Answers4

1

It seems you are creating checksum with wrong parameters, please find the below steps for more clarification.

  1. body request should be
body=‘{“requestType”:“Payment”,“mid”:“YOUR_MID_HERE”,“websiteName”:“WEBSTAGING”,“orderId”:“ORDERID_98765111",“txnAmount”:{“value”:“1.00”,“currency”:“INR”},“userInfo”:{“custId”:“CUST_001"},“callbackUrl”:“https://merchant.com/callback”}’
paytmChecksum = PaytmChecksum.new.generateSignature(body, “YOUR_Key_HERE”)
  1. Your final curl request should be
curl -X POST ‘https://securegw-stage.paytm.in/theia/api/v1/initiateTransaction?mid=hkmbcA45014017456710&orderId=ORDERID_2’ \
--header ‘Content-Type: application/json’ \
--data ‘{“body”:{“requestType”:“Payment”,“mid”:“INTEGR77698636129383",“websiteName”:“WEBSTAGING”,“orderId”:“ORDERID_98765111",“txnAmount”:{“value”:“1.00”,“currency”:“INR”},“userInfo”:{“custId”:“CUST_001"},“callbackUrl”:“https://merchant.com/callback”},“head”:{“signature”:“‘+paytmChecksum+‘“}}’
Daniel Walker
  • 6,380
  • 5
  • 22
  • 45
0
When I removed website name and callback URL its working fine.

Just replace the MID with your and its working fine

enter image description here

shubomb
  • 672
  • 7
  • 20
0

Include all the mandatory fields, as described in: https://business.paytm.com/docs/api/initiate-transaction-api/?ref=payments

An example in java would be:

    // Below section generates body of the POST request

    JSONObject body = new JSONObject();
    body.put("requestType", "Payment");
    body.put("mid", MERCHANT_ID);
    //"DEFAULT" for production and "WEBSTAGING" for staging
    body.put("websiteName", "DEFAULT");
    body.put("orderId", orderId);
    body.put("callbackUrl", "");
    
    JSONObject txnAmount = new JSONObject();
    txnAmount.put("value", amount);
    txnAmount.put("currency", "INR");

    JSONObject userInfo = new JSONObject();
    userInfo.put("custId", CUSTOMER_ID);
    userInfo.put("mobile", customerMobile);

    body.put("txnAmount", txnAmount);
    body.put("userInfo", userInfo);

    String checksum = PaytmChecksum.generateSignature(body.toString(), MERCHANT_KEY);
    JSONObject head = new JSONObject();
    head.put("signature", checksum);

    JSONObject paytmParams = new JSONObject();
    paytmParams.put("body", body);
    paytmParams.put("head", head);

    URL url = new URL(PAYTM_URL + "mid="+MERCHANT_ID+"&orderId="+orderId);

Also, set the header "Content-Type" to "application/json" when sending the POST request.

TC4Y
  • 18
  • 2
-1
require './lib/modules/PaytmChecksum.rb'

def paytm_txn_gen
body = '{"requestType":"Payment","mid":"YOUR_MID_HERE","websiteName":"WEBSTAGING","orderId":"ORDERID_98765","txnAmount":{"value":"1.00","currency":"INR"},"userInfo":{"custId":"CUST_001"},"callbackUrl":"https://merchant.com/callback"}'

paytmChecksum = PaytmChecksum.new.generateSignature(body, "YOUR_MERCHANT_KEY")
verifyChecksum = PaytmChecksum.new.verifySignature(body, "YOUR_MERCHANT_KEY", paytmChecksum)

puts "generateSignature Returns: %s\n" %[paytmChecksum]
puts "verifySignature Returns: %s\n" %[verifyChecksum]

data = '{"body":{"requestType":"Payment","mid":"YOUR_MID_HERE","websiteName":"WEBSTAGING","orderId":"ORDERID_98765","txnAmount":{"value":"1.00","currency":"INR"},"userInfo":{"custId":"CUST_001"},"callbackUrl":"https://merchant.com/callback"},"head":{"signature":"'+paytmChecksum+'"}}'

puts data

_url = "https://securegw-stage.paytm.in/theia/api/v1/initiateTransaction?mid=YOUR_MID_HERE&orderId=ORDERID_98765";

response = RestClient::Request.new({
method: :post,
url: "#{_url}",
payload: data,
headers: {content_type: "application/json"}
 }).execute do |response, request, result|
  puts "***********************"
  puts JSON.parse(response).inspect
end

end

Ro Ja
  • 49
  • 3
  • While your answer may solve the question, [including an explanation](https://meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. You can edit your answer to add explanations and give an indication of what limitations and assumptions apply. - [From Review](https://stackoverflow.com/review/late-answers/28337419) – Adam Marshall Feb 16 '21 at 16:37