Fetch available payment offers for a merchant.
Use this endpoint to fetch payment offers for a merchant.
Method
POST
Endpoint
/partner/fetchOffer
Environment
| Environment | URL |
|---|---|
| Test Environment | https://test-partnerapilayer.payu.in/apilayer/partner/fetchOffer |
| Production Environment | https://api.payu.in/partner/fetchOffer |
Sample Request
curl -X POST https://test-partnerapilayer.payu.in/apilayer/partner/fetchOffer \
-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",
"offerKeys": [
"OFFER_KEY_1"
],
"paymentId": 403993715521855092,
"userToken": "USER_TOKEN",
"skusDetail": [
{
"skuId": "SKU1",
"skuAmount": "100.00",
"quantity": "1",
"offerKeys": [
"OFFER_KEY_1"
]
}
]
}'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\", \"offerKeys\": [\"OFFER_KEY_1\"], \"paymentId\": 403993715521855092, \"userToken\": \"USER_TOKEN\", \"skusDetail\": [{\"skuId\": \"SKU1\", \"skuAmount\": \"100.00\", \"quantity\": \"1\", \"offerKeys\": [\"OFFER_KEY_1\"]}]}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://test-partnerapilayer.payu.in/apilayer/partner/fetchOffer"))
.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/fetchOffer"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer d4e5f6a7b8c90123456789abcdef0123456789abcdef0123456789abcdef0123"
}
payload = {
"merchant_id": 8739528,
"reseller_id": "11ed-933c-ece48d50-a41d-023f883eb17c",
"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"amount": "1000.00",
"offerKeys": [
"OFFER_KEY_1"
],
"paymentId": 403993715521855092,
"userToken": "USER_TOKEN",
"skusDetail": [
{
"skuId": "SKU1",
"skuAmount": "100.00",
"quantity": "1",
"offerKeys": [
"OFFER_KEY_1"
]
}
]
}
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/fetchOffer",
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"merchant_id\": 8739528, \"reseller_id\": \"11ed-933c-ece48d50-a41d-023f883eb17c\", \"hash\": \"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\", \"amount\": \"1000.00\", \"offerKeys\": [\"OFFER_KEY_1\"], \"paymentId\": 403993715521855092, \"userToken\": \"USER_TOKEN\", \"skusDetail\": [{\"skuId\": \"SKU1\", \"skuAmount\": \"100.00\", \"quantity\": \"1\", \"offerKeys\": [\"OFFER_KEY_1\"]}]}",
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/fetchOffer", {
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",
"offerKeys": [
"OFFER_KEY_1"
],
"paymentId": 403993715521855092,
"userToken": "USER_TOKEN",
"skusDetail": [
{
"skuId": "SKU1",
"skuAmount": "100.00",
"quantity": "1",
"offerKeys": [
"OFFER_KEY_1"
]
}
]
})
});
console.log(await response.text());using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://test-partnerapilayer.payu.in/apilayer/partner/fetchOffer");
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\", \"offerKeys\": [\"OFFER_KEY_1\"], \"paymentId\": 403993715521855092, \"userToken\": \"USER_TOKEN\", \"skusDetail\": [{\"skuId\": \"SKU1\", \"skuAmount\": \"100.00\", \"quantity\": \"1\", \"offerKeys\": [\"OFFER_KEY_1\"]}]}", 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/fetchOffer")
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", "offerKeys": ["OFFER_KEY_1"], "paymentId": 403993715521855092, "userToken": "USER_TOKEN", "skusDetail": [{"skuId": "SKU1", "skuAmount": "100.00", "quantity": "1", "offerKeys": ["OFFER_KEY_1"]}]}.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. Hash input in PartnerUtils.getWhatsappOfferRequestHashSequence is merchant_id, then the client secret is appended (`merchant_id |
amount | string Amount. |
offerKeys | array of string OfferKeys. |
paymentId | integer PaymentId. |
userToken | string UserToken. |
skusDetail | array of objects SkusDetail. Parameter descriptions are explained in the skusDetail Object Parameters section. |
skusDetail Object
skusDetail Object| Parameter | Description |
|---|---|
skuId* | string SkuId. |
skuAmount | string SkuAmount. |
quantity | string Quantity. |
offerKeys | array of string SkusDetail[].offerKeys. |
Sample Response
{
"code": "200",
"message": "Offer Retrieved Successfully",
"status": 1,
"result": {
"failureReason": null,
"clientId": 42693,
"mid": 180012,
"amount": 300,
"couponsAvailable": true,
"isUserPersonalizedOffersAvailable": true,
"offers": [
{
"offerKey": "Test@A0RwlqkXSPkK",
"type": "MERCHANT",
"title": "Test",
"description": "Test",
"offerType": "INSTANT",
"minTxnAmount": 100.00,
"maxTxnAmount": 1000.00,
"validFrom": "2024-10-14 00:00:00",
"validTo": "2024-10-15 23:59:59",
"discountDetail": {
"discountType": "ABSOLUTE",
"discountPercentage": null,
"discount": 100.00,
"discountedAmount": 200.00,
"maxDiscount": 100.00
}
}
],
"skusDetail": null,
"flagToFail": false,
"isSkuOffer": false
},
"traceId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}| Parameter | Description |
|---|---|
code | Response code. The sample value is 200. |
message | Offer Retrieved Successfully. |
status | 1 when offers are retrieved. |
result | Object that includes the offer list. Parameter descriptions are explained in the result Object Parameters section. |
traceId | Trace id for the offers response. |
result Object Parameters
| Parameter | Description |
|---|---|
failureReason | Failure reason. Null on success. |
clientId | Client id. The sample value is 42693. |
mid | Merchant id. The sample value is 180012. |
amount | Transaction amount used to fetch offers. The sample value is 300. |
couponsAvailable | Whether coupons are available. The sample value is true. |
isUserPersonalizedOffersAvailable | Whether personalized offers are available. The sample value is true. |
offers | List of offers. Each item is explained in the offers Object Parameters section. |
skusDetail | SKU offer detail. Null in this sample. |
flagToFail | Whether the offers service marked the fetch to fail. The sample value is false. |
isSkuOffer | Whether the response is a SKU offer. The sample value is false. |
offers Object Parameters
| Parameter | Description |
|---|---|
offerKey | Offer key. The sample value is Test@A0RwlqkXSPkK. |
type | Offer owner type. The sample value is MERCHANT. |
title | Offer title. |
description | Offer description. |
offerType | Offer type. The sample value is INSTANT. |
minTxnAmount | Minimum transaction amount for the offer. The sample value is 100.00. |
maxTxnAmount | Maximum transaction amount for the offer. The sample value is 1000.00. |
validFrom | Offer start time. |
validTo | Offer end time. |
discountDetail | Discount for the offer. Parameter descriptions are explained in the discountDetail Object Parameters section. |
discountDetail Object Parameters
| Parameter | Description |
|---|---|
discountType | Discount type. The sample value is ABSOLUTE. |
discountPercentage | Discount percentage. Null for an absolute discount. |
discount | Discount amount. The sample value is 100.00. |
discountedAmount | Amount after the discount. The sample value is 200.00. |
maxDiscount | Maximum discount. The sample value is 100.00. |
Errors
Below are the failure scenarios.
merchant_id is mandatory
{
"errors": [
"merchant_id is mandatory"
]
}Reason: This error occurs when merchant_id is not included in the request.
Recommended Fix: Include the merchant_id parameter 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.
