Skip to content

Commit 5c18b3f

Browse files
feat: endpoint to fetch transaction status of an order via paytm
1 parent fcf5275 commit 5c18b3f

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
@@ -622,3 +622,31 @@ def omise_checkout(order_identifier):
622622
logging.info(f"Successful charge: {charge.id}. Order ID: {order_identifier}")
623623

624624
return redirect(make_frontend_url('orders/{}/view'.format(order_identifier)))
625+
626+
627+
@order_misc_routes.route('/orders/<string:order_identifier>/paytm/transaction-status', methods=['GET'])
628+
def get_transaction_status(order_identifier):
629+
paytmParams = dict()
630+
paytm_params = dict()
631+
url = ""
632+
paytm_mode = get_settings()['paytm_mode']
633+
merchant_id = (get_settings()['paytm_sandbox_merchant'] if paytm_mode == 'test'
634+
else get_settings()['paytm_live_merchant'])
635+
636+
paytm_params["body"] = {
637+
"mid": merchant_id,
638+
"orderId": order_identifier
639+
}
640+
checksum = PaytmPaymentsManager.generate_checksum(paytm_params)
641+
642+
paytmParams["MID"] = merchant_id
643+
paytmParams["ORDERID"] = order_identifier
644+
paytmParams["CHECKSUMHASH"] = checksum
645+
post_data = json.dumps(paytmParams)
646+
647+
if paytm_mode == 'test':
648+
url = "https://securegw-stage.paytm.in/order/status"
649+
else:
650+
url = "https://securegw.paytm.in/order/status"
651+
response = requests.post(url, data = post_data, headers = {"Content-type": "application/json"}).json()
652+
return response

0 commit comments

Comments
 (0)