curl --request POST \
--url https://api-sandbox.beinfi.com/products/{productID}/payment-links \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"successUrl": "<string>",
"cancelUrl": "<string>",
"productVersionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://api-sandbox.beinfi.com/products/{productID}/payment-links"
payload = {
"successUrl": "<string>",
"cancelUrl": "<string>",
"productVersionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
successUrl: '<string>',
cancelUrl: '<string>',
productVersionId: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
})
};
fetch('https://api-sandbox.beinfi.com/products/{productID}/payment-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://api-sandbox.beinfi.com/products/{productID}/payment-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([
'successUrl' => '<string>',
'cancelUrl' => '<string>',
'productVersionId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://api-sandbox.beinfi.com/products/{productID}/payment-links"
payload := strings.NewReader("{\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"productVersionId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api-sandbox.beinfi.com/products/{productID}/payment-links")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"productVersionId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.beinfi.com/products/{productID}/payment-links")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"productVersionId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"productId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"token": "<string>",
"url": "<string>",
"productVersionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"active": true,
"revokedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"successUrl": "<string>",
"cancelUrl": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"resource": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"errors": [
{
"field": "<string>",
"value": "<string>",
"constraint": "<string>",
"description": "<string>"
}
]
}Create a payment link
Creates a reusable, revocable link for this product. Use the url in the response; the link has no payer, and the customer and invoice (or subscription) are created when someone pays.
Requires a published version. Publishing a version already creates the first link; use this route for additional links, for links with successUrl / cancelUrl, or to sell an offer with productVersionId.
curl --request POST \
--url https://api-sandbox.beinfi.com/products/{productID}/payment-links \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"successUrl": "<string>",
"cancelUrl": "<string>",
"productVersionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://api-sandbox.beinfi.com/products/{productID}/payment-links"
payload = {
"successUrl": "<string>",
"cancelUrl": "<string>",
"productVersionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
successUrl: '<string>',
cancelUrl: '<string>',
productVersionId: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
})
};
fetch('https://api-sandbox.beinfi.com/products/{productID}/payment-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://api-sandbox.beinfi.com/products/{productID}/payment-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([
'successUrl' => '<string>',
'cancelUrl' => '<string>',
'productVersionId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://api-sandbox.beinfi.com/products/{productID}/payment-links"
payload := strings.NewReader("{\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"productVersionId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api-sandbox.beinfi.com/products/{productID}/payment-links")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"productVersionId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.beinfi.com/products/{productID}/payment-links")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"productVersionId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"productId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"token": "<string>",
"url": "<string>",
"productVersionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"active": true,
"revokedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"successUrl": "<string>",
"cancelUrl": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"resource": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"errors": [
{
"field": "<string>",
"value": "<string>",
"constraint": "<string>",
"description": "<string>"
}
]
}Authorizations
Your account's secret key: Authorization: Bearer sk_test_… or sk_live_…. Server-side only.
Path Parameters
Product ID.
Body
Optional. A link needs no configuration; send a body only to set where the payer goes afterwards, or to sell an offer. URLs must be absolute http(s).
Where the payer goes after paying, with ?status=success&invoice=… appended.
2048Offered to the payer as "back to the store" while the checkout is open.
2048Sells a specific published version instead of the default. This is how a promotional price reaches a buyer: the version is published with default: false, and only a link that names it can sell it. Omit it to sell the default version. Refused if the version is not a published version of this product.
Response
Link created.
A reusable, revocable payment link bound to a product. Anyone holding it can open the checkout; it is meant to be copied and shared.
The link's public token, part of the url.
The address to send the payer. Use this value instead of building the URL yourself.
The product version this link sells, fixed at creation. Publishing a new version does not reprice a link already issued. When null, the link sells the latest published version at payment time.
false once revoked.
When the link was revoked.
Where the payer goes after paying, with ?status=success&invoice=… appended.
Offered to the payer as "back to the store" while the checkout is open; also the ?status=error destination when the charge expires in the embedded checkout.