curl --request POST \
--url https://sandbox.cashfree.com/pg/links \
--header 'Content-Type: application/json' \
--header 'x-api-version: <x-api-version>' \
--header 'x-client-id: <api-key>' \
--header 'x-client-secret: <api-key>' \
--data '
{
"link_amount": 100,
"link_currency": "INR",
"link_minimum_partial_amount": 20,
"link_id": "my_link_id",
"link_partial_payments": true,
"customer_details": {
"customer_name": "John Doe",
"customer_phone": "9999999999",
"customer_email": "john@cashfree.com"
},
"link_expiry_time": "2021-10-14T15:04:05+05:30",
"link_purpose": "Payment for PlayStation 11",
"link_notify": {
"title": "link_notify",
"type": "object",
"description": "Payment link Notify Object for SMS and Email",
"example": {
"send_sms": false,
"send_email": true
},
"properties": {
"send_sms": {
"type": "boolean",
"description": "If \"true\", Cashfree will send sms on customer_phone"
},
"send_email": {
"type": "boolean",
"description": "If \"true\", Cashfree will send email on customer_email"
}
}
},
"link_auto_reminders": true,
"link_notes": {
"title": "link_notes",
"type": "object",
"description": "Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs",
"example": {
"key_1": "value_1",
"key_2": "value_2"
},
"additionalProperties": {
"type": "string"
}
},
"link_meta": {
"title": "link_meta",
"description": "Payment link meta information object",
"type": "object",
"example": {
"notify_url": "https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net",
"upi_intent": false,
"return_url": "https://b8af79f41056.eu.ngrok.io"
},
"properties": {
"notify_url": {
"type": "string",
"description": "Notification URL for server-server communication. It should be an https URL."
},
"upi_intent": {
"type": "boolean",
"description": "If \"true\", link will directly open UPI Intent flow on mobile, and normal link flow elsewhere"
},
"return_url": {
"type": "string",
"description": "The URL to which user will be redirected to after the payment is done on the link. Maximum length: 250."
},
"payment_methods": {
"type": "string",
"description": "Allowed payment modes for this link. Pass comma-separated values among following options - \"cc\", \"dc\", \"ccc\", \"ppc\", \"nb\", \"upi\", \"paypal\", \"app\". Leave it blank to show all available payment methods"
}
}
}
}
'import requests
url = "https://sandbox.cashfree.com/pg/links"
payload = {
"link_amount": 100,
"link_currency": "INR",
"link_minimum_partial_amount": 20,
"link_id": "my_link_id",
"link_partial_payments": True,
"customer_details": {
"customer_name": "John Doe",
"customer_phone": "9999999999",
"customer_email": "john@cashfree.com"
},
"link_expiry_time": "2021-10-14T15:04:05+05:30",
"link_purpose": "Payment for PlayStation 11",
"link_notify": {
"title": "link_notify",
"type": "object",
"description": "Payment link Notify Object for SMS and Email",
"example": {
"send_sms": False,
"send_email": True
},
"properties": {
"send_sms": {
"type": "boolean",
"description": "If \"true\", Cashfree will send sms on customer_phone"
},
"send_email": {
"type": "boolean",
"description": "If \"true\", Cashfree will send email on customer_email"
}
}
},
"link_auto_reminders": True,
"link_notes": {
"title": "link_notes",
"type": "object",
"description": "Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs",
"example": {
"key_1": "value_1",
"key_2": "value_2"
},
"additionalProperties": { "type": "string" }
},
"link_meta": {
"title": "link_meta",
"description": "Payment link meta information object",
"type": "object",
"example": {
"notify_url": "https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net",
"upi_intent": False,
"return_url": "https://b8af79f41056.eu.ngrok.io"
},
"properties": {
"notify_url": {
"type": "string",
"description": "Notification URL for server-server communication. It should be an https URL."
},
"upi_intent": {
"type": "boolean",
"description": "If \"true\", link will directly open UPI Intent flow on mobile, and normal link flow elsewhere"
},
"return_url": {
"type": "string",
"description": "The URL to which user will be redirected to after the payment is done on the link. Maximum length: 250."
},
"payment_methods": {
"type": "string",
"description": "Allowed payment modes for this link. Pass comma-separated values among following options - \"cc\", \"dc\", \"ccc\", \"ppc\", \"nb\", \"upi\", \"paypal\", \"app\". Leave it blank to show all available payment methods"
}
}
}
}
headers = {
"x-api-version": "<x-api-version>",
"x-client-id": "<api-key>",
"x-client-secret": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-api-version': '<x-api-version>',
'x-client-id': '<api-key>',
'x-client-secret': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
link_amount: 100,
link_currency: 'INR',
link_minimum_partial_amount: 20,
link_id: 'my_link_id',
link_partial_payments: true,
customer_details: {
customer_name: 'John Doe',
customer_phone: '9999999999',
customer_email: 'john@cashfree.com'
},
link_expiry_time: '2021-10-14T15:04:05+05:30',
link_purpose: 'Payment for PlayStation 11',
link_notify: {
title: 'link_notify',
type: 'object',
description: 'Payment link Notify Object for SMS and Email',
example: {send_sms: false, send_email: true},
properties: {
send_sms: {
type: 'boolean',
description: 'If "true", Cashfree will send sms on customer_phone'
},
send_email: {
type: 'boolean',
description: 'If "true", Cashfree will send email on customer_email'
}
}
},
link_auto_reminders: true,
link_notes: {
title: 'link_notes',
type: 'object',
description: 'Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs',
example: {key_1: 'value_1', key_2: 'value_2'},
additionalProperties: {type: 'string'}
},
link_meta: {
title: 'link_meta',
description: 'Payment link meta information object',
type: 'object',
example: {
notify_url: 'https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net',
upi_intent: false,
return_url: 'https://b8af79f41056.eu.ngrok.io'
},
properties: {
notify_url: {
type: 'string',
description: 'Notification URL for server-server communication. It should be an https URL.'
},
upi_intent: {
type: 'boolean',
description: 'If "true", link will directly open UPI Intent flow on mobile, and normal link flow elsewhere'
},
return_url: {
type: 'string',
description: 'The URL to which user will be redirected to after the payment is done on the link. Maximum length: 250.'
},
payment_methods: {
type: 'string',
description: 'Allowed payment modes for this link. Pass comma-separated values among following options - "cc", "dc", "ccc", "ppc", "nb", "upi", "paypal", "app". Leave it blank to show all available payment methods'
}
}
}
})
};
fetch('https://sandbox.cashfree.com/pg/links', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.cashfree.com/pg/links",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'link_amount' => 100,
'link_currency' => 'INR',
'link_minimum_partial_amount' => 20,
'link_id' => 'my_link_id',
'link_partial_payments' => true,
'customer_details' => [
'customer_name' => 'John Doe',
'customer_phone' => '9999999999',
'customer_email' => 'john@cashfree.com'
],
'link_expiry_time' => '2021-10-14T15:04:05+05:30',
'link_purpose' => 'Payment for PlayStation 11',
'link_notify' => [
'title' => 'link_notify',
'type' => 'object',
'description' => 'Payment link Notify Object for SMS and Email',
'example' => [
'send_sms' => false,
'send_email' => true
],
'properties' => [
'send_sms' => [
'type' => 'boolean',
'description' => 'If "true", Cashfree will send sms on customer_phone'
],
'send_email' => [
'type' => 'boolean',
'description' => 'If "true", Cashfree will send email on customer_email'
]
]
],
'link_auto_reminders' => true,
'link_notes' => [
'title' => 'link_notes',
'type' => 'object',
'description' => 'Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs',
'example' => [
'key_1' => 'value_1',
'key_2' => 'value_2'
],
'additionalProperties' => [
'type' => 'string'
]
],
'link_meta' => [
'title' => 'link_meta',
'description' => 'Payment link meta information object',
'type' => 'object',
'example' => [
'notify_url' => 'https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net',
'upi_intent' => false,
'return_url' => 'https://b8af79f41056.eu.ngrok.io'
],
'properties' => [
'notify_url' => [
'type' => 'string',
'description' => 'Notification URL for server-server communication. It should be an https URL.'
],
'upi_intent' => [
'type' => 'boolean',
'description' => 'If "true", link will directly open UPI Intent flow on mobile, and normal link flow elsewhere'
],
'return_url' => [
'type' => 'string',
'description' => 'The URL to which user will be redirected to after the payment is done on the link. Maximum length: 250.'
],
'payment_methods' => [
'type' => 'string',
'description' => 'Allowed payment modes for this link. Pass comma-separated values among following options - "cc", "dc", "ccc", "ppc", "nb", "upi", "paypal", "app". Leave it blank to show all available payment methods'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-version: <x-api-version>",
"x-client-id: <api-key>",
"x-client-secret: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.cashfree.com/pg/links"
payload := strings.NewReader("{\n \"link_amount\": 100,\n \"link_currency\": \"INR\",\n \"link_minimum_partial_amount\": 20,\n \"link_id\": \"my_link_id\",\n \"link_partial_payments\": true,\n \"customer_details\": {\n \"customer_name\": \"John Doe\",\n \"customer_phone\": \"9999999999\",\n \"customer_email\": \"john@cashfree.com\"\n },\n \"link_expiry_time\": \"2021-10-14T15:04:05+05:30\",\n \"link_purpose\": \"Payment for PlayStation 11\",\n \"link_notify\": {\n \"title\": \"link_notify\",\n \"type\": \"object\",\n \"description\": \"Payment link Notify Object for SMS and Email\",\n \"example\": {\n \"send_sms\": false,\n \"send_email\": true\n },\n \"properties\": {\n \"send_sms\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", Cashfree will send sms on customer_phone\"\n },\n \"send_email\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", Cashfree will send email on customer_email\"\n }\n }\n },\n \"link_auto_reminders\": true,\n \"link_notes\": {\n \"title\": \"link_notes\",\n \"type\": \"object\",\n \"description\": \"Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs\",\n \"example\": {\n \"key_1\": \"value_1\",\n \"key_2\": \"value_2\"\n },\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"link_meta\": {\n \"title\": \"link_meta\",\n \"description\": \"Payment link meta information object\",\n \"type\": \"object\",\n \"example\": {\n \"notify_url\": \"https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net\",\n \"upi_intent\": false,\n \"return_url\": \"https://b8af79f41056.eu.ngrok.io\"\n },\n \"properties\": {\n \"notify_url\": {\n \"type\": \"string\",\n \"description\": \"Notification URL for server-server communication. It should be an https URL.\"\n },\n \"upi_intent\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", link will directly open UPI Intent flow on mobile, and normal link flow elsewhere\"\n },\n \"return_url\": {\n \"type\": \"string\",\n \"description\": \"The URL to which user will be redirected to after the payment is done on the link. Maximum length: 250.\"\n },\n \"payment_methods\": {\n \"type\": \"string\",\n \"description\": \"Allowed payment modes for this link. Pass comma-separated values among following options - \\\"cc\\\", \\\"dc\\\", \\\"ccc\\\", \\\"ppc\\\", \\\"nb\\\", \\\"upi\\\", \\\"paypal\\\", \\\"app\\\". Leave it blank to show all available payment methods\"\n }\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-version", "<x-api-version>")
req.Header.Add("x-client-id", "<api-key>")
req.Header.Add("x-client-secret", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox.cashfree.com/pg/links")
.header("x-api-version", "<x-api-version>")
.header("x-client-id", "<api-key>")
.header("x-client-secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"link_amount\": 100,\n \"link_currency\": \"INR\",\n \"link_minimum_partial_amount\": 20,\n \"link_id\": \"my_link_id\",\n \"link_partial_payments\": true,\n \"customer_details\": {\n \"customer_name\": \"John Doe\",\n \"customer_phone\": \"9999999999\",\n \"customer_email\": \"john@cashfree.com\"\n },\n \"link_expiry_time\": \"2021-10-14T15:04:05+05:30\",\n \"link_purpose\": \"Payment for PlayStation 11\",\n \"link_notify\": {\n \"title\": \"link_notify\",\n \"type\": \"object\",\n \"description\": \"Payment link Notify Object for SMS and Email\",\n \"example\": {\n \"send_sms\": false,\n \"send_email\": true\n },\n \"properties\": {\n \"send_sms\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", Cashfree will send sms on customer_phone\"\n },\n \"send_email\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", Cashfree will send email on customer_email\"\n }\n }\n },\n \"link_auto_reminders\": true,\n \"link_notes\": {\n \"title\": \"link_notes\",\n \"type\": \"object\",\n \"description\": \"Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs\",\n \"example\": {\n \"key_1\": \"value_1\",\n \"key_2\": \"value_2\"\n },\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"link_meta\": {\n \"title\": \"link_meta\",\n \"description\": \"Payment link meta information object\",\n \"type\": \"object\",\n \"example\": {\n \"notify_url\": \"https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net\",\n \"upi_intent\": false,\n \"return_url\": \"https://b8af79f41056.eu.ngrok.io\"\n },\n \"properties\": {\n \"notify_url\": {\n \"type\": \"string\",\n \"description\": \"Notification URL for server-server communication. It should be an https URL.\"\n },\n \"upi_intent\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", link will directly open UPI Intent flow on mobile, and normal link flow elsewhere\"\n },\n \"return_url\": {\n \"type\": \"string\",\n \"description\": \"The URL to which user will be redirected to after the payment is done on the link. Maximum length: 250.\"\n },\n \"payment_methods\": {\n \"type\": \"string\",\n \"description\": \"Allowed payment modes for this link. Pass comma-separated values among following options - \\\"cc\\\", \\\"dc\\\", \\\"ccc\\\", \\\"ppc\\\", \\\"nb\\\", \\\"upi\\\", \\\"paypal\\\", \\\"app\\\". Leave it blank to show all available payment methods\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.cashfree.com/pg/links")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-version"] = '<x-api-version>'
request["x-client-id"] = '<api-key>'
request["x-client-secret"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"link_amount\": 100,\n \"link_currency\": \"INR\",\n \"link_minimum_partial_amount\": 20,\n \"link_id\": \"my_link_id\",\n \"link_partial_payments\": true,\n \"customer_details\": {\n \"customer_name\": \"John Doe\",\n \"customer_phone\": \"9999999999\",\n \"customer_email\": \"john@cashfree.com\"\n },\n \"link_expiry_time\": \"2021-10-14T15:04:05+05:30\",\n \"link_purpose\": \"Payment for PlayStation 11\",\n \"link_notify\": {\n \"title\": \"link_notify\",\n \"type\": \"object\",\n \"description\": \"Payment link Notify Object for SMS and Email\",\n \"example\": {\n \"send_sms\": false,\n \"send_email\": true\n },\n \"properties\": {\n \"send_sms\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", Cashfree will send sms on customer_phone\"\n },\n \"send_email\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", Cashfree will send email on customer_email\"\n }\n }\n },\n \"link_auto_reminders\": true,\n \"link_notes\": {\n \"title\": \"link_notes\",\n \"type\": \"object\",\n \"description\": \"Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs\",\n \"example\": {\n \"key_1\": \"value_1\",\n \"key_2\": \"value_2\"\n },\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"link_meta\": {\n \"title\": \"link_meta\",\n \"description\": \"Payment link meta information object\",\n \"type\": \"object\",\n \"example\": {\n \"notify_url\": \"https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net\",\n \"upi_intent\": false,\n \"return_url\": \"https://b8af79f41056.eu.ngrok.io\"\n },\n \"properties\": {\n \"notify_url\": {\n \"type\": \"string\",\n \"description\": \"Notification URL for server-server communication. It should be an https URL.\"\n },\n \"upi_intent\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", link will directly open UPI Intent flow on mobile, and normal link flow elsewhere\"\n },\n \"return_url\": {\n \"type\": \"string\",\n \"description\": \"The URL to which user will be redirected to after the payment is done on the link. Maximum length: 250.\"\n },\n \"payment_methods\": {\n \"type\": \"string\",\n \"description\": \"Allowed payment modes for this link. Pass comma-separated values among following options - \\\"cc\\\", \\\"dc\\\", \\\"ccc\\\", \\\"ppc\\\", \\\"nb\\\", \\\"upi\\\", \\\"paypal\\\", \\\"app\\\". Leave it blank to show all available payment methods\"\n }\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"cf_link_id": 1996567,
"link_id": "my_link_id",
"link_status": "ACTIVE",
"link_currency": "INR",
"link_amount": 100,
"link_amount_paid": 0,
"link_partial_payments": true,
"link_minimum_partial_amount": 20,
"link_purpose": "Payment for PlayStation 11",
"link_created_at": "2021-09-30T17:05:01+05:30",
"customer_details": {
"customer_name": "John Doe",
"customer_phone": "9999999999",
"customer_email": "john@example.com"
},
"link_meta": {
"title": "link_meta",
"type": "object",
"description": "Payment link meta information object.",
"example": {
"key_1": "value_1",
"key_2": "value_2"
},
"additionalProperties": {
"type": "string"
}
},
"link_url": "https://payments-test.cashfree.com/links/o1tf1nvcvjhg",
"link_expiry_time": "2021-10-14T15:04:05+05:30",
"link_notes": {
"title": "link_notes",
"type": "object",
"description": "Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs",
"example": {
"key_1": "value_1",
"key_2": "value_2"
},
"additionalProperties": {
"type": "string"
}
},
"link_auto_reminders": true,
"link_notify": {
"title": "link_notify",
"type": "object",
"description": "Payment link Notify Object for SMS and Email",
"example": {
"send_sms": false,
"send_email": true
},
"properties": {
"send_sms": {
"type": "boolean",
"description": "If \"true\", Cashfree will send sms on customer_phone"
},
"send_email": {
"type": "boolean",
"description": "If \"true\", Cashfree will send email on customer_email"
}
}
}
}{
"message": "bad URL, please check API documentation",
"code": "request_failed",
"type": "invalid_request_error"
}{
"message": "authentication Failed",
"code": "request_failed",
"type": "authentication_error"
}{
"message": "something is not found",
"code": "somethind_not_found",
"type": "invalid_request_error"
}{
"message": "order with same id is already present",
"code": "order_already_exists",
"type": "invalid_request_error"
}{
"message": "something is not found",
"code": "request_invalid",
"type": "idempotency_error"
}{
"message": "Too many requests from IP. Check headers",
"code": "request_failed",
"type": "rate_limit_error"
}{
"message": "internal Server Error",
"code": "internal_error",
"type": "api_error"
}Create Payment Link
Use this API to create a new payment link. The created payment link url will be available in the API response parameter link_url.
curl --request POST \
--url https://sandbox.cashfree.com/pg/links \
--header 'Content-Type: application/json' \
--header 'x-api-version: <x-api-version>' \
--header 'x-client-id: <api-key>' \
--header 'x-client-secret: <api-key>' \
--data '
{
"link_amount": 100,
"link_currency": "INR",
"link_minimum_partial_amount": 20,
"link_id": "my_link_id",
"link_partial_payments": true,
"customer_details": {
"customer_name": "John Doe",
"customer_phone": "9999999999",
"customer_email": "john@cashfree.com"
},
"link_expiry_time": "2021-10-14T15:04:05+05:30",
"link_purpose": "Payment for PlayStation 11",
"link_notify": {
"title": "link_notify",
"type": "object",
"description": "Payment link Notify Object for SMS and Email",
"example": {
"send_sms": false,
"send_email": true
},
"properties": {
"send_sms": {
"type": "boolean",
"description": "If \"true\", Cashfree will send sms on customer_phone"
},
"send_email": {
"type": "boolean",
"description": "If \"true\", Cashfree will send email on customer_email"
}
}
},
"link_auto_reminders": true,
"link_notes": {
"title": "link_notes",
"type": "object",
"description": "Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs",
"example": {
"key_1": "value_1",
"key_2": "value_2"
},
"additionalProperties": {
"type": "string"
}
},
"link_meta": {
"title": "link_meta",
"description": "Payment link meta information object",
"type": "object",
"example": {
"notify_url": "https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net",
"upi_intent": false,
"return_url": "https://b8af79f41056.eu.ngrok.io"
},
"properties": {
"notify_url": {
"type": "string",
"description": "Notification URL for server-server communication. It should be an https URL."
},
"upi_intent": {
"type": "boolean",
"description": "If \"true\", link will directly open UPI Intent flow on mobile, and normal link flow elsewhere"
},
"return_url": {
"type": "string",
"description": "The URL to which user will be redirected to after the payment is done on the link. Maximum length: 250."
},
"payment_methods": {
"type": "string",
"description": "Allowed payment modes for this link. Pass comma-separated values among following options - \"cc\", \"dc\", \"ccc\", \"ppc\", \"nb\", \"upi\", \"paypal\", \"app\". Leave it blank to show all available payment methods"
}
}
}
}
'import requests
url = "https://sandbox.cashfree.com/pg/links"
payload = {
"link_amount": 100,
"link_currency": "INR",
"link_minimum_partial_amount": 20,
"link_id": "my_link_id",
"link_partial_payments": True,
"customer_details": {
"customer_name": "John Doe",
"customer_phone": "9999999999",
"customer_email": "john@cashfree.com"
},
"link_expiry_time": "2021-10-14T15:04:05+05:30",
"link_purpose": "Payment for PlayStation 11",
"link_notify": {
"title": "link_notify",
"type": "object",
"description": "Payment link Notify Object for SMS and Email",
"example": {
"send_sms": False,
"send_email": True
},
"properties": {
"send_sms": {
"type": "boolean",
"description": "If \"true\", Cashfree will send sms on customer_phone"
},
"send_email": {
"type": "boolean",
"description": "If \"true\", Cashfree will send email on customer_email"
}
}
},
"link_auto_reminders": True,
"link_notes": {
"title": "link_notes",
"type": "object",
"description": "Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs",
"example": {
"key_1": "value_1",
"key_2": "value_2"
},
"additionalProperties": { "type": "string" }
},
"link_meta": {
"title": "link_meta",
"description": "Payment link meta information object",
"type": "object",
"example": {
"notify_url": "https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net",
"upi_intent": False,
"return_url": "https://b8af79f41056.eu.ngrok.io"
},
"properties": {
"notify_url": {
"type": "string",
"description": "Notification URL for server-server communication. It should be an https URL."
},
"upi_intent": {
"type": "boolean",
"description": "If \"true\", link will directly open UPI Intent flow on mobile, and normal link flow elsewhere"
},
"return_url": {
"type": "string",
"description": "The URL to which user will be redirected to after the payment is done on the link. Maximum length: 250."
},
"payment_methods": {
"type": "string",
"description": "Allowed payment modes for this link. Pass comma-separated values among following options - \"cc\", \"dc\", \"ccc\", \"ppc\", \"nb\", \"upi\", \"paypal\", \"app\". Leave it blank to show all available payment methods"
}
}
}
}
headers = {
"x-api-version": "<x-api-version>",
"x-client-id": "<api-key>",
"x-client-secret": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-api-version': '<x-api-version>',
'x-client-id': '<api-key>',
'x-client-secret': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
link_amount: 100,
link_currency: 'INR',
link_minimum_partial_amount: 20,
link_id: 'my_link_id',
link_partial_payments: true,
customer_details: {
customer_name: 'John Doe',
customer_phone: '9999999999',
customer_email: 'john@cashfree.com'
},
link_expiry_time: '2021-10-14T15:04:05+05:30',
link_purpose: 'Payment for PlayStation 11',
link_notify: {
title: 'link_notify',
type: 'object',
description: 'Payment link Notify Object for SMS and Email',
example: {send_sms: false, send_email: true},
properties: {
send_sms: {
type: 'boolean',
description: 'If "true", Cashfree will send sms on customer_phone'
},
send_email: {
type: 'boolean',
description: 'If "true", Cashfree will send email on customer_email'
}
}
},
link_auto_reminders: true,
link_notes: {
title: 'link_notes',
type: 'object',
description: 'Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs',
example: {key_1: 'value_1', key_2: 'value_2'},
additionalProperties: {type: 'string'}
},
link_meta: {
title: 'link_meta',
description: 'Payment link meta information object',
type: 'object',
example: {
notify_url: 'https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net',
upi_intent: false,
return_url: 'https://b8af79f41056.eu.ngrok.io'
},
properties: {
notify_url: {
type: 'string',
description: 'Notification URL for server-server communication. It should be an https URL.'
},
upi_intent: {
type: 'boolean',
description: 'If "true", link will directly open UPI Intent flow on mobile, and normal link flow elsewhere'
},
return_url: {
type: 'string',
description: 'The URL to which user will be redirected to after the payment is done on the link. Maximum length: 250.'
},
payment_methods: {
type: 'string',
description: 'Allowed payment modes for this link. Pass comma-separated values among following options - "cc", "dc", "ccc", "ppc", "nb", "upi", "paypal", "app". Leave it blank to show all available payment methods'
}
}
}
})
};
fetch('https://sandbox.cashfree.com/pg/links', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.cashfree.com/pg/links",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'link_amount' => 100,
'link_currency' => 'INR',
'link_minimum_partial_amount' => 20,
'link_id' => 'my_link_id',
'link_partial_payments' => true,
'customer_details' => [
'customer_name' => 'John Doe',
'customer_phone' => '9999999999',
'customer_email' => 'john@cashfree.com'
],
'link_expiry_time' => '2021-10-14T15:04:05+05:30',
'link_purpose' => 'Payment for PlayStation 11',
'link_notify' => [
'title' => 'link_notify',
'type' => 'object',
'description' => 'Payment link Notify Object for SMS and Email',
'example' => [
'send_sms' => false,
'send_email' => true
],
'properties' => [
'send_sms' => [
'type' => 'boolean',
'description' => 'If "true", Cashfree will send sms on customer_phone'
],
'send_email' => [
'type' => 'boolean',
'description' => 'If "true", Cashfree will send email on customer_email'
]
]
],
'link_auto_reminders' => true,
'link_notes' => [
'title' => 'link_notes',
'type' => 'object',
'description' => 'Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs',
'example' => [
'key_1' => 'value_1',
'key_2' => 'value_2'
],
'additionalProperties' => [
'type' => 'string'
]
],
'link_meta' => [
'title' => 'link_meta',
'description' => 'Payment link meta information object',
'type' => 'object',
'example' => [
'notify_url' => 'https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net',
'upi_intent' => false,
'return_url' => 'https://b8af79f41056.eu.ngrok.io'
],
'properties' => [
'notify_url' => [
'type' => 'string',
'description' => 'Notification URL for server-server communication. It should be an https URL.'
],
'upi_intent' => [
'type' => 'boolean',
'description' => 'If "true", link will directly open UPI Intent flow on mobile, and normal link flow elsewhere'
],
'return_url' => [
'type' => 'string',
'description' => 'The URL to which user will be redirected to after the payment is done on the link. Maximum length: 250.'
],
'payment_methods' => [
'type' => 'string',
'description' => 'Allowed payment modes for this link. Pass comma-separated values among following options - "cc", "dc", "ccc", "ppc", "nb", "upi", "paypal", "app". Leave it blank to show all available payment methods'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-version: <x-api-version>",
"x-client-id: <api-key>",
"x-client-secret: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.cashfree.com/pg/links"
payload := strings.NewReader("{\n \"link_amount\": 100,\n \"link_currency\": \"INR\",\n \"link_minimum_partial_amount\": 20,\n \"link_id\": \"my_link_id\",\n \"link_partial_payments\": true,\n \"customer_details\": {\n \"customer_name\": \"John Doe\",\n \"customer_phone\": \"9999999999\",\n \"customer_email\": \"john@cashfree.com\"\n },\n \"link_expiry_time\": \"2021-10-14T15:04:05+05:30\",\n \"link_purpose\": \"Payment for PlayStation 11\",\n \"link_notify\": {\n \"title\": \"link_notify\",\n \"type\": \"object\",\n \"description\": \"Payment link Notify Object for SMS and Email\",\n \"example\": {\n \"send_sms\": false,\n \"send_email\": true\n },\n \"properties\": {\n \"send_sms\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", Cashfree will send sms on customer_phone\"\n },\n \"send_email\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", Cashfree will send email on customer_email\"\n }\n }\n },\n \"link_auto_reminders\": true,\n \"link_notes\": {\n \"title\": \"link_notes\",\n \"type\": \"object\",\n \"description\": \"Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs\",\n \"example\": {\n \"key_1\": \"value_1\",\n \"key_2\": \"value_2\"\n },\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"link_meta\": {\n \"title\": \"link_meta\",\n \"description\": \"Payment link meta information object\",\n \"type\": \"object\",\n \"example\": {\n \"notify_url\": \"https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net\",\n \"upi_intent\": false,\n \"return_url\": \"https://b8af79f41056.eu.ngrok.io\"\n },\n \"properties\": {\n \"notify_url\": {\n \"type\": \"string\",\n \"description\": \"Notification URL for server-server communication. It should be an https URL.\"\n },\n \"upi_intent\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", link will directly open UPI Intent flow on mobile, and normal link flow elsewhere\"\n },\n \"return_url\": {\n \"type\": \"string\",\n \"description\": \"The URL to which user will be redirected to after the payment is done on the link. Maximum length: 250.\"\n },\n \"payment_methods\": {\n \"type\": \"string\",\n \"description\": \"Allowed payment modes for this link. Pass comma-separated values among following options - \\\"cc\\\", \\\"dc\\\", \\\"ccc\\\", \\\"ppc\\\", \\\"nb\\\", \\\"upi\\\", \\\"paypal\\\", \\\"app\\\". Leave it blank to show all available payment methods\"\n }\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-version", "<x-api-version>")
req.Header.Add("x-client-id", "<api-key>")
req.Header.Add("x-client-secret", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox.cashfree.com/pg/links")
.header("x-api-version", "<x-api-version>")
.header("x-client-id", "<api-key>")
.header("x-client-secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"link_amount\": 100,\n \"link_currency\": \"INR\",\n \"link_minimum_partial_amount\": 20,\n \"link_id\": \"my_link_id\",\n \"link_partial_payments\": true,\n \"customer_details\": {\n \"customer_name\": \"John Doe\",\n \"customer_phone\": \"9999999999\",\n \"customer_email\": \"john@cashfree.com\"\n },\n \"link_expiry_time\": \"2021-10-14T15:04:05+05:30\",\n \"link_purpose\": \"Payment for PlayStation 11\",\n \"link_notify\": {\n \"title\": \"link_notify\",\n \"type\": \"object\",\n \"description\": \"Payment link Notify Object for SMS and Email\",\n \"example\": {\n \"send_sms\": false,\n \"send_email\": true\n },\n \"properties\": {\n \"send_sms\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", Cashfree will send sms on customer_phone\"\n },\n \"send_email\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", Cashfree will send email on customer_email\"\n }\n }\n },\n \"link_auto_reminders\": true,\n \"link_notes\": {\n \"title\": \"link_notes\",\n \"type\": \"object\",\n \"description\": \"Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs\",\n \"example\": {\n \"key_1\": \"value_1\",\n \"key_2\": \"value_2\"\n },\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"link_meta\": {\n \"title\": \"link_meta\",\n \"description\": \"Payment link meta information object\",\n \"type\": \"object\",\n \"example\": {\n \"notify_url\": \"https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net\",\n \"upi_intent\": false,\n \"return_url\": \"https://b8af79f41056.eu.ngrok.io\"\n },\n \"properties\": {\n \"notify_url\": {\n \"type\": \"string\",\n \"description\": \"Notification URL for server-server communication. It should be an https URL.\"\n },\n \"upi_intent\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", link will directly open UPI Intent flow on mobile, and normal link flow elsewhere\"\n },\n \"return_url\": {\n \"type\": \"string\",\n \"description\": \"The URL to which user will be redirected to after the payment is done on the link. Maximum length: 250.\"\n },\n \"payment_methods\": {\n \"type\": \"string\",\n \"description\": \"Allowed payment modes for this link. Pass comma-separated values among following options - \\\"cc\\\", \\\"dc\\\", \\\"ccc\\\", \\\"ppc\\\", \\\"nb\\\", \\\"upi\\\", \\\"paypal\\\", \\\"app\\\". Leave it blank to show all available payment methods\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.cashfree.com/pg/links")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-version"] = '<x-api-version>'
request["x-client-id"] = '<api-key>'
request["x-client-secret"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"link_amount\": 100,\n \"link_currency\": \"INR\",\n \"link_minimum_partial_amount\": 20,\n \"link_id\": \"my_link_id\",\n \"link_partial_payments\": true,\n \"customer_details\": {\n \"customer_name\": \"John Doe\",\n \"customer_phone\": \"9999999999\",\n \"customer_email\": \"john@cashfree.com\"\n },\n \"link_expiry_time\": \"2021-10-14T15:04:05+05:30\",\n \"link_purpose\": \"Payment for PlayStation 11\",\n \"link_notify\": {\n \"title\": \"link_notify\",\n \"type\": \"object\",\n \"description\": \"Payment link Notify Object for SMS and Email\",\n \"example\": {\n \"send_sms\": false,\n \"send_email\": true\n },\n \"properties\": {\n \"send_sms\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", Cashfree will send sms on customer_phone\"\n },\n \"send_email\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", Cashfree will send email on customer_email\"\n }\n }\n },\n \"link_auto_reminders\": true,\n \"link_notes\": {\n \"title\": \"link_notes\",\n \"type\": \"object\",\n \"description\": \"Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs\",\n \"example\": {\n \"key_1\": \"value_1\",\n \"key_2\": \"value_2\"\n },\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"link_meta\": {\n \"title\": \"link_meta\",\n \"description\": \"Payment link meta information object\",\n \"type\": \"object\",\n \"example\": {\n \"notify_url\": \"https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net\",\n \"upi_intent\": false,\n \"return_url\": \"https://b8af79f41056.eu.ngrok.io\"\n },\n \"properties\": {\n \"notify_url\": {\n \"type\": \"string\",\n \"description\": \"Notification URL for server-server communication. It should be an https URL.\"\n },\n \"upi_intent\": {\n \"type\": \"boolean\",\n \"description\": \"If \\\"true\\\", link will directly open UPI Intent flow on mobile, and normal link flow elsewhere\"\n },\n \"return_url\": {\n \"type\": \"string\",\n \"description\": \"The URL to which user will be redirected to after the payment is done on the link. Maximum length: 250.\"\n },\n \"payment_methods\": {\n \"type\": \"string\",\n \"description\": \"Allowed payment modes for this link. Pass comma-separated values among following options - \\\"cc\\\", \\\"dc\\\", \\\"ccc\\\", \\\"ppc\\\", \\\"nb\\\", \\\"upi\\\", \\\"paypal\\\", \\\"app\\\". Leave it blank to show all available payment methods\"\n }\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"cf_link_id": 1996567,
"link_id": "my_link_id",
"link_status": "ACTIVE",
"link_currency": "INR",
"link_amount": 100,
"link_amount_paid": 0,
"link_partial_payments": true,
"link_minimum_partial_amount": 20,
"link_purpose": "Payment for PlayStation 11",
"link_created_at": "2021-09-30T17:05:01+05:30",
"customer_details": {
"customer_name": "John Doe",
"customer_phone": "9999999999",
"customer_email": "john@example.com"
},
"link_meta": {
"title": "link_meta",
"type": "object",
"description": "Payment link meta information object.",
"example": {
"key_1": "value_1",
"key_2": "value_2"
},
"additionalProperties": {
"type": "string"
}
},
"link_url": "https://payments-test.cashfree.com/links/o1tf1nvcvjhg",
"link_expiry_time": "2021-10-14T15:04:05+05:30",
"link_notes": {
"title": "link_notes",
"type": "object",
"description": "Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs",
"example": {
"key_1": "value_1",
"key_2": "value_2"
},
"additionalProperties": {
"type": "string"
}
},
"link_auto_reminders": true,
"link_notify": {
"title": "link_notify",
"type": "object",
"description": "Payment link Notify Object for SMS and Email",
"example": {
"send_sms": false,
"send_email": true
},
"properties": {
"send_sms": {
"type": "boolean",
"description": "If \"true\", Cashfree will send sms on customer_phone"
},
"send_email": {
"type": "boolean",
"description": "If \"true\", Cashfree will send email on customer_email"
}
}
}
}{
"message": "bad URL, please check API documentation",
"code": "request_failed",
"type": "invalid_request_error"
}{
"message": "authentication Failed",
"code": "request_failed",
"type": "authentication_error"
}{
"message": "something is not found",
"code": "somethind_not_found",
"type": "invalid_request_error"
}{
"message": "order with same id is already present",
"code": "order_already_exists",
"type": "invalid_request_error"
}{
"message": "something is not found",
"code": "request_invalid",
"type": "idempotency_error"
}{
"message": "Too many requests from IP. Check headers",
"code": "request_failed",
"type": "rate_limit_error"
}{
"message": "internal Server Error",
"code": "internal_error",
"type": "api_error"
}Authorizations
Client app ID. You can find your app id in the Merchant Dashboard.
Client secret key. You can find your secret in the Merchant Dashboard.
Headers
API version to be used
Request id for the API call. Can be used to resolve tech issues. Communicate this in your tech related queries to cashfree
Idempotency works by saving the resulting status code and body of the first request made for any given idempotency key, regardless of whether it succeeded or failed. Subsequent requests with the same key return the same result, including 500 errors.
Currently supported on all POST calls that uses x-client-id & x-client-secret. To use enable, pass x-idempotency-key in the request header. The value of this header must be unique to each operation you are trying to do. One example can be to use the same order_id that you pass while creating orders
Body
Request Body to Create Payment Links
Request paramenters for link creation
Unique Identifier (provided by merchant) for the Link. Alphanumeric and only - and _ allowed (50 character limit). Use this for other link-related APIs.
50Amount to be collected using this link. Provide upto two decimals for paise.
Currency for the payment link. Default is INR. Fill out the Support Form to enable new currencies.
A brief description for which payment must be collected. This is shown to the customer.
500Payment link customer entity
Show child attributes
Show child attributes
{
"customer_name": "John Doe",
"customer_phone": "9999999999",
"customer_email": "john@cashfree.com"
}
If "true", customer can make partial payments for the link.
Minimum amount in first installment that needs to be paid by the customer if partial payments are enabled. This should be less than the link_amount.
Time after which the link expires. Customers will not be able to make the payment beyond the time specified here. You can provide them in a valid ISO 8601 time format. Default is 30 days.
Payment link Notify Object for SMS and Email
Show child attributes
Show child attributes
{ "send_sms": false, "send_email": true }
If "true", reminders will be sent to customers for collecting payments.
Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs
Show child attributes
Show child attributes
{ "key_1": "value_1", "key_2": "value_2" }
Payment link meta information object
Show child attributes
Show child attributes
{
"notify_url": "https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net",
"upi_intent": false,
"return_url": "https://b8af79f41056.eu.ngrok.io"
}
Response
OK
Payment link success creation response object
Payment link customer entity
Show child attributes
Show child attributes
{
"customer_name": "John Doe",
"customer_phone": "9999999999",
"customer_email": "john@cashfree.com"
}
Payment link meta information object.
Show child attributes
Show child attributes
{ "key_1": "value_1", "key_2": "value_2" }
Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs
Show child attributes
Show child attributes
{ "key_1": "value_1", "key_2": "value_2" }
Payment link Notify Object for SMS and Email
Show child attributes
Show child attributes
{ "send_sms": false, "send_email": true }
Was this page helpful?