Validate a payment offer before payment. The response is the Offers validate JSON, passed through.
Use this endpoint to validate an offer before payment. txnid, offerKey, and bankcode are not fields. Offer keys are sent as offerKeys.
POST
/partner/validateOffer
Environment
| Environment | URL |
|---|---|
| Test Environment | https://test-partnerapilayer.payu.in/apilayer/partner/validateOffer |
| Production Environment | https://api.payu.in/partner/validateOffer |
Sample Request
curl -X POST https://test-partnerapilayer.payu.in/apilayer/partner/validateOffer \
-H "Content-Type: application/json" \
-H "Authorization: Bearer d4e5f6a7b8c90123456789abcdef0123456789abcdef0123456789abcdef0123" \
-d '{
"merchant_id": 8739528,
"reseller_id": "11ed-933c-ece48d50-a41d-023f883eb17c",
"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"amount": "1000.00",
"autoApply": false,
"merchantNceParamActive": false,
"offerKeys": [
"OFFER_KEY_1"
],
"paymentId": 403993715521855092,
"paymentDetail": {
"category": "creditcard",
"paymentCode": "CC",
"cardNumber": 411111,
"cardHash": "CARD_HASH",
"cardToken": "CARD_TOKEN",
"cardTokenType": 0,
"cardMask": 1111,
"vpa": "customer@upi"
},
"userDetail": {
"userToken": "USER_TOKEN",
"email": "[email protected]",
"phoneNo": "9999999999"
},
"skusDetail": {
"skus": [
{
"skuId": "SKU1",
"skuAmount": "100.00",
"quantity": "1",
"offerKeys": [
"OFFER_KEY_1"
],
"autoApply": false
}
]
}
}'import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class PartnerRequest {
public static void main(String[] args) throws Exception {
String body = "{\"merchant_id\": 8739528, \"reseller_id\": \"11ed-933c-ece48d50-a41d-023f883eb17c\", \"hash\": \"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\", \"amount\": \"1000.00\", \"autoApply\": false, \"merchantNceParamActive\": false, \"offerKeys\": [\"OFFER_KEY_1\"], \"paymentId\": 403993715521855092, \"paymentDetail\": {\"category\": \"creditcard\", \"paymentCode\": \"CC\", \"cardNumber\": 411111, \"cardHash\": \"CARD_HASH\", \"cardToken\": \"CARD_TOKEN\", \"cardTokenType\": 0, \"cardMask\": 1111, \"vpa\": \"customer@upi\"}, \"userDetail\": {\"userToken\": \"USER_TOKEN\", \"email\": \"[email protected]\", \"phoneNo\": \"9999999999\"}, \"skusDetail\": {\"skus\": [{\"skuId\": \"SKU1\", \"skuAmount\": \"100.00\", \"quantity\": \"1\", \"offerKeys\": [\"OFFER_KEY_1\"], \"autoApply\": false}]}}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://test-partnerapilayer.payu.in/apilayer/partner/validateOffer"))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer d4e5f6a7b8c90123456789abcdef0123456789abcdef0123456789abcdef0123")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}import requests
url = "https://test-partnerapilayer.payu.in/apilayer/partner/validateOffer"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer d4e5f6a7b8c90123456789abcdef0123456789abcdef0123456789abcdef0123"
}
payload = {
"merchant_id": 8739528,
"reseller_id": "11ed-933c-ece48d50-a41d-023f883eb17c",
"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"amount": "1000.00",
"autoApply": false,
"merchantNceParamActive": false,
"offerKeys": [
"OFFER_KEY_1"
],
"paymentId": 403993715521855092,
"paymentDetail": {
"category": "creditcard",
"paymentCode": "CC",
"cardNumber": 411111,
"cardHash": "CARD_HASH",
"cardToken": "CARD_TOKEN",
"cardTokenType": 0,
"cardMask": 1111,
"vpa": "customer@upi"
},
"userDetail": {
"userToken": "USER_TOKEN",
"email": "[email protected]",
"phoneNo": "9999999999"
},
"skusDetail": {
"skus": [
{
"skuId": "SKU1",
"skuAmount": "100.00",
"quantity": "1",
"offerKeys": [
"OFFER_KEY_1"
],
"autoApply": false
}
]
}
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://test-partnerapilayer.payu.in/apilayer/partner/validateOffer",
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"merchant_id\": 8739528, \"reseller_id\": \"11ed-933c-ece48d50-a41d-023f883eb17c\", \"hash\": \"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\", \"amount\": \"1000.00\", \"autoApply\": false, \"merchantNceParamActive\": false, \"offerKeys\": [\"OFFER_KEY_1\"], \"paymentId\": 403993715521855092, \"paymentDetail\": {\"category\": \"creditcard\", \"paymentCode\": \"CC\", \"cardNumber\": 411111, \"cardHash\": \"CARD_HASH\", \"cardToken\": \"CARD_TOKEN\", \"cardTokenType\": 0, \"cardMask\": 1111, \"vpa\": \"customer@upi\"}, \"userDetail\": {\"userToken\": \"USER_TOKEN\", \"email\": \"[email protected]\", \"phoneNo\": \"9999999999\"}, \"skusDetail\": {\"skus\": [{\"skuId\": \"SKU1\", \"skuAmount\": \"100.00\", \"quantity\": \"1\", \"offerKeys\": [\"OFFER_KEY_1\"], \"autoApply\": false}]}}",
CURLOPT_HTTPHEADER => ["Content-Type: application/json", "Authorization: Bearer d4e5f6a7b8c90123456789abcdef0123456789abcdef0123456789abcdef0123"],
CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($curl);
curl_close($curl);const response = await fetch("https://test-partnerapilayer.payu.in/apilayer/partner/validateOffer", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer d4e5f6a7b8c90123456789abcdef0123456789abcdef0123456789abcdef0123"
},
body: JSON.stringify({
"merchant_id": 8739528,
"reseller_id": "11ed-933c-ece48d50-a41d-023f883eb17c",
"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"amount": "1000.00",
"autoApply": false,
"merchantNceParamActive": false,
"offerKeys": [
"OFFER_KEY_1"
],
"paymentId": 403993715521855092,
"paymentDetail": {
"category": "creditcard",
"paymentCode": "CC",
"cardNumber": 411111,
"cardHash": "CARD_HASH",
"cardToken": "CARD_TOKEN",
"cardTokenType": 0,
"cardMask": 1111,
"vpa": "customer@upi"
},
"userDetail": {
"userToken": "USER_TOKEN",
"email": "[email protected]",
"phoneNo": "9999999999"
},
"skusDetail": {
"skus": [
{
"skuId": "SKU1",
"skuAmount": "100.00",
"quantity": "1",
"offerKeys": [
"OFFER_KEY_1"
],
"autoApply": false
}
]
}
})
});
console.log(await response.text());using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://test-partnerapilayer.payu.in/apilayer/partner/validateOffer");
request.Headers.TryAddWithoutValidation("Authorization", "Bearer d4e5f6a7b8c90123456789abcdef0123456789abcdef0123456789abcdef0123");
request.Content = new StringContent("{\"merchant_id\": 8739528, \"reseller_id\": \"11ed-933c-ece48d50-a41d-023f883eb17c\", \"hash\": \"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\", \"amount\": \"1000.00\", \"autoApply\": false, \"merchantNceParamActive\": false, \"offerKeys\": [\"OFFER_KEY_1\"], \"paymentId\": 403993715521855092, \"paymentDetail\": {\"category\": \"creditcard\", \"paymentCode\": \"CC\", \"cardNumber\": 411111, \"cardHash\": \"CARD_HASH\", \"cardToken\": \"CARD_TOKEN\", \"cardTokenType\": 0, \"cardMask\": 1111, \"vpa\": \"customer@upi\"}, \"userDetail\": {\"userToken\": \"USER_TOKEN\", \"email\": \"[email protected]\", \"phoneNo\": \"9999999999\"}, \"skusDetail\": {\"skus\": [{\"skuId\": \"SKU1\", \"skuAmount\": \"100.00\", \"quantity\": \"1\", \"offerKeys\": [\"OFFER_KEY_1\"], \"autoApply\": false}]}}", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());require "net/http"
require "json"
uri = URI("https://test-partnerapilayer.payu.in/apilayer/partner/validateOffer")
request = Net::HTTP::Post.new(uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer d4e5f6a7b8c90123456789abcdef0123456789abcdef0123456789abcdef0123"
request.body = {"merchant_id": 8739528, "reseller_id": "11ed-933c-ece48d50-a41d-023f883eb17c", "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "amount": "1000.00", "autoApply": false, "merchantNceParamActive": false, "offerKeys": ["OFFER_KEY_1"], "paymentId": 403993715521855092, "paymentDetail": {"category": "creditcard", "paymentCode": "CC", "cardNumber": 411111, "cardHash": "CARD_HASH", "cardToken": "CARD_TOKEN", "cardTokenType": 0, "cardMask": 1111, "vpa": "customer@upi"}, "userDetail": {"userToken": "USER_TOKEN", "email": "[email protected]", "phoneNo": "9999999999"}, "skusDetail": {"skus": [{"skuId": "SKU1", "skuAmount": "100.00", "quantity": "1", "offerKeys": ["OFFER_KEY_1"], "autoApply": false}]}}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
puts response.body
Mandatory ParametersParameters marked with * are mandatory.
| Parameter | Description |
|---|---|
Content-Type* | string Send the body as application/json. |
Authorization* | string Partner access token. Send as Authorization Bearer token. |
merchant_id* | integer Merchant id. |
reseller_id* | string Reseller id. |
hash* | string Hash. |
amount | string Amount. |
autoApply | boolean AutoApply. |
merchantNceParamActive | boolean MerchantNceParamActive. |
offerKeys | array of string OfferKeys. |
paymentId | integer PaymentId. |
paymentDetail* | JSON PaymentDetail. Parameter descriptions are explained in the paymentDetail Object Parameters section. |
userDetail* | JSON UserDetail. Parameter descriptions are explained in the userDetail Object Parameters section. |
skusDetail | JSON SkusDetail. Parameter descriptions are explained in the skusDetail Object Parameters section. |
paymentDetail Object
paymentDetail Object| Parameter | Description |
|---|---|
category* | string Category. |
paymentCode | string PaymentCode. |
cardNumber | integer CardNumber. |
cardHash | string CardHash. |
cardToken | string CardToken. |
cardTokenType | integer CardTokenType. |
cardMask | integer CardMask. |
vpa | string Vpa. |
userDetail Object
userDetail Object| Parameter | Description |
|---|---|
userToken* | string UserToken. |
email | string Email. |
phoneNo | string PhoneNo. |
skusDetail Object
skusDetail Object| Parameter | Description |
|---|---|
skus | array of objects SkusDetail.skus. Parameter descriptions are explained in the skus Object Parameters section. |
skusDetail.skus Object
skusDetail.skus Object| Parameter | Description |
|---|---|
skuId* | string SkuId. |
skuAmount | string SkuAmount. |
quantity | string Quantity. |
offerKeys | array of string SkusDetail.skus[].offerKeys. |
autoApply | boolean AutoApply. |
Sample Response
{
"code": "200",
"message": "Offer Validated Successfully",
"status": 1,
"result": {
"flagToFail": false,
"paymentId": 11111135,
"clientId": 42693,
"mid": 180012,
"amount": 300,
"downPaymentAmount": null,
"emiAmount": null,
"paymentCode": "CC",
"category": "CREDITCARD",
"isValid": true,
"offerDiscount": {
"offerKey": "TestOffer@fY6HdoP7da8L",
"offerType": "INSTANT",
"discount": 100.00,
"discountedAmount": 200.00,
"discountType": "ABSOLUTE"
}
}
}| Parameter | Description |
|---|---|
code | Response code. The sample value is 200. |
message | Offer Validated Successfully. |
status | 1 when the offer is valid. |
result | Validation result. Parameter descriptions are explained in the result Object Parameters section. |
result Object Parameters
| Parameter | Description |
|---|---|
flagToFail | Whether the offers service marked the validation to fail. The sample value is false. |
paymentId | Payment id. The sample value is 11111135. |
clientId | Client id. The sample value is 42693. |
mid | Merchant id. The sample value is 180012. |
amount | Transaction amount. The sample value is 300. |
downPaymentAmount | Down payment amount. Null in this sample. |
emiAmount | EMI amount. Null in this sample. |
paymentCode | Payment code. The sample value is CC. |
category | Payment category. The sample value is CREDITCARD. |
isValid | Whether the offer is valid. The sample value is true. |
offerDiscount | Applied discount. Parameter descriptions are explained in the offerDiscount Object Parameters section. |
offerDiscount Object Parameters
| Parameter | Description |
|---|---|
offerKey | Offer key. The sample value is TestOffer@fY6HdoP7da8L. |
offerType | Offer type. The sample value is INSTANT. |
discount | Discount amount. The sample value is 100.00. |
discountedAmount | Amount after the discount. The sample value is 200.00. |
discountType | Discount type. The sample value is ABSOLUTE. |
Errors
Below are the failure scenarios.
paymentDetail is mandatory
{
"errors": [
"paymentDetail is mandatory"
]
}Reason: This error occurs when paymentDetail is not included in the request.
Recommended Fix: Include the paymentDetail object in the request and retry.
Invalid Auth token
{
"error": "Invalid Auth token"
}Reason: This error occurs when the auth token is missing or invalid.
Recommended Fix: Generate a new auth token and send it in the Authorization header.
