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/jsonCreate Payin
POST https://api.payvanta.in/payinRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| order_id | string | Yes | Unique identifier for the transaction |
| amount | number | Yes | Amount to be collected (in INR) |
| mobile_no | string | Yes | Customer'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
| Field | Type | Description |
|---|---|---|
| success | boolean | Indicates if the request was successful |
| message | string | Status message |
| data.order_id | string | Order ID of the transaction |
| data.amount | number | Amount of the transaction |
| data.status | string | Status of the transaction (PENDING, FAILED) |
| data.payment_link | string | UPI 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
- The UPI deep link (
payment_link) follows a standard URI format:upi://pay?... - When clicked, it triggers installed UPI apps on Android devices (PhonePe, Google Pay, Paytm, etc.)
- The payment details are pre-filled in the UPI app based on the parameters
- After payment, the user is redirected back to your application
Important Considerations
- 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
| Status | Description |
|---|---|
PENDING | Payment is initiated but not completed |
SUCCESS | Payment completed successfully |
FAILED | Payment failed |
Error Codes
| Code | Description |
|---|---|
INVALID_AMOUNT | Invalid payment amount |
INVALID_ORDER_ID | Invalid or duplicate order ID |
PAYMENT_FAILED | Payment processing failed |
PAYMENT_EXPIRED | Payment link has expired |
INVALID_MOBILE | Invalid mobile number format |
Best Practices
- Always use unique
order_idfor each transaction - Validate the amount before initiating the payment
- Implement webhook handling for real-time payment updates
- Store the payment response for reconciliation
- Handle all possible payment status scenarios
- 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.