Manage Payments

Learn how you can manage payments using Plural APIs.

Listed below are the various options available to manage your payments.

  1. Inquiry: Use this request to know the payment statuses.
  2. Refund: Use this request to refund the payment.

Use the below endpoint to handle both Inquiry and Refund operations. The type of operation is identified by the content of the request body.

POST: https://uat.pinepg.in/api/PG/v2
POST: https://pinepg.in/api/PG/v2

Request Headers

  • Content-Type: application/x-www-form-urlencoded

Operations

1. Inquiry

An Inquiry request allows you to retrieve the status or details of a specific transaction.

As a pre-requisite you must generate the HashMap secret key to pass against the ppc_DIA_SECRET parameter of the Inquiry API request.

Follow the below steps to generate a HashMap secret key.

  1. Use the & separated payload format provided below to enter the transaction details you wish to Inquire about.
ppc_MerchantAccessCode=cfd05c0c-39f1-4232-bd6f-6d3a8608e1be&ppc_MerchantID=279082&ppc_TransactionType=3&ppc_UniqueMerchantTxnID=testingedgeseamless1123145432

Request Payload Parameters

Click Here

The table below lists the various JSON parameters.

ParameterTypeRequirement TypeDescription
ppc_MerchantAccessCodestringMUnique access code of the merchant in Plural database.

Example: 1a39a6d4-46b7-124d-929d-21bf0e9ed123
ppc_MerchantIDstringMUnique identifier of the merchant in the Plural database.

Example: 123456
ppc_TransactionTypestringMThe type of operation.

Accepted values:
  • 3: For Inquiry.
  • 10: For Refund.
ppc_UniqueMerchantTxnIDstringMUnique merchant transaction ID.

Example: 1234567890

Note: You must enter the transaction ID passed in the accept payment API request.

📘

Note:

  • The Request payload is sorted alphabetically by the key names.
  • Please ensure you use the same order of key-value pairs as provided in the payload to generate a HashMap secret.
  1. Use the sample code provided below to generate a SHA256 HashMap.
  2. In the sample code use the request payload with updated transaction details along with your secret key to generate a SHA256 Hash.
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.DatatypeConverter;

public class SignatureGenerator {

    public static String jsonHash(String request, String secret) throws NoSuchAlgorithmException, InvalidKeyException, IllegalStateException, UnsupportedEncodingException {
        SecretKeySpec secretKeySpec = new SecretKeySpec(DatatypeConverter.parseHexBinary(secret), "HmacSHA256");
        Mac mac = Mac.getInstance("HmacSHA256");
        mac.init(secretKeySpec);
        byte[] hmacBytes = mac.doFinal(request.getBytes("UTF-8"));
        String ss = String.format("%02x", new BigInteger(1, hmacBytes));
        return bytesToHex(hmacBytes).toUpperCase();
    }
    private static String bytesToHex(byte[] bytes) {
        StringBuilder result = new StringBuilder();
        for (byte b : bytes) {
            result.append(String.format("%02X", b));
        }
        return result.toString();
    }

    public static void main(String[] args) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException {
        String responseBody = "<HashMap_payload>";
        String signingSecret = "<Secret_key>";

        String requestSignature = SignatureGenerator.jsonHash(responseBody,signingSecret);
        System.out.println(requestSignature);
    }
}
  1. Use the generate HashMap secret against the ppc_DIA_SECRET in the Inquiry request.

Shown below is a sample request and sample response for a Inquiry Request.

ppc_DIA_SECRET=DECF2D9D903BACAF85DA88B5686BC0FB6AB7681673E99191C86B4DC78C27277F&ppc_
DIA_SECRET_TYPE=SHA256&ppc_MerchantAccessCode=58ad283b-7c93-4f19-b072- b17e8ecfb20e&ppc_MerchantID=2415&ppc_TransactionType=3&ppc_UniqueMerchantTxnID=100000000000007687
{
  "ppc_MerchantID": "279082",
  "ppc_MerchantAccessCode": "cfd05c0c-39f1-4232-bd6f-6d3a8608e1be",
  "ppc_PinePGTxnStatus": "7",
  "ppc_TransactionCompletionDateTime": "17/07/2024 12:41:54 PM",
  "ppc_UniqueMerchantTxnID": "testingedgeseamless1123145432",
  "ppc_Amount": "100",
  "ppc_TxnResponseCode": "1",
  "ppc_TxnResponseMessage": "SUCCESS",
  "ppc_PinePGTransactionID": "342048376",
  "ppc_CapturedAmount": "100",
  "ppc_RefundedAmount": "0",
  "ppc_AcquirerName": "KOTAK_SETU",
  "ppc_DIA_SECRET": "9FFA2E99D14B6357E50D9AF2CF9D01D67B03FA1020BB88A82E76C962313FC004",
  "ppc_DIA_SECRET_TYPE": "SHA256",
  "ppc_PaymentMode": "10",
  "ppc_Parent_TxnStatus": "4",
  "ppc_ParentTxnResponseCode": "1",
  "ppc_ParentTxnResponseMessage": "SUCCESS",
  "ppc_UdfField1": "",
  "ppc_UdfField2": "",
  "ppc_UdfField3": "",
  "ppc_UdfField4": "",
  "ppc_RRN": "1721200204930238149",
  "ppc_AcquirerResponseCode": "SUCCESS",
  "ppc_AcquirerResponseMessage": "SUCCESS"
}

Refer to our Inquiry API Documentation for more information.

2. Refund

A Refund request allows you to initiate a refund for a specific transaction.

As a pre-requisite you must generate the HashMap secret key to pass against the ppc_DIA_SECRET parameter of the Refund request.

Follow the below steps to generate a HashMap secret key.

  1. Use the & separated payload format provided below to enter the transaction details you wish to Refund.
ppc_Amount=100&ppc_CurrencyCode=356&ppc_MerchantAccessCode=bcf441be-411b-46a1-aa88-c6e852a7d68c&ppc_MerchantID=106600&ppc_PinePGTransactionID=14709745&ppc_TransactionType=10&ppc_UniqueMerchantTxnID=refund%20test

Request Payload Parameters

Click Here

The table below lists the various JSON parameters.

ParameterTypeRequirement TypeDescription
ppc_AmountstringMThe total amount to be refunded.

Example: 10000
ppc_CurrencyCodestringMThe currency code of the amount to be refunded.

Example: 356: For INR.
ppc_MerchantAccessCodestringMUnique access code of the merchant in Plural database.

Example: 1a39a6d4-46b7-124d-929d-21bf0e9ed123
ppc_MerchantIDstringMUnique identifier of the merchant in the Plural database.

Example: 123456
ppc_PinePGTransactionIDstringMUnique transaction ID generated by Plural against an Order ID.

Example: 12345
ppc_TransactionTypestringMThe type of operation.

Accepted values:
  • 3: For Inquiry.
  • 10: For Refund.
ppc_UniqueMerchantTxnIDstringMUnique merchant transaction ID.

Example: 1234567890

Note: You must enter the transaction ID passed in the accept payment API request.

📘

Note:

The sample payload is sorted alphabetically by the key names. Please ensure you use the same order of key-value pairs as provided in the payload to generate a HashMap secret.

  1. Use the sample code provided below to generate a SHA256 Hash.
  2. In the sample code use the HashMap payload with updated transaction details along with your secret key to generate a SHA256 Hash.
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.DatatypeConverter;

public class SignatureGenerator {

    public static String jsonHash(String request, String secret) throws NoSuchAlgorithmException, InvalidKeyException, IllegalStateException, UnsupportedEncodingException {
        SecretKeySpec secretKeySpec = new SecretKeySpec(DatatypeConverter.parseHexBinary(secret), "HmacSHA256");
        Mac mac = Mac.getInstance("HmacSHA256");
        mac.init(secretKeySpec);
        byte[] hmacBytes = mac.doFinal(request.getBytes("UTF-8"));
        String ss = String.format("%02x", new BigInteger(1, hmacBytes));
        return bytesToHex(hmacBytes).toUpperCase();
    }
    private static String bytesToHex(byte[] bytes) {
        StringBuilder result = new StringBuilder();
        for (byte b : bytes) {
            result.append(String.format("%02X", b));
        }
        return result.toString();
    }

    public static void main(String[] args) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException {
        String responseBody = "<HashMap_payload>";
        String signingSecret = "<Secret_key>";

        String requestSignature = SignatureGenerator.jsonHash(responseBody,signingSecret);
        System.out.println(requestSignature);
    }
}
  1. Use the generate HashMap secret against the ppc_DIA_SECRET in the Refund request.

Shown below is a sample request and sample response for a Refund request.

ppc_Amount=10000&ppc_CurrencyCode=356&ppc_DIA_SECRET=1781AE06CAF31A32B79F31B82B140484 DD9C1B95CC0DD26C1CB4F1AE0D13C066&ppc_DIA_SECRET_TYPE=SHA256&ppc_MerchantAccessCode=58 ad283b-7c93-4f19-b072-
b17e8ecfb20e&ppc_MerchantID=2415&ppc_PinePGTransactionID=87943&ppc_TransactionType=10&ppc_UniqueMerchantTxnID
=100000000000007687&ppc_ImeiProductDetails=W3sicHJvZHVjdF9jb2RlIjoiNzgwMyIsImltZWlfbm8iOiI5ODQ4NDg4ODQ0In0sIH sicHJvZHVjdF9jb2RlIjoieGlhb21pX3BybyIsImltZWlfbm8iOiI5ODQ4NDg4Mjg0NSJ9XQ==
{
  "ppc_MerchantID": "279082",
  "ppc_MerchantAccessCode": "cfd05c0c-39f1-4232-bd6f-6d3a8608e1be",
  "ppc_PinePGTxnStatus": "1",
  "ppc_TransactionCompletionDateTime": "01/08/2024 10:25:07 AM",
  "ppc_UniqueMerchantTxnID": "Refund_1",
  "ppc_Amount": "100",
  "ppc_TxnResponseCode": "2",
  "ppc_TxnResponseMessage": "REFUND PROCESS INITIATED",
  "ppc_PinePGTransactionID": "0",
  "ppc_CapturedAmount": "0",
  "ppc_RefundedAmount": "0",
  "ppc_ParentTxnResponseCode": "1",
  "ppc_Parent_TxnStatus": "4",
  "ppc_ParentTxnResponseMessage": "SUCCESS",
  "ppc_DIA_SECRET": "EE3844A2B85588D20AA173269BCC4F3375ABDEE8631CFF1366B271FABB47AE6F",
  "ppc_DIA_SECRET_TYPE": "SHA256"
}

Below are the possible response combinations for an Inquiry and Refund call:

ppc_Parent_TxnStatusppc_ParentTxnResponseCodeTransaction StateTransaction Type
41SuccessPurchase
1-1FailurePurchase
11InitiatedPurchase
61Full Refund SuccessFull Refund
91Partial Refund SuccessPartial Refund
-7AnycodeFailure - Purchase / Full Refund / Partial RefundPurchase / Full Refund / Partial Refund

Refer to our Refund API Documentation for more information.