Step 1: Create New Order (REST API) 🔗

Use the below url to create an order in your (backend) server.

UAT URL: https://uatapi.payg.in/payment/api/order

Production URL: https://paygapi.payg.in/payment/api/order

/create


Authorization: basic authentication with base64encoded

PayGAuthentication –
 <MerchantAuthenticationKey>: <MerchantAuthenticationToken>:M: <MerchantKeyId>
  
						
                        
{
  "Merchantkeyid":  "7963",
  "UniqueRequestId":  "f3f5b5c13f",
  "UserDefinedData": {
    "UserDefined1":  ""
  },
  "RequestDateTime":  "06232021",
  "RedirectUrl":  "https://payg.in",
  "TransactionData": {
    "AcceptedPaymentTypes":  "",
    "PaymentType":  "",
    "SurchargeType":  "",
    "SurchargeValue":  "",
    "RefTransactionId":  "",
    "IndustrySpecificationCode":  "",
    "PartialPaymentOption":  ""
  },
  "OrderAmount":  "100",
  "OrderType":  "",
  "OrderAmountData": {
    "AmountTypeDesc":  "3",
    "Amount":  "2"
  },
  "CustomerData": {
    "CustomerId":  "152433",
    "CustomerNotes":  "amway product",
    "FirstName":  "kanhaiya",
    "LastName":  "dhaked",
    "MobileNo":  "08619083450",
    "Email":  "demo@gmail.com",
    "EmailReceipt":  "true",
    "BillingAddress":  "44 bhawar nagar semal",
    "BillingCity":  "semla",
    "BillingState":  "Rajasthan",
    "BillingCountry":  "India",
    "BillingZipCode":  "30202020",
    "ShippingFirstName":  "yagyang",
    "ShippingLastName":  "dhaked",
    "ShippingAddress":  "44 bhawar nagar semal",
    "ShippingCity":  "semla",
    "ShippingState":  "Rajasthan",
    "ShippingCountry":  "India",
    "ShippingZipCode":  "30202020",
    "ShippingMobileNo":  "08619083450"
  },
  "IntegrationData": {
    "UserName":  "ranjith",
    "Source":  "3213",
    "IntegrationType":  "11",
    "HashData":   "",
    "PlatformId":  "1"
  },
 
}
  
 
         
public Process create(HttpServletRequest request) throws IOException {
      Map mapData = new HashMap();
      mapData.put("Merchantkeyid", this.MerchantKeyId);
      mapData.put("UniqueRequestId", Order.generateRandomString(10));
      
      Map uData = new HashMap();
      uData.put("UserDefined1", "");
      mapData.put("UserDefinedData", uData);
      
      SimpleDateFormat dt = new SimpleDateFormat("MMddyyyy");
      mapData.put("RequestDateTime", dt.format(new Date()));
      mapData.put("RedirectUrl", this.RedirectUrl);
      
      Map tranData = new HashMap();
      tranData.put("AcceptedPaymentTypes", "");
      tranData.put("PaymentType", "");
      tranData.put("SurchargeType", "");
      tranData.put("SurchargeValue", "");
      tranData.put("RefTransactionId", "");
      tranData.put("IndustrySpecificationCode", "");
      tranData.put("PartialPaymentOption", "");
      
      mapData.put("TransactionData", tranData);
      
      Map custData = new HashMap();
      Map orderData = new HashMap();
      Map intgData = new HashMap();
      
      for (Entry entry : request.getParameterMap().entrySet()) {
          String name = entry.getKey();
          if (name.startsWith("CustomerData[")) {
              String key = name.substring(name.indexOf('[') + 1, name.indexOf(']')); 
              custData.put(key, entry.getValue()[0]);
          }
          else if (name.startsWith("OrderAmountData[")) {
              String key = name.substring(name.indexOf('[') + 1, name.indexOf(']')); 
              orderData.put(key, entry.getValue()[0]);
          }
          else if (name.startsWith("IntegrationData[")) {
              String key = name.substring(name.indexOf('[') + 1, name.indexOf(']')); 
              intgData.put(key, entry.getValue()[0]);
          }
      }
      mapData.put("CustomerData", custData);
      mapData.put("OrderAmountData", orderData);
      mapData.put("IntegrationData", intgData);

      String auth = this.AuthenticationKey+":"+this.AuthenticationToken+":M:"+this.MerchantKeyId;
      
      String shellcmd = "curl -X POST -d \""+new Gson().toJson(mapData)+"\" "+this.paymentURL+"/create"+" -H \"Content-Type: application/json\" -H \"Authorization:  Basic "+Base64.getEncoder().encodeToString(auth.getBytes("utf-8"))+"\"";
      //System.out.println(shellcmd);
      return Runtime.getRuntime().exec(shellcmd);
   }
   

      
{"OrderKeyId":"210619M11172U6f463b05b1",
"MerchantKeyId":11172,
"UniqueRequestId":"6f463b05b1",
"OrderType":"PAYMENT",
"OrderAmount":45,
"OrderId":77,
"OrderStatus":'',
"OrderPaymentStatus":0,
"OrderPaymentStatusText":'',
"PaymentStatus":0,
"PaymentTransactionId":'',
"PaymentResponseCode":0,
"PaymentApprovalCode":'',
"PaymentTransactionRefNo":'',
"PaymentResponseText":'',
"PaymentMethod":'',
"PaymentAccount":'',
"OrderNotes":'',
"PaymentDateTime":'',
"UpdatedDateTime":'',
"PaymentProcessUrl":"https:\/\/payg.in\/payment\/payment?orderid=210619M11172U6f463b05b1",
"OrderPaymentCustomerData":{
	"FirstName":"kanhaiya",
	"LastName":'dhaked',
	"Address":'jaipur',
	"City":'jaipur',
	"State":'RJ',
	"ZipCode":'302020',
	"Country":'IN',
	"MobileNo":"8619083450",
	"Email":"kl.nagar7@gmail.com",
	"UserId":'34',
	"IpAddress":'127.0.0.1'
	},
"UpiLink":"upi:\/\/pay?pa=A2zfame@yesbank&pn=A2zfame&mc=8999&am=0&mam=null&cu=INR&mode=01&orgid=00000&mid=YES0000001558758&sign=YzYxYzhmOWI5MjY1MjM3ZDEzMzQ0NDhkYWQ3NTNlZGE5OTcwMDE2MjEyODQ2ZDFiZjdlNTU4YmM3OThkOTY0NGIxYzk3OGIxNGZjM2VkMWRhYjA2MDA4MDhhZDY2M2Q2Y2I5MWQ4ZmExMTAzMjU0YzJhNTk4MDRjMzhlZmVkNGI="
}
  
 

Step 2: Payment process url for checkout 🔗

This payment url is used to redirect to actual payment screen.

Developer can redirect either by using javascript or other programming language.

This is a javascript example like window.location="Payment process url"

Step 3: Order Details (API request Parameters) 🔗

      
Authorization: basic authentication with base64encoded
PayGAuthentication –
<MerchantAuthenticationKey>:<MerchantAuthenticationToken>:M:<MerchantKeyId>
      
      

      
{
  "OrderKeyId": "210624M7963Ubd259588d4",
  "MerchantKeyId": "7963",
  "PaymentType": ''
};
 
      
      
      
   public Process enquire(HttpServletRequest request,int orderKeyID,String paymentType) throws IOException {
      Map mapData = new HashMap();
      mapData.put("Merchantkeyid", this.MerchantKeyId);
      mapData.put("OrderKeyID", orderKeyID);
      mapData.put("PaymentType", paymentType);
      
      String auth = this.AuthenticationKey+":"+this.AuthenticationToken+":M:"+this.MerchantKeyId;
      String shellcmd = "curl -X POST -d \""+ new Gson().toJson(mapData)+"\" "+this.paymentURL+"/Detail"+" -H \"Content-Type: application/json\" -H \"Authorization:  Basic "+Base64.getEncoder().encodeToString(auth.getBytes("utf-8"))+"\"";
      return Runtime.getRuntime().exec(shellcmd);
   }
}
      
      

      
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL =>'uatapi.payg.in/payment/api/order/Detail',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING =>   "", 
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>$payload_data,
  CURLOPT_HTTPHEADER => $header,
));

$response = curl_exec($curl);
curl_close($curl);
 
      
      

      
{
"OrderKeyId": "210624M7963Ubd259588d4",
"MerchantKeyId":  7963,
"UniqueRequestId":  "bd259588d4",
"OrderType":  "213",
"OrderAmount":  1.00,
"OrderId":  null,
"OrderStatus":  "0",
"OrderPaymentStatus":  0,
"OrderPaymentStatusText":  null,
"PaymentStatus":  0,
"PaymentTransactionId":  null,
"PaymentResponseCode":  0,
"PaymentApprovalCode":  null,
"PaymentTransactionRefNo":  null,
"PaymentResponseText":  null,
"PaymentMethod":  null,
"PaymentAccount":  null,
"OrderNotes":  null,
"PaymentDateTime":  null,
"UpdatedDateTime":  "6/24/2021 6:12:43 PM",
"PaymentProcessUrl":  null,
"OrderPaymentCustomerData":  null,
"UpiLink":  null
}
      
      
Note: Please check the payment status codes from this URL Payment Response codes Note: Please check the error codes from this URL Error codes