Skip to content

Commit 03299e0

Browse files
feat: endpoint to fetch transaction status of an order via paytm
1 parent 23d0b57 commit 03299e0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

app/api/orders.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,3 +766,30 @@ def process_transaction(order_identifier, txn_token):
766766

767767
response = PaytmPaymentsManager.hit_paytm_endpoint(url=url, head=head, body=body)
768768
return response
769+
770+
771+
@order_misc_routes.route('/orders/<string:order_identifier>/paytm/transaction-status', methods=['GET'])
772+
def get_transaction_status(order_identifier):
773+
paytm_params = dict()
774+
paytm_checksum_params = dict()
775+
url = ""
776+
paytm_mode = get_settings()['paytm_mode']
777+
merchant_id = (get_settings()['paytm_sandbox_merchant'] if paytm_mode == 'test'
778+
else get_settings()['paytm_live_merchant'])
779+
paytm_checksum_params["body"] = {
780+
"mid": merchant_id,
781+
"orderId": order_identifier
782+
}
783+
checksum = PaytmPaymentsManager.generate_checksum(paytm_checksum_params)
784+
785+
paytmParams["MID"] = merchant_id
786+
paytmParams["ORDERID"] = order_identifier
787+
paytmParams["CHECKSUMHASH"] = checksum
788+
post_data = json.dumps(paytm_params)
789+
790+
if paytm_mode == 'test':
791+
url = "https://securegw-stage.paytm.in/order/status"
792+
else:
793+
url = "https://securegw.paytm.in/order/status"
794+
response = requests.post(url, data = post_data, headers = {"Content-type": "application/json"}).json()
795+
return response

0 commit comments

Comments
 (0)