Guides
Payin

Payin

The Payin API allows you to initiate payment collection from your customers. This endpoint supports various payment methods including UPI, PhonePe, Paytm, and Google Pay.

Authentication

This endpoint requires Bearer token authentication. The token should be generated by Base64 encoding your API credentials in the format api_key:api_secret.

Authorization: Bearer <base64_encoded_credentials>
Content-Type: application/json

Create Payin

POST https://api.payvanta.in/payin

Request Parameters

ParameterTypeRequiredDescription
order_idstringYesUnique identifier for the transaction
amountnumberYesAmount to be collected (in INR)
mobile_nostringYesCustomer's mobile number

Example Request

{
    "order_id": "123456789012345",
    "amount": 50,
    "mobile_no": "9910000065"
}

Success Response

{
    "success": true,
    "message": "PAYIN_INITIATED",
    "data": {
        "order_id": "123456789012345",
        "amount": 50,
        "status": "PENDING",
        "payment_link": "upi://pay?ver=01&mode=19&pa=merchant@upi&pn=PayVanta&tr=123456789012&cu=INR&mc=8241&qrMedium=04&tn=PaymenttoPayVanta&am=49.97"
    }
}

Response Fields

FieldTypeDescription
successbooleanIndicates if the request was successful
messagestringStatus message
data.order_idstringOrder ID of the transaction
data.amountnumberAmount of the transaction
data.statusstringStatus of the transaction (PENDING, FAILED)
data.payment_linkstringUPI payment link for direct app opening

Implementing UPI Deep Links

The payment_link in the response can be used to redirect users directly to their UPI apps. Here's how to implement it:

HTML + JavaScript Implementation

<!-- UPI Payment Button -->
<button onclick="initiateUPIPayment()">Pay with UPI</button>
 
<script>
  function initiateUPIPayment() {
    // Replace with the payment_link from the API response
    const upiUrl = "upi://pay?ver=01&mode=19&pa=merchant@upi&pn=PayVanta&tr=123456789012&cu=INR&mc=8241&qrMedium=04&tn=PaymenttoPayVanta&am=49.97";
 
    // Redirect user to UPI app
    window.location.href = upiUrl;
  }
</script>

How It Works

  1. The UPI deep link (payment_link) follows a standard URI format: upi://pay?...
  2. When clicked, it triggers installed UPI apps on Android devices (PhonePe, Google Pay, Paytm, etc.)
  3. The payment details are pre-filled in the UPI app based on the parameters
  4. After payment, the user is redirected back to your application

Important Considerations

  1. Browser Compatibility
    • UPI deep links work best on Android devices
    • Consider implementing a fallback mechanism for devices without UPI apps
    • Test across different browsers and devices

Payment Status Values

StatusDescription
PENDINGPayment is initiated but not completed
SUCCESSPayment completed successfully
FAILEDPayment failed

Error Codes

CodeDescription
INVALID_AMOUNTInvalid payment amount
INVALID_ORDER_IDInvalid or duplicate order ID
PAYMENT_FAILEDPayment processing failed
PAYMENT_EXPIREDPayment link has expired
INVALID_MOBILEInvalid mobile number format

Best Practices

  1. Always use unique order_id for each transaction
  2. Validate the amount before initiating the payment
  3. Implement webhook handling for real-time payment updates
  4. Store the payment response for reconciliation
  5. Handle all possible payment status scenarios
  6. Test the integration in sandbox environment first

Webhooks

PayVanta will send payment status updates to your webhook URL. Example webhook payload:

{
  "type": "payin",
  "payload": {
    "order_id": "123456789012345",
    "amount": 50,
    "status": "SUCCESS",
    "utr": "UTR24031545789",
    "upi": "user@okaxis",
    "code": "PAYMENT_SUCCESS"
  }
}

For webhook integration details, refer to the Webhooks Guide.

Next Steps