Create a transaction
curl --request POST \
--url https://rewardservice-staging.withbenji.com/reward_transaction/create \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"reward_authentication_token": "<string>"
}
'import requests
url = "https://rewardservice-staging.withbenji.com/reward_transaction/create"
payload = { "reward_authentication_token": "<string>" }
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({reward_authentication_token: '<string>'})
};
fetch('https://rewardservice-staging.withbenji.com/reward_transaction/create', 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/create",
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([
'reward_authentication_token' => '<string>'
]),
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/create"
payload := strings.NewReader("{\n \"reward_authentication_token\": \"<string>\"\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/create")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"reward_authentication_token\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://rewardservice-staging.withbenji.com/reward_transaction/create")
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 \"reward_authentication_token\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"code": "ok",
"data": {
"reward_transactions": [{
"created_date": "2024-08-23T19:55:12.015047+00:00",
"last_updated_date": "2024-08-23T19:57:12.015047+00:00",
"status": 2,
"external_order_id": "5856681787572",
"id": 1,
"merchant_id": 1,
"partner_id": 1,
"campaign_id": 1,
"reward_amount": 266,
"transaction_amount": 885.95,
"transaction_type": 1,
"user_id": 1
}]
}
}
{
"error": "invalid_token",
"message": "Invalid token"
}
{
"error": "transaction_already_exists",
"message": "The transaction has already been created"
}
{
"error": "unauthorized_request",
"message": "Token is not authorized to make this request"
}
Create a transaction
Create a transaction using the reward transaction authentication token from the previous step.
POST
/
reward_transaction
/
create
Create a transaction
curl --request POST \
--url https://rewardservice-staging.withbenji.com/reward_transaction/create \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"reward_authentication_token": "<string>"
}
'import requests
url = "https://rewardservice-staging.withbenji.com/reward_transaction/create"
payload = { "reward_authentication_token": "<string>" }
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({reward_authentication_token: '<string>'})
};
fetch('https://rewardservice-staging.withbenji.com/reward_transaction/create', 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/create",
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([
'reward_authentication_token' => '<string>'
]),
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/create"
payload := strings.NewReader("{\n \"reward_authentication_token\": \"<string>\"\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/create")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"reward_authentication_token\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://rewardservice-staging.withbenji.com/reward_transaction/create")
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 \"reward_authentication_token\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"code": "ok",
"data": {
"reward_transactions": [{
"created_date": "2024-08-23T19:55:12.015047+00:00",
"last_updated_date": "2024-08-23T19:57:12.015047+00:00",
"status": 2,
"external_order_id": "5856681787572",
"id": 1,
"merchant_id": 1,
"partner_id": 1,
"campaign_id": 1,
"reward_amount": 266,
"transaction_amount": 885.95,
"transaction_type": 1,
"user_id": 1
}]
}
}
{
"error": "invalid_token",
"message": "Invalid token"
}
{
"error": "transaction_already_exists",
"message": "The transaction has already been created"
}
{
"error": "unauthorized_request",
"message": "Token is not authorized to make this request"
}
The
x-api-key header value to be used on this API is a user-based access token.string
required
The token received from the authenticate reward transaction API call.
Return values
array
An array of reward transaction objects created with this transaction
Hide items
Hide items
A reward transaction object property
Hide properties
Hide properties
integer
Benji Platform reward transaction identifier
integer
The ID of the partner associated with this transaction in the Benji Platform
integer
The ID of the campaign triggered for this transaction in the Benji Platform
integer
The ID of the user associated with the transaction in the Benji Platform
integer
The ID of the merchant partner associated with this campaign in the Benji Platform
integer
The total dollar amount of the transaction
integer
The total amount of rewards earned or redeemed on this transaction
string
The external reference of the order on the merchant partner system
integer
Integer representing an enum of one of the following transaction type values:
Show possible transaction type values
Show possible transaction type values
- EARN (1) : Indicating an earn transaction type
- REDEEM (2) : Indicating a redeem transaction type
integer
Integer representing an enum of one of the following transaction status values:
Show possible transaction status values
Show possible transaction status values
- PENDING (1) : Indicating a transaction that is pending and has not been confirmed by the partner yet
- CONFIRMED (2) : Indicating a transaction that has been confirmed by the partner
- FAILED (3) : Indicating a transaction that has been rejected by the partner
string
If status is FAILED, the reason why this transaction was rejected
datetime
Datetime indicating the last status change. For instance, if the status is CONFIRMED, this date will indicate when the transaction was confirmed
datetime
The transaction date
{
"code": "ok",
"data": {
"reward_transactions": [{
"created_date": "2024-08-23T19:55:12.015047+00:00",
"last_updated_date": "2024-08-23T19:57:12.015047+00:00",
"status": 2,
"external_order_id": "5856681787572",
"id": 1,
"merchant_id": 1,
"partner_id": 1,
"campaign_id": 1,
"reward_amount": 266,
"transaction_amount": 885.95,
"transaction_type": 1,
"user_id": 1
}]
}
}
{
"error": "invalid_token",
"message": "Invalid token"
}
{
"error": "transaction_already_exists",
"message": "The transaction has already been created"
}
{
"error": "unauthorized_request",
"message": "Token is not authorized to make this request"
}
Make sure to store the returned reward transaction ID. You can use this ID to get the status of the reward transaction when receiving reward_transaction_update webhooks.
The transaction authentication token is valid for 10 minutes.
Was this page helpful?
⌘I