Create a JusPay module
  • 20 Jul 2023
  • 3 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Create a JusPay module

  • Dark
    Light
  • PDF

Article summary

JusPay is a popular payment processor in India that offers a variety of payment options, including credit cards, debit cards, netbanking, wallets, and UPI. ViewLift supports integration with JusPay. If you would like to integrate JusPay with your ViewLift account, please contact us for assistance.

How JusPay handles mandate (recurring) payments

The first step towards integration is to ensure that your mandate payments acceptance are set up and processing correctly. This means that you need to have a JusPay account and have configured your payment methods. Then, integrate JusPay with your site and apps through ViewLift. Here you will enable JusPay as a payment handler and set up a JusPay landing screen. Once this is done, you can start accepting payments through JusPay.

Mandate payments are a convenient way for customers to make recurring payments. The following workflow outlines how JusPay implements recurring payments:

  1. Create a mandate order. See this JusPay documentation for more information.
    JusPay calls ViewLift's Callback API for each completed order. ViewLift sends the endUrl as 'www.yoursite.tv' from the SDK and returnUrl as 'https://prod-api.viewlift.com/subscription/callback/juspay/{orderId}/yoursitename' through the order creation API.
    Below is the list of gateways we pass the shouldCreateMandate parameter as TRUE:
    1. paytm
    2. upi
    3. boi
    4. ibl
    5. ybl
    6. axl
    7. apl
    8. cnrb
    9. barodampay
    10. okhdfcbank
    11. okaxis
    12. {
        "orderId": "1234567890",
        "customerId": "1234567890",
        "amount": 100,
        "currency": "INR",
        "description": "Monthly subscription",
        "gateway": "paytm",
        "shouldCreateMandate": true,
        "endUrl": "www.yoursite.tv",
        "returnUrl": "https://prod-api.viewlift.com/subscription/callback/juspay/1234567890/yoursitename"
      }
      
  2. Call the Mandate Registration API.
  3. Post the mandate registration is successful, you will receive a mandate_id, mandate_token from Juspay that ViewLift stores against a customer in the Tools Users module. For the subsequent charge transactions, ViewLift will pass a combination of customer_id and mandate_id to do a debit without a 2FA. This API will create an order and perform a transaction with payment gateways based on the mandate_id passed in the request. For more information, see this reference article.
    For every recurring debit, we call JusPay's Mandate Execution API and JusPay calls the execute API of the payment gateway on T-day, and debit will happen accordingly.

How ViewLift creates recurring orders

On renewals, ViewLift checks to see if the mandate is valid. If it is, we use it to create the order ID for the next billing period. An order ID is a random 20-digit string we create containing the order details and then is sent as part of the payload to JusPay. JusPay uses the order ID to process the payment. ViewLift can then either pull the JusPay API or wait for JusPay to send webhook notifications about the order's status. Based on the order's status, ViewLift can determine whether or not to cancel the user's subscription.

A sample payload when ViewLift requests payment status is as follows:

{
  customerEmail: '+91-mobilenumber@sampletv.com',
  customerPhone: 'customer-contact-number',
  customerId: 'abc50d8e-323f-4829-ghi7-j0klmf5083ca',
  statusId: 21,
  status: 'CHARGED',
  id: 'ordeu_12344e0fd9534840a5430cf616d75987',
  merchantId: 'sampletv',
  amount: 499,
  currency: 'INR',
  orderId: 'QuMPGLdB8BFz93TuSb4E',
  dateCreated: '2023-05-27T03:38:26Z',
  returnUrl: '',
  productId: '',
  paymentLinks: {
    iframe: 'https://api.juspay.in/merchant/ipay/ordeu_12344e0fd9534840a5430cf616d75987',
    web: 'https://api.juspay.in/orders/ordeu_12344e0fd9534840a5430cf616d75987/payment-page',
    mobile: 'https://api.juspay.in/orders/ordeu_12344e0fd9534840a5430cf616d75987/payment-page'
  },
  udf1: '',
  udf2: '',
  udf3: '',
  udf4: '3months1stream',
  udf5: '',
  udf6: 'sampletv',
  udf7: 'android_phone',
  udf8: '15683fe4-d9cf-4989-b5ff-4ad7afc33c89',
  udf9: '',
  udf10: '',
  txnId: 'sampletv-QuMPGLdB8BFz93TuSb4E-1',
  paymentMethodType: 'UPI',
  authType: '',
  paymentMethod: 'PAY',
  refunded: false,
  amountRefunded: 0,
  effectiveAmount: 499,
  respCode: null,
  respMessage: null,
  bankErrorCode: '',
  bankErrorMessage: '',
  txnUuid: 'mozemGVX6R3PgwiUUS4',
  txnDetail: {
    txn_id: 'sampletv-QuMPGLdB8BFz93TuSb4E-1',
    order_id: 'QuMPGLdB8BFz93TuSb4E',
    status: 'CHARGED',
    error_code: null,
    net_amount: 499,
    surcharge_amount: null,
    tax_amount: null,
    txn_amount: 499,
    offer_deduction_amount: null,
    gateway_id: 23,
    currency: 'INR',
    express_checkout: false,
    redirect: false,
    txn_uuid: 'mozemGVX6R3PgwiUUS4',
    gateway: 'RAZORPAY',
    error_message: '',
    txn_object_type: 'EMANDATE_PAYMENT',
    source_object: 'MANDATE',
    source_object_id: '12329284',
    created: '2023-05-27T03:38:26Z'
  },
  paymentGatewayResponse: {
    respCode: 'captured',
    rrn: '314829598264',
    created: 2023-05-27T03:43:25.000Z,
    epgTxnId: 'pay_LuXiUbMctaOC1f',
    respMessage: '',
    authIdCode: '',
    txnId: 'sampletv-QuMPGLdB8BFz93TuSb4E-1',
    debitAmount: '499.0'
  },
  gatewayId: 23,
  payerVpa: 'mobilenumber@upi',
  payerAppName: 'in.org.npci.upiapp',
  upi: {
    payer_app: 'in.org.npci.upiapp',
    payer_vpa: 'mobilenumber@upi',
    txn_flow_type: 'PAY'
  },
  gatewayReferenceId: null,
  offers: [],
  maximumEligibleRefundAmount: 499
}

Troubleshooting

If you are experiencing problems with mandate payments, you can try the following troubleshooting steps:

  • Check that the mandate order has been created successfully.
  • Check that the mandate has been registered successfully.
  • Check that the mandate execution API has been called successfully.
  • Check that the customer has sufficient funds in their bank account.
  • Contact JusPay support for assistance.

Create a JusPay Screen 

Set up a System Screen page for JusPay Payments and add the JusPay Payment Gateway module as presented in the screenshot below. Open the settings menu, here you can add text (provide the name of the payment service in Title field) and logos for payment options that you want to support. The options include net banking, Cards, UPI, and wallets. These are organized into sections on the site and apps. Publish the page once you've configured the payment options.


JusPay Payment page 


 



Was this article helpful?