Esempio n. 1
0
def process_transaction(order_identifier, txn_token):
    paytm_mode = get_settings()['paytm_mode']
    merchant_id = (get_settings()['paytm_sandbox_merchant'] if paytm_mode
                   == 'test' else get_settings()['paytm_live_merchant'])

    if paytm_mode == 'test':
        url = "https://securegw-stage.paytm.in/theia/api/v1/processTransaction?mid={}&orderId={}".format(
            get_settings()['paytm_sandbox_merchant'], order_identifier)
    else:
        url = "https://securegw.paytm.in/theia/api/v1/processTransaction?mid={}&orderId={}".format(
            get_settings()['paytm_live_merchant'], order_identifier)

    head = {
        "version": "v1",
        "requestTimestamp": str(int(time.time())),
        "channelId": "WEB",
        "txnToken": txn_token,
    }

    body = {
        "requestType": "NATIVE",
        "mid": merchant_id,
        "orderId": order_identifier,
        "paymentMode": "BALANCE",
    }

    response = PaytmPaymentsManager.hit_paytm_endpoint(url=url,
                                                       head=head,
                                                       body=body)
    return response
Esempio n. 2
0
def fetch_payment_options(order_identifier, txn_token):
    paytm_mode = get_settings()['paytm_mode']
    if paytm_mode == 'test':
        url = "https://securegw-stage.paytm.in/theia/api/v1/fetchPaymentOptions?mid={}&orderId={}".format(
            get_settings()['paytm_sandbox_merchant'], order_identifier)
    else:
        url = "https://securegw.paytm.in/theia/api/v1/fetchPaymentOptions?mid={}&orderId={}".format(
            get_settings()['paytm_live_merchant'], order_identifier)
    head = {
        "clientId": "C11",
        "version": "v1",
        "requestTimestamp": str(int(time.time())),
        "channelId": "WEB",
        "txnToken": txn_token,
    }
    response = PaytmPaymentsManager.hit_paytm_endpoint(url=url, head=head)
    return response
Esempio n. 3
0
def validate_otp(order_identifier, txn_token):
    paytm_mode = get_settings()['paytm_mode']
    if paytm_mode == 'test':
        url = "https://securegw-stage.paytm.in/theia/api/v1/login/validateOtp?mid={}&orderId={}".\
            format(get_settings()['paytm_sandbox_merchant'], order_identifier)
    else:
        url = "https://securegw.paytm.in/theia/api/v1/login/validateOtp?mid={}&orderId={}".\
            format(get_settings()['paytm_live_merchant'], order_identifier)
    head = {
        "clientId": "C11",
        "version": "v1",
        "requestTimestamp": str(int(time.time())),
        "channelId": "WEB",
        "txnToken": txn_token
    }
    body = {"otp": request.json['data']['otp']}
    response = PaytmPaymentsManager.hit_paytm_endpoint(url=url, head=head, body=body)
    return response