Create a transaction token
curl --request POST \
--url https://rewardservice-staging.withbenji.com/reward_transaction/auth \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"transaction_amount": 123,
"external_transaction_id": "<string>",
"campaign_id": 123,
"partner_id": 123
}
'import requests
url = "https://rewardservice-staging.withbenji.com/reward_transaction/auth"
payload = {
"transaction_amount": 123,
"external_transaction_id": "<string>",
"campaign_id": 123,
"partner_id": 123
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
transaction_amount: 123,
external_transaction_id: '<string>',
campaign_id: 123,
partner_id: 123
})
};
fetch('https://rewardservice-staging.withbenji.com/reward_transaction/auth', 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://rewardservice-staging.withbenji.com/reward_transaction/auth",
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([
'transaction_amount' => 123,
'external_transaction_id' => '<string>',
'campaign_id' => 123,
'partner_id' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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://rewardservice-staging.withbenji.com/reward_transaction/auth"
payload := strings.NewReader("{\n \"transaction_amount\": 123,\n \"external_transaction_id\": \"<string>\",\n \"campaign_id\": 123,\n \"partner_id\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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://rewardservice-staging.withbenji.com/reward_transaction/auth")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"transaction_amount\": 123,\n \"external_transaction_id\": \"<string>\",\n \"campaign_id\": 123,\n \"partner_id\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://rewardservice-staging.withbenji.com/reward_transaction/auth")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"transaction_amount\": 123,\n \"external_transaction_id\": \"<string>\",\n \"campaign_id\": 123,\n \"partner_id\": 123\n}"
response = http.request(request)
puts response.read_body{
"code": "ok",
"data": {
"authentication_id": "016bb1f6-ab4e-11ef-a1a8-0a58a9feac02",
"authentication_status": 1
}
}
{
"error": "unauthorized_user",
"message": "Invalid key, or key is not authorized to make this call"
}
{
"error": "unexpected_error",
"message": "An unexpected error has occurred"
}
Create a transaction token
Create a token to authenticate the transaction and use in the create transaction API
POST
/
reward_transaction
/
auth
Create a transaction token
curl --request POST \
--url https://rewardservice-staging.withbenji.com/reward_transaction/auth \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"transaction_amount": 123,
"external_transaction_id": "<string>",
"campaign_id": 123,
"partner_id": 123
}
'import requests
url = "https://rewardservice-staging.withbenji.com/reward_transaction/auth"
payload = {
"transaction_amount": 123,
"external_transaction_id": "<string>",
"campaign_id": 123,
"partner_id": 123
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
transaction_amount: 123,
external_transaction_id: '<string>',
campaign_id: 123,
partner_id: 123
})
};
fetch('https://rewardservice-staging.withbenji.com/reward_transaction/auth', 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://rewardservice-staging.withbenji.com/reward_transaction/auth",
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([
'transaction_amount' => 123,
'external_transaction_id' => '<string>',
'campaign_id' => 123,
'partner_id' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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://rewardservice-staging.withbenji.com/reward_transaction/auth"
payload := strings.NewReader("{\n \"transaction_amount\": 123,\n \"external_transaction_id\": \"<string>\",\n \"campaign_id\": 123,\n \"partner_id\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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://rewardservice-staging.withbenji.com/reward_transaction/auth")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"transaction_amount\": 123,\n \"external_transaction_id\": \"<string>\",\n \"campaign_id\": 123,\n \"partner_id\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://rewardservice-staging.withbenji.com/reward_transaction/auth")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"transaction_amount\": 123,\n \"external_transaction_id\": \"<string>\",\n \"campaign_id\": 123,\n \"partner_id\": 123\n}"
response = http.request(request)
puts response.read_body{
"code": "ok",
"data": {
"authentication_id": "016bb1f6-ab4e-11ef-a1a8-0a58a9feac02",
"authentication_status": 1
}
}
{
"error": "unauthorized_user",
"message": "Invalid key, or key is not authorized to make this call"
}
{
"error": "unexpected_error",
"message": "An unexpected error has occurred"
}
The
x-api-key header value to be used on this API is a user-based access token.integer
required
The total amount of the transaction.
string
required
The unique identifier in your system of the order transaction.
integer
The ID of the campaign associated with the transaction. Note that in cases of a single running campaign, this field is optional.
integer
For marketplace-only scenarios, if the user pre-selected a partner to earn or redeem points on. When not passed, the user’s default loyalty partner will be used.
Return values
string
required
The transaction token to use when calling the create transaction API
integer
required
Integer representing an enum of one of the following transaction authentication status values:
Show possible transaction authentication status values
Show possible transaction authentication status values
- AUTHENTICATED (1) : Transaction is authenticated
- INSUFFICIENT_REWARDS_AMOUNT (2) : Member does not have sufficient rewards for the transaction
- MEMBER_NOT_EXISTS (3) : The user does not have a valid loyalty account with the partner currently
- ERROR (4) : General error when authenticating the transaction
{
"code": "ok",
"data": {
"authentication_id": "016bb1f6-ab4e-11ef-a1a8-0a58a9feac02",
"authentication_status": 1
}
}
{
"error": "unauthorized_user",
"message": "Invalid key, or key is not authorized to make this call"
}
{
"error": "unexpected_error",
"message": "An unexpected error has occurred"
}
Was this page helpful?
⌘I