Skip to main content

Accept Payments API

How to Get Started
To use the Redirect Checkout, start by integrating with our Accept Payment API. This API is designed to simplify the way you initiate and manage transactions, providing a seamless checkout experience for your customers.

Steps to Integrate

Step 1: Invoke Accept Payments API
Step 2: Handling callback response and signature verification
Step 3: Integrating with Inquiry and Refunds API
Step 4: Configure webhooks

Step 1: Invoke Accept Payments API

The first step is to create a Accept Payments request, including all necessary parameters for the API. This JSON request will further be hashed to secure the API call.

Step 1.1: Create an Accept Payments Request

Sample Request

{
"merchant_data": {
"merchant_id": 107994,
"merchant_access_code": "2e4adb40-296e-4fa7-88ec-b1fcdf5aadcc",
"unique_merchant_txn_id": "XYZ123",
"merchant_return_url": "https://stage-webapp.paytm.in/peon.php"
},
"payment_data": {
"amount_in_paisa": 800
},
"txn_data": {
"navigation_mode": "2",
"payment_mode": "1,3,4,19,10,11,14",
"transaction_type": "1",
"time_stamp": 157588000000
},
"product_details": [
{
"product_code": "SKU1",
"product_amount": 2000000
}
]
}

Request Parameters

Parameter NameTypeDescriptionMandatory(M)/Optional
merchant_dataObjectIt contains merchant dataM
payment_dataObjectIt contains payment related dataM
txn_dataObjectIt contains transaction related dataM
customer_dataObjectIt contains information about customer data.O
udf_dataObjectIt contains user defined fields. Merchant can pass it transaction specific data in these fieldsO
Merchant Data
Parameter NameTypeDescriptionMandatory(M)/Optional/Conditional
merchant_idintMerchant id provided by pine labsM
merchant_access_codestringMerchant access code provided by pine labsM
unique_merchant_txn_idstringUnique transaction id maintained by merchant for each transactionM
merchant_return_urlstringMerchant returnurl on which browser response will be sentM
Payment Data
Parameter NameTypeDescriptionMandatory(M)/Optional
amount_in_paisalongTransaction amount in paiseM
Transaction Data
Parameter NameTypeDescriptionMandatory(M)/Optional
navigation_modeintNavigation mode 2 for Redirect, 7 for SeamlessM
payment_modestringIt will contain csv of valid payment mode Ids. In case of seamless mode only single payment mode to be specified. Refer to payment modes table.M
transaction_typeInteger1 for ‘Purchase’M
time_stampLongUnix timestampO
Payment Modes
PAYMENT_MODE_IDPAYMENT_MODE_NAME
1CREDIT/DEBIT CARD
3NET BANKING
4CREDIT EMI
10UPI
11WALLET
14DEBIT EMI
16PREBOOKING
17BNPL/FLEXIPAY
19Cardless EMI
20PBP (Paybypoints)
Customer Data
Parameter NameTypeDescriptionMandatory(M)/Optional
email_idstringCustomer email idO
first_namestringCustomer first nameO
last_namestringCustomer last nameO
customer_idstringCustomer id maintained at merchant endO
mobile_nostring10 digit mobile numberO
Billing Data
Parameter NameTypeDescriptionMandatory(M)/Optional
address1stringAddress 1O
address2stringAddress 2O
address3stringAddress 3O
pincodestringPin codeO
citystringCity nameO
statestringState nameO
countrystringCountry nameO
Shipping Data
Parameter NameTypeDescriptionMandatory(M)/Optional
first_nameStringFirst name entered in shipping addressO
last_nameStringLast name entered in shipping addressO
mobile_nostringMobile number entered in shipping addressO
address1stringAddress 1O
address2stringAddress 2O
address3stringAddress 3O
pincodestringPin codeO
citystringCity nameO
statestringState nameO
countrystringCountry nameO

Step 1.2: Encode the API request

Use the CURL request from Step 1 to convert it into Base64 format. Below is an example of the encoded request:

Encoded Request Example

{
"request":"ewogICAgIm1lcmNoYW50X2RhdGEiOiB7CiAgICAgICAgIm1lcmNoYW50X2lkIjogMTA3OTk0LAogICAgICAgICJtZXJjaGFudF9hY2Nlc3NfY29kZSI6ICIyZTRhZGI0MC0yOTZlLTRmYTctODhlYy1iMWZjZGY1YWFkY2MiLAogICAgICAgICJ1bmlxdWVfbWVyY2hhbnRfdHhuX2lkIjogIlhZWjEyMyIsCiAgICAgICAgIm1lcmNoYW50X3JldHVybl91cmwiOiAiaHR0cHM6Ly9zdGFnZS13ZWJhcHAucGF5dG0uaW4vcGVvbi5waHAiCiAgICB9LAogICAgInBheW1lbnRfZGF0YSI6IHsKICAgICAgICAiYW1vdW50X2luX3BhaXNhIjogODAwCiAgICB9LAogICAgInR4bl9kYXRhIjogewogICAgICAgICJuYXZpZ2F0aW9uX21vZGUiOiAiMiIsCiAgICAgICAgInBheW1lbnRfbW9kZSI6ICIxLDMsNCwxOSwxMCwxMSwxNCIsCiAgICAgICAgInRyYW5zYWN0aW9uX3R5cGUiOiAiMSIsCiAgICAgICAgInRpbWVfc3RhbXAiOiAxNTc1ODgwMDAwMDAKICAgIH0sCiAgICAicHJvZHVjdF9kZXRhaWxzIjogWwogICAgICAgIHsKICAgICAgICAgICAgInByb2R1Y3RfY29kZSI6ICJTS1UxIiwKICAgICAgICAgICAgInByb2R1Y3RfYW1vdW50IjogMjAwMDAwMAogICAgICAgIH0KICAgIF0KfQ=="
}

Step 1.3: Generating a hash value

In this step, generate a hash value from the Base64-encoded request. This hash serves as a unique identifier and an authentication mechanism, enhancing the security of the API call used to accept payments.

Hash Generation logic

public static string GenerateCreateOrderHash(string request, string secret)
{
try
{
using (var hmac = new HMACSHA256(HexToByteArray(secret)))
{
var data = Encoding.UTF8.GetBytes(request);
var hashBytes = hmac.ComputeHash(data);
var hash = BitConverter.ToString(hashBytes).Replace("-", "").ToUpper();
return hash;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}

Step 1.4: Trigger Accept Payment API

Use the generated hash to send a payment request. This step creates a redirect URL where your customers will complete their payment.

API Endpoints:

UAT: https://uat.pinepg.in/api/v2/accept/payment
Production: https://pinepg.in/api/v2/accept/payment

Redirect customers to the URL given in the "redirect_url" of the Accept Payment API to accept payments.

curl --location 'https://uat.pinepg.in/api/v2/accept/payment' \
--header 'X-VERIFY: 2DA74DEF5A835093487882E670D3021F1880CEF3FA4DBDAEE9DE29A516A45FE5' \
--header 'Content-Type: application/json' \
--header 'Cookie: TS01385dd8=011bd729b0089a0835762551a5dbd4b3a9fe2bdd818e6d33efeac0c966ef176c3a5b889345ef44cc8136c62f4cf3545d326588b6c4' \
--data '{
"request": "ewogICAgIm1lcmNoYW50X2RhdGEiOiB7CiAgICAgICAgIm1lcmNoYW50X2lkIjogMTA3OTk0LAogICAgICAgICJtZXJjaGFudF9hY2Nlc3NfY29kZSI6ICIyZTRhZGI0MC0yOTZlLTRmYTctODhlYy1iMWZjZGY1YWFkY2MiLAogICAgICAgICJ1bmlxdWVfbWVyY2hhbnRfdHhuX2lkIjogIlhZWjEyMyIsCiAgICAgICAgIm1lcmNoYW50X3JldHVybl91cmwiOiAiaHR0cHM6Ly9zdGFnZS13ZWJhcHAucGF5dG0uaW4vcGVvbi5waHAiCiAgICB9LAogICAgInBheW1lbnRfZGF0YSI6IHsKICAgICAgICAiYW1vdW50X2luX3BhaXNhIjogODAwCiAgICB9LAogICAgInR4bl9kYXRhIjogewogICAgICAgICJuYXZpZ2F0aW9uX21vZGUiOiAiMiIsCiAgICAgICAgInBheW1lbnRfbW9kZSI6ICIxLDMsNCwxOSwxMCwxMSwxNCIsCiAgICAgICAgInRyYW5zYWN0aW9uX3R5cGUiOiAiMSIsCiAgICAgICAgInRpbWVfc3RhbXAiOiAxNTc1ODgwMDAwMDAKICAgIH0sCiAgICAicHJvZHVjdF9kZXRhaWxzIjogWwogICAgICAgIHsKICAgICAgICAgICAgInByb2R1Y3RfY29kZSI6ICJTS1UxIiwKICAgICAgICAgICAgInByb2R1Y3RfYW1vdW50IjogMjAwMDAwMAogICAgICAgIH0KICAgIF0KfQ=="
}'

Response Parameters

Parameter NameTypeDescription
response_codeintIt notifies the result of api processing. Value 1 denotes success.
response_messagestringIt denotes the message corresponding to the response_code.
tokenstringIt is the token created for a transaction. You need to pass it in the subsequent calls.
redirect_urlStringRedirect URL on which customer needs to be redirected. This parameter will be present only in redirect mode.

Step 2: Handling callback response and signature verification

After the transaction is complete a callback response will be posted to the "merchant_return_url". To understand the status of the transaction, it is important to consume the following parameters:

  1. pine_pg_txn_status
  2. txn_response_code

Sample Response

{
"merchant_id": "107994",
"merchant_access_code": "2e4adb40-296e-4fa7-88ec-b1fcdf5aadcc",
"unique_merchant_txn_id": "XYZ123",
"pine_pg_txn_status": "4",
"txn_completion_date_time": "08/05/2024 06:12:25 PM",
"amount_in_paisa": "800",
"txn_response_code": "1",
"txn_response_msg": "SUCCESS",
"acquirer_name": "HDFC",
"pine_pg_transaction_id": "14722293",
"captured_amount_in_paisa": "800",
"refund_amount_in_paisa": "0",
"payment_mode": "1",
"udf_field_1": "",
"card_holder_name": "Meghana",
"Acquirer_Response_Code": "CAPTURED",
"Acquirer_Response_Message": "CAPTURED",
"is_surcharge_txn": "1",
"convenience_fees_in_paise": "0",
"convenience_gst_in_paise": "0",
"convenience_additional_charges_in_paise": "0",
"parent_txn_status": "",
"parent_txn_response_code": "",
"parent_txn_response_message": "",
"dia_secret": "BC1B7F0C1C51090373D17E7D9FC910A89886B4A412CD55923C31EC40D21F11E4",
"dia_secret_type": "SHA256"
}
Callback Description
ParameterDatatypeDescription
merchant_idIntegerIn response you can see the merchant_id which you have sent as one of the parameters in Pine Labs payment gateway API request parameters.
merchant_access_codeStringIn response you can find the merchant access code which you have sent as one of the parameters.
pine_pg_txn_statusIntegerTransaction status
txn_completion_date_timeDateTimeThe date-time of the transaction completion at Pine Labs payment gateway server.
amount_in_paisaLongIt is the amount for which payment transaction is being done.
txn_response_codeIntegerRepresent the response of the API request and response code is returned based on the transaction result.
txn_response_msgStringTransaction response message
acquirer_nameStringAcquirer Bank
pine_pg_transaction_idLongUnique transaction id generated by Pine Labs
payment_modeIntegerPayment mode chosen at landing page.
dia_secretStringHash of response parameters. Please refer to HashGeneration document. Pine Labs payment gateway creates the hash of the response parameters and sends this information in response in tag dia_secret. Merchant should use this hash value returned in response to match...
dia_secret_typeString‘SHA256’ or ‘MD5’ and will be the same which is passed in dia_secret_type parameter of request
is_bank_emi_txnBoolFlag to indicate Bank EMI transaction
is_brand_emi_txnBoolFlag to indicate Brand EMI transaction
emi_tenure_monthIntegerTenure month of EMI transaction
emi_principal_amount_in_paisaLongPrincipal EMI amount in Paise
emi_amount_payable_each_month_in_paisaLongMonthly Installment
emi_interest_rate_percentIntegerInterest rate charged by bank multiplied by 10000
emi_cashback_typeIntegerIts value will be 0, 1,2 and 3: 0- Standard EMI, 1- Pre cash back, 2- Post cash back, 3- Instant Cashback
emi_total_discount_cashabck_amount_in_paisaLongTotal discount or cashback amount applicable in EMI transaction in paise
emi_total_discount_cashback_percentIntegerTotal discount or cashback percent applicable in EMI transaction multiplied by 10000
emi_merchant_discount_cashabck_perecentIntegerMerchant discount or cashback percent applicable in EMI transaction multiplied by 10000
emi_merchant_discount_cashback_fixed_amount_in_paisaLongMerchant fixed discount or cashback amount applicable in EMI transaction in paise
emi_issuer_discount_cashabck_perecentIntegerIssuer discount or cashback percent applicable in EMI transaction multiplied by 10000
emi_issuer_discount_cashback_fixed_amount_in_paisaLongIssuer fixed discount or cashback amount applicable in EMI transaction in paise
emi_additional_cashbackStringAdditional Cashback in case of EMI Transaction
txn_additional_infoStringBase64 encoded string
merchant_return_urlStringMerchant return url
emi_processing_feelongProcessing fee amount in paise.
manufacturerStringManufacturer name in case of brand emi transaction
product_categoryStringProduct category in case of brand emi transaction
product_descriptioStringProduct description in case of brand emi transaction
product_discountlongProduct discount in case of brand emi transaction. It is the flat discount given on product
captured_amount_in_paisalongCaptured amount for a transaction
refund_amount_in_paisalongRefund amount for a transaction
parent_txn_statusIntegerParent txn status
parent_txn_response_codeIntegerParent txn response code
parent_txn_response_messageStringParent txn response message
issuer_nameStringIssuing bank name.
udf_field_1StringUdf field1 which comes in payment initiation request
udf_field_2StringUdf field2 which comes in payment initiation request
udf_field_3StringUdf field3 which comes in payment initiation request
udf_field_4StringUdf field4 which comes in payment initiation request
card_holder_nameStringCard holder name in case of card transaction
salted_card_hashStringSalted card hash in case of card transaction
masked_card_numberStringMasked Card number in case of card transaction
auth_codeStringauth code received from acquirer in authorization response
rrnStringrrn number received from acquirer in authorization response
Acquirer_Response_CodeStringacquirer response code received from acquirer in authorization response
Acquirer_Response_MessageStringacquirer response message received from acquirer in authorization response
is_surcharge_txnint1 value will be come if transaction is convenience fee else 0
convenience_fees_in_paiselongTotal convenience fees applied on transaction
convenience_gst_in_paiselongTotal convenience fees gst applied on transaction
convenience_additional_charges_in_paiselongTotal convenience fees additional fees applied on transaction
auth_idStringauth id received in authorization response
Response Status
Transaction Statepine_pg_txn_statustxn_response_code
Success41
Failure1-1
Initiated11
Failure - Payment / Full Refund / Partial Refund failed-7Any code

Signature Verification

This is a mandatory step to confirm the authenticity of the details returned to you on the return URL for successful payments. Refer to the steps below to ensure that the data is authentic and not tampered with. To find the signature refer to the dia_secret parameter in the response parameters.

Step 2.1: Remove parameters from response recieved:

  • dia_secret
  • dia_secret_type

Step 2.2: Sort the payload into an alphabetical order and convert into "&" separated string

Acquirer_Response_Code=0300&Acquirer_Response_Message=DEFAULT&acquirer_name=BILLDESK&amount_in_paisa=1000&ca ptured_amount_in_paisa=1000&merchant_access_code=4a39a6d4-46b7-474d-929d-
21bf0e9ed607&merchant_id=106598&mobile_no=&parent_txn_response_code=&parent_txn_response_message=&parent_txn_ status=&payment_mode=3&pine_pg_transaction_id=14635747&pine_pg_txn_status=4&refund_amount_in_paisa=0&txn_compl etion_date_time=18/03/2024 04:44:49
PM&txn_response_code=1&txn_response_msg=SUCCESS&udf_field_1=&udf_field_2=&udf_field_3=&udf_field_4=&unique_merc hant_txn_id=TestNode3222

Step 2.3: Hashing the payload

156A7BD91DCC0A7BD9D080FDC900581A7BC65D8B17A535E24CE6A042B93DF7C9

Step 2.4: Match the generated signature with the received signature in the dia_secret parameter of response

Error Handling

Step 3: Integrating with Inquiry and Refunds API

After integrating with the Accept Payments API, integrate with the Refunds and Inquiry API to query the status of transaction and refunds.

Step 4: Configure Webhooks

After integrating with Refunds and Inquiry API, configure webhooks to get real-time updates on transaction and refund status. Complete this step to start accepting payments.