Skip to content

Commit 58804ed

Browse files
feat: endpoint to fetch transaction status of an order via paytm
1 parent a408e39 commit 58804ed

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

app/api/orders.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,3 +668,31 @@ def initiate_transaction(order_identifier):
668668
format(get_settings()['paytm_sandbox_merchant'], order.id)
669669
response = requests.post(url, data=post_data, headers={"Content-type": "application/json"})
670670
return response.json()
671+
672+
673+
@order_misc_routes.route('/orders/<string:order_identifier>/paytm/transaction-status', methods=['GET'])
674+
def get_transaction_status(order_identifier):
675+
paytmParams = dict()
676+
paytm_params = dict()
677+
url = ""
678+
paytm_mode = get_settings()['paytm_mode']
679+
merchant_id = (get_settings()['paytm_sandbox_merchant'] if paytm_mode == 'test'
680+
else get_settings()['paytm_live_merchant'])
681+
682+
paytm_params["body"] = {
683+
"mid": merchant_id,
684+
"orderId": order_identifier
685+
}
686+
checksum = PaytmPaymentsManager.generate_checksum(paytm_params)
687+
688+
paytmParams["MID"] = merchant_id
689+
paytmParams["ORDERID"] = order_identifier
690+
paytmParams["CHECKSUMHASH"] = checksum
691+
post_data = json.dumps(paytmParams)
692+
693+
if paytm_mode == 'test':
694+
url = "https://securegw-stage.paytm.in/order/status"
695+
else:
696+
url = "https://securegw.paytm.in/order/status"
697+
response = requests.post(url, data = post_data, headers = {"Content-type": "application/json"}).json()
698+
return response

0 commit comments

Comments
 (0)