curl --request POST \
--url https://api.example.com/api/v1/subscription/create \
--header 'Content-Type: application/json' \
--data '
{
"subscriptionRequest": "<string>",
"merchantSubscriptionId": "PLAN_001",
"currency": "USD",
"amount": 100,
"productInfo": {
"description": "Premium Monthly Subscription",
"periodType": "MONTHLY",
"periodInterval": 1,
"numberOfPeriod": 12,
"trialPeriodAmount": 0,
"numberOfTrialPeriod": 1,
"trialPeriodType": "MONTHLY",
"trialPeriodInterval": 1,
"scheduledAmounts": [
{
"period": "<string>",
"amount": "<string>"
}
]
},
"merchantInfo": {
"merchantId": 1000000201,
"subMerchantId": "<string>"
},
"userInfo": {
"userId": "USER001",
"userEmail": "user@example.com",
"userTerminal": "<string>",
"userPhone": "+62-08990013157",
"userFirstName": "<string>",
"userLastName": "<string>",
"userCreatedAt": "2023-11-07T05:31:56Z"
},
"requestedAt": "2023-11-07T05:31:56Z",
"notifyUrl": "https://merchant-notify-url.com",
"promotionInfo": {
"promotionCode": "<string>",
"couponId": "<string>"
},
"userCurrency": "<string>",
"addressInfo": {
"address": "<string>",
"city": "<string>",
"region": "<string>",
"postcode": "<string>",
"addressCountryCode": "<string>"
},
"brandInfo": {
"cashierLogoUrl": "<string>",
"cashierDisplayName": "<string>",
"cashierProductImageUrl": "<string>"
},
"paymentInfo": {
"productName": "SUBSCRIPTION",
"payMethodType": "APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY"
},
"startTime": "2023-11-07T05:31:56Z",
"successRedirectUrl": "https://merchant-success-redirecturl.com",
"failedRedirectUrl": "https://merchant-failed-redirecturl.com",
"cancelRedirectUrl": "https://merchant-cancel-url.com",
"riskData": {
"userType": "Individual",
"userCategory": "Member",
"userLegalName": "John Doe",
"userDisplayName": "John",
"userRegistrationIp": "192.168.1.1",
"userLastSeenIp": "192.168.1.1",
"userIsNew": "No",
"userIsFirstPurchase": "No"
},
"subscriptionManagementUrl": "https://merchant.com/subscription/manage",
"extendInfo": "<string>",
"orderExpiredAt": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.example.com/api/v1/subscription/create"
payload = {
"subscriptionRequest": "<string>",
"merchantSubscriptionId": "PLAN_001",
"currency": "USD",
"amount": 100,
"productInfo": {
"description": "Premium Monthly Subscription",
"periodType": "MONTHLY",
"periodInterval": 1,
"numberOfPeriod": 12,
"trialPeriodAmount": 0,
"numberOfTrialPeriod": 1,
"trialPeriodType": "MONTHLY",
"trialPeriodInterval": 1,
"scheduledAmounts": [
{
"period": "<string>",
"amount": "<string>"
}
]
},
"merchantInfo": {
"merchantId": 1000000201,
"subMerchantId": "<string>"
},
"userInfo": {
"userId": "USER001",
"userEmail": "user@example.com",
"userTerminal": "<string>",
"userPhone": "+62-08990013157",
"userFirstName": "<string>",
"userLastName": "<string>",
"userCreatedAt": "2023-11-07T05:31:56Z"
},
"requestedAt": "2023-11-07T05:31:56Z",
"notifyUrl": "https://merchant-notify-url.com",
"promotionInfo": {
"promotionCode": "<string>",
"couponId": "<string>"
},
"userCurrency": "<string>",
"addressInfo": {
"address": "<string>",
"city": "<string>",
"region": "<string>",
"postcode": "<string>",
"addressCountryCode": "<string>"
},
"brandInfo": {
"cashierLogoUrl": "<string>",
"cashierDisplayName": "<string>",
"cashierProductImageUrl": "<string>"
},
"paymentInfo": {
"productName": "SUBSCRIPTION",
"payMethodType": "APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY"
},
"startTime": "2023-11-07T05:31:56Z",
"successRedirectUrl": "https://merchant-success-redirecturl.com",
"failedRedirectUrl": "https://merchant-failed-redirecturl.com",
"cancelRedirectUrl": "https://merchant-cancel-url.com",
"riskData": {
"userType": "Individual",
"userCategory": "Member",
"userLegalName": "John Doe",
"userDisplayName": "John",
"userRegistrationIp": "192.168.1.1",
"userLastSeenIp": "192.168.1.1",
"userIsNew": "No",
"userIsFirstPurchase": "No"
},
"subscriptionManagementUrl": "https://merchant.com/subscription/manage",
"extendInfo": "<string>",
"orderExpiredAt": "2023-11-07T05:31:56Z"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
subscriptionRequest: '<string>',
merchantSubscriptionId: 'PLAN_001',
currency: 'USD',
amount: 100,
productInfo: {
description: 'Premium Monthly Subscription',
periodType: 'MONTHLY',
periodInterval: 1,
numberOfPeriod: 12,
trialPeriodAmount: 0,
numberOfTrialPeriod: 1,
trialPeriodType: 'MONTHLY',
trialPeriodInterval: 1,
scheduledAmounts: [{period: '<string>', amount: '<string>'}]
},
merchantInfo: {merchantId: 1000000201, subMerchantId: '<string>'},
userInfo: {
userId: 'USER001',
userEmail: 'user@example.com',
userTerminal: '<string>',
userPhone: '+62-08990013157',
userFirstName: '<string>',
userLastName: '<string>',
userCreatedAt: '2023-11-07T05:31:56Z'
},
requestedAt: '2023-11-07T05:31:56Z',
notifyUrl: 'https://merchant-notify-url.com',
promotionInfo: {promotionCode: '<string>', couponId: '<string>'},
userCurrency: '<string>',
addressInfo: {
address: '<string>',
city: '<string>',
region: '<string>',
postcode: '<string>',
addressCountryCode: '<string>'
},
brandInfo: {
cashierLogoUrl: '<string>',
cashierDisplayName: '<string>',
cashierProductImageUrl: '<string>'
},
paymentInfo: {
productName: 'SUBSCRIPTION',
payMethodType: 'APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY'
},
startTime: '2023-11-07T05:31:56Z',
successRedirectUrl: 'https://merchant-success-redirecturl.com',
failedRedirectUrl: 'https://merchant-failed-redirecturl.com',
cancelRedirectUrl: 'https://merchant-cancel-url.com',
riskData: {
userType: 'Individual',
userCategory: 'Member',
userLegalName: 'John Doe',
userDisplayName: 'John',
userRegistrationIp: '192.168.1.1',
userLastSeenIp: '192.168.1.1',
userIsNew: 'No',
userIsFirstPurchase: 'No'
},
subscriptionManagementUrl: 'https://merchant.com/subscription/manage',
extendInfo: '<string>',
orderExpiredAt: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.example.com/api/v1/subscription/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://api.example.com/api/v1/subscription/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([
'subscriptionRequest' => '<string>',
'merchantSubscriptionId' => 'PLAN_001',
'currency' => 'USD',
'amount' => 100,
'productInfo' => [
'description' => 'Premium Monthly Subscription',
'periodType' => 'MONTHLY',
'periodInterval' => 1,
'numberOfPeriod' => 12,
'trialPeriodAmount' => 0,
'numberOfTrialPeriod' => 1,
'trialPeriodType' => 'MONTHLY',
'trialPeriodInterval' => 1,
'scheduledAmounts' => [
[
'period' => '<string>',
'amount' => '<string>'
]
]
],
'merchantInfo' => [
'merchantId' => 1000000201,
'subMerchantId' => '<string>'
],
'userInfo' => [
'userId' => 'USER001',
'userEmail' => 'user@example.com',
'userTerminal' => '<string>',
'userPhone' => '+62-08990013157',
'userFirstName' => '<string>',
'userLastName' => '<string>',
'userCreatedAt' => '2023-11-07T05:31:56Z'
],
'requestedAt' => '2023-11-07T05:31:56Z',
'notifyUrl' => 'https://merchant-notify-url.com',
'promotionInfo' => [
'promotionCode' => '<string>',
'couponId' => '<string>'
],
'userCurrency' => '<string>',
'addressInfo' => [
'address' => '<string>',
'city' => '<string>',
'region' => '<string>',
'postcode' => '<string>',
'addressCountryCode' => '<string>'
],
'brandInfo' => [
'cashierLogoUrl' => '<string>',
'cashierDisplayName' => '<string>',
'cashierProductImageUrl' => '<string>'
],
'paymentInfo' => [
'productName' => 'SUBSCRIPTION',
'payMethodType' => 'APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY'
],
'startTime' => '2023-11-07T05:31:56Z',
'successRedirectUrl' => 'https://merchant-success-redirecturl.com',
'failedRedirectUrl' => 'https://merchant-failed-redirecturl.com',
'cancelRedirectUrl' => 'https://merchant-cancel-url.com',
'riskData' => [
'userType' => 'Individual',
'userCategory' => 'Member',
'userLegalName' => 'John Doe',
'userDisplayName' => 'John',
'userRegistrationIp' => '192.168.1.1',
'userLastSeenIp' => '192.168.1.1',
'userIsNew' => 'No',
'userIsFirstPurchase' => 'No'
],
'subscriptionManagementUrl' => 'https://merchant.com/subscription/manage',
'extendInfo' => '<string>',
'orderExpiredAt' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"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.example.com/api/v1/subscription/create"
payload := strings.NewReader("{\n \"subscriptionRequest\": \"<string>\",\n \"merchantSubscriptionId\": \"PLAN_001\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"productInfo\": {\n \"description\": \"Premium Monthly Subscription\",\n \"periodType\": \"MONTHLY\",\n \"periodInterval\": 1,\n \"numberOfPeriod\": 12,\n \"trialPeriodAmount\": 0,\n \"numberOfTrialPeriod\": 1,\n \"trialPeriodType\": \"MONTHLY\",\n \"trialPeriodInterval\": 1,\n \"scheduledAmounts\": [\n {\n \"period\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ]\n },\n \"merchantInfo\": {\n \"merchantId\": 1000000201,\n \"subMerchantId\": \"<string>\"\n },\n \"userInfo\": {\n \"userId\": \"USER001\",\n \"userEmail\": \"user@example.com\",\n \"userTerminal\": \"<string>\",\n \"userPhone\": \"+62-08990013157\",\n \"userFirstName\": \"<string>\",\n \"userLastName\": \"<string>\",\n \"userCreatedAt\": \"2023-11-07T05:31:56Z\"\n },\n \"requestedAt\": \"2023-11-07T05:31:56Z\",\n \"notifyUrl\": \"https://merchant-notify-url.com\",\n \"promotionInfo\": {\n \"promotionCode\": \"<string>\",\n \"couponId\": \"<string>\"\n },\n \"userCurrency\": \"<string>\",\n \"addressInfo\": {\n \"address\": \"<string>\",\n \"city\": \"<string>\",\n \"region\": \"<string>\",\n \"postcode\": \"<string>\",\n \"addressCountryCode\": \"<string>\"\n },\n \"brandInfo\": {\n \"cashierLogoUrl\": \"<string>\",\n \"cashierDisplayName\": \"<string>\",\n \"cashierProductImageUrl\": \"<string>\"\n },\n \"paymentInfo\": {\n \"productName\": \"SUBSCRIPTION\",\n \"payMethodType\": \"APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY\"\n },\n \"startTime\": \"2023-11-07T05:31:56Z\",\n \"successRedirectUrl\": \"https://merchant-success-redirecturl.com\",\n \"failedRedirectUrl\": \"https://merchant-failed-redirecturl.com\",\n \"cancelRedirectUrl\": \"https://merchant-cancel-url.com\",\n \"riskData\": {\n \"userType\": \"Individual\",\n \"userCategory\": \"Member\",\n \"userLegalName\": \"John Doe\",\n \"userDisplayName\": \"John\",\n \"userRegistrationIp\": \"192.168.1.1\",\n \"userLastSeenIp\": \"192.168.1.1\",\n \"userIsNew\": \"No\",\n \"userIsFirstPurchase\": \"No\"\n },\n \"subscriptionManagementUrl\": \"https://merchant.com/subscription/manage\",\n \"extendInfo\": \"<string>\",\n \"orderExpiredAt\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/api/v1/subscription/create")
.header("Content-Type", "application/json")
.body("{\n \"subscriptionRequest\": \"<string>\",\n \"merchantSubscriptionId\": \"PLAN_001\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"productInfo\": {\n \"description\": \"Premium Monthly Subscription\",\n \"periodType\": \"MONTHLY\",\n \"periodInterval\": 1,\n \"numberOfPeriod\": 12,\n \"trialPeriodAmount\": 0,\n \"numberOfTrialPeriod\": 1,\n \"trialPeriodType\": \"MONTHLY\",\n \"trialPeriodInterval\": 1,\n \"scheduledAmounts\": [\n {\n \"period\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ]\n },\n \"merchantInfo\": {\n \"merchantId\": 1000000201,\n \"subMerchantId\": \"<string>\"\n },\n \"userInfo\": {\n \"userId\": \"USER001\",\n \"userEmail\": \"user@example.com\",\n \"userTerminal\": \"<string>\",\n \"userPhone\": \"+62-08990013157\",\n \"userFirstName\": \"<string>\",\n \"userLastName\": \"<string>\",\n \"userCreatedAt\": \"2023-11-07T05:31:56Z\"\n },\n \"requestedAt\": \"2023-11-07T05:31:56Z\",\n \"notifyUrl\": \"https://merchant-notify-url.com\",\n \"promotionInfo\": {\n \"promotionCode\": \"<string>\",\n \"couponId\": \"<string>\"\n },\n \"userCurrency\": \"<string>\",\n \"addressInfo\": {\n \"address\": \"<string>\",\n \"city\": \"<string>\",\n \"region\": \"<string>\",\n \"postcode\": \"<string>\",\n \"addressCountryCode\": \"<string>\"\n },\n \"brandInfo\": {\n \"cashierLogoUrl\": \"<string>\",\n \"cashierDisplayName\": \"<string>\",\n \"cashierProductImageUrl\": \"<string>\"\n },\n \"paymentInfo\": {\n \"productName\": \"SUBSCRIPTION\",\n \"payMethodType\": \"APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY\"\n },\n \"startTime\": \"2023-11-07T05:31:56Z\",\n \"successRedirectUrl\": \"https://merchant-success-redirecturl.com\",\n \"failedRedirectUrl\": \"https://merchant-failed-redirecturl.com\",\n \"cancelRedirectUrl\": \"https://merchant-cancel-url.com\",\n \"riskData\": {\n \"userType\": \"Individual\",\n \"userCategory\": \"Member\",\n \"userLegalName\": \"John Doe\",\n \"userDisplayName\": \"John\",\n \"userRegistrationIp\": \"192.168.1.1\",\n \"userLastSeenIp\": \"192.168.1.1\",\n \"userIsNew\": \"No\",\n \"userIsFirstPurchase\": \"No\"\n },\n \"subscriptionManagementUrl\": \"https://merchant.com/subscription/manage\",\n \"extendInfo\": \"<string>\",\n \"orderExpiredAt\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/subscription/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"subscriptionRequest\": \"<string>\",\n \"merchantSubscriptionId\": \"PLAN_001\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"productInfo\": {\n \"description\": \"Premium Monthly Subscription\",\n \"periodType\": \"MONTHLY\",\n \"periodInterval\": 1,\n \"numberOfPeriod\": 12,\n \"trialPeriodAmount\": 0,\n \"numberOfTrialPeriod\": 1,\n \"trialPeriodType\": \"MONTHLY\",\n \"trialPeriodInterval\": 1,\n \"scheduledAmounts\": [\n {\n \"period\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ]\n },\n \"merchantInfo\": {\n \"merchantId\": 1000000201,\n \"subMerchantId\": \"<string>\"\n },\n \"userInfo\": {\n \"userId\": \"USER001\",\n \"userEmail\": \"user@example.com\",\n \"userTerminal\": \"<string>\",\n \"userPhone\": \"+62-08990013157\",\n \"userFirstName\": \"<string>\",\n \"userLastName\": \"<string>\",\n \"userCreatedAt\": \"2023-11-07T05:31:56Z\"\n },\n \"requestedAt\": \"2023-11-07T05:31:56Z\",\n \"notifyUrl\": \"https://merchant-notify-url.com\",\n \"promotionInfo\": {\n \"promotionCode\": \"<string>\",\n \"couponId\": \"<string>\"\n },\n \"userCurrency\": \"<string>\",\n \"addressInfo\": {\n \"address\": \"<string>\",\n \"city\": \"<string>\",\n \"region\": \"<string>\",\n \"postcode\": \"<string>\",\n \"addressCountryCode\": \"<string>\"\n },\n \"brandInfo\": {\n \"cashierLogoUrl\": \"<string>\",\n \"cashierDisplayName\": \"<string>\",\n \"cashierProductImageUrl\": \"<string>\"\n },\n \"paymentInfo\": {\n \"productName\": \"SUBSCRIPTION\",\n \"payMethodType\": \"APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY\"\n },\n \"startTime\": \"2023-11-07T05:31:56Z\",\n \"successRedirectUrl\": \"https://merchant-success-redirecturl.com\",\n \"failedRedirectUrl\": \"https://merchant-failed-redirecturl.com\",\n \"cancelRedirectUrl\": \"https://merchant-cancel-url.com\",\n \"riskData\": {\n \"userType\": \"Individual\",\n \"userCategory\": \"Member\",\n \"userLegalName\": \"John Doe\",\n \"userDisplayName\": \"John\",\n \"userRegistrationIp\": \"192.168.1.1\",\n \"userLastSeenIp\": \"192.168.1.1\",\n \"userIsNew\": \"No\",\n \"userIsFirstPurchase\": \"No\"\n },\n \"subscriptionManagementUrl\": \"https://merchant.com/subscription/manage\",\n \"extendInfo\": \"<string>\",\n \"orderExpiredAt\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"msg": "success",
"data": {
"subscriptionRequest": "<string>",
"merchantSubscriptionId": "<string>",
"subscriptionId": "<string>",
"payMethodSubscriptionId": "<string>",
"subscriptionStatus": "<string>",
"subscriptionAction": "<string>"
}
}Create Subscription
Note: For certain Pay Methods, some optional fields are required. Kindly refer to Section Specific Pay Method Requirement
curl --request POST \
--url https://api.example.com/api/v1/subscription/create \
--header 'Content-Type: application/json' \
--data '
{
"subscriptionRequest": "<string>",
"merchantSubscriptionId": "PLAN_001",
"currency": "USD",
"amount": 100,
"productInfo": {
"description": "Premium Monthly Subscription",
"periodType": "MONTHLY",
"periodInterval": 1,
"numberOfPeriod": 12,
"trialPeriodAmount": 0,
"numberOfTrialPeriod": 1,
"trialPeriodType": "MONTHLY",
"trialPeriodInterval": 1,
"scheduledAmounts": [
{
"period": "<string>",
"amount": "<string>"
}
]
},
"merchantInfo": {
"merchantId": 1000000201,
"subMerchantId": "<string>"
},
"userInfo": {
"userId": "USER001",
"userEmail": "user@example.com",
"userTerminal": "<string>",
"userPhone": "+62-08990013157",
"userFirstName": "<string>",
"userLastName": "<string>",
"userCreatedAt": "2023-11-07T05:31:56Z"
},
"requestedAt": "2023-11-07T05:31:56Z",
"notifyUrl": "https://merchant-notify-url.com",
"promotionInfo": {
"promotionCode": "<string>",
"couponId": "<string>"
},
"userCurrency": "<string>",
"addressInfo": {
"address": "<string>",
"city": "<string>",
"region": "<string>",
"postcode": "<string>",
"addressCountryCode": "<string>"
},
"brandInfo": {
"cashierLogoUrl": "<string>",
"cashierDisplayName": "<string>",
"cashierProductImageUrl": "<string>"
},
"paymentInfo": {
"productName": "SUBSCRIPTION",
"payMethodType": "APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY"
},
"startTime": "2023-11-07T05:31:56Z",
"successRedirectUrl": "https://merchant-success-redirecturl.com",
"failedRedirectUrl": "https://merchant-failed-redirecturl.com",
"cancelRedirectUrl": "https://merchant-cancel-url.com",
"riskData": {
"userType": "Individual",
"userCategory": "Member",
"userLegalName": "John Doe",
"userDisplayName": "John",
"userRegistrationIp": "192.168.1.1",
"userLastSeenIp": "192.168.1.1",
"userIsNew": "No",
"userIsFirstPurchase": "No"
},
"subscriptionManagementUrl": "https://merchant.com/subscription/manage",
"extendInfo": "<string>",
"orderExpiredAt": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.example.com/api/v1/subscription/create"
payload = {
"subscriptionRequest": "<string>",
"merchantSubscriptionId": "PLAN_001",
"currency": "USD",
"amount": 100,
"productInfo": {
"description": "Premium Monthly Subscription",
"periodType": "MONTHLY",
"periodInterval": 1,
"numberOfPeriod": 12,
"trialPeriodAmount": 0,
"numberOfTrialPeriod": 1,
"trialPeriodType": "MONTHLY",
"trialPeriodInterval": 1,
"scheduledAmounts": [
{
"period": "<string>",
"amount": "<string>"
}
]
},
"merchantInfo": {
"merchantId": 1000000201,
"subMerchantId": "<string>"
},
"userInfo": {
"userId": "USER001",
"userEmail": "user@example.com",
"userTerminal": "<string>",
"userPhone": "+62-08990013157",
"userFirstName": "<string>",
"userLastName": "<string>",
"userCreatedAt": "2023-11-07T05:31:56Z"
},
"requestedAt": "2023-11-07T05:31:56Z",
"notifyUrl": "https://merchant-notify-url.com",
"promotionInfo": {
"promotionCode": "<string>",
"couponId": "<string>"
},
"userCurrency": "<string>",
"addressInfo": {
"address": "<string>",
"city": "<string>",
"region": "<string>",
"postcode": "<string>",
"addressCountryCode": "<string>"
},
"brandInfo": {
"cashierLogoUrl": "<string>",
"cashierDisplayName": "<string>",
"cashierProductImageUrl": "<string>"
},
"paymentInfo": {
"productName": "SUBSCRIPTION",
"payMethodType": "APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY"
},
"startTime": "2023-11-07T05:31:56Z",
"successRedirectUrl": "https://merchant-success-redirecturl.com",
"failedRedirectUrl": "https://merchant-failed-redirecturl.com",
"cancelRedirectUrl": "https://merchant-cancel-url.com",
"riskData": {
"userType": "Individual",
"userCategory": "Member",
"userLegalName": "John Doe",
"userDisplayName": "John",
"userRegistrationIp": "192.168.1.1",
"userLastSeenIp": "192.168.1.1",
"userIsNew": "No",
"userIsFirstPurchase": "No"
},
"subscriptionManagementUrl": "https://merchant.com/subscription/manage",
"extendInfo": "<string>",
"orderExpiredAt": "2023-11-07T05:31:56Z"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
subscriptionRequest: '<string>',
merchantSubscriptionId: 'PLAN_001',
currency: 'USD',
amount: 100,
productInfo: {
description: 'Premium Monthly Subscription',
periodType: 'MONTHLY',
periodInterval: 1,
numberOfPeriod: 12,
trialPeriodAmount: 0,
numberOfTrialPeriod: 1,
trialPeriodType: 'MONTHLY',
trialPeriodInterval: 1,
scheduledAmounts: [{period: '<string>', amount: '<string>'}]
},
merchantInfo: {merchantId: 1000000201, subMerchantId: '<string>'},
userInfo: {
userId: 'USER001',
userEmail: 'user@example.com',
userTerminal: '<string>',
userPhone: '+62-08990013157',
userFirstName: '<string>',
userLastName: '<string>',
userCreatedAt: '2023-11-07T05:31:56Z'
},
requestedAt: '2023-11-07T05:31:56Z',
notifyUrl: 'https://merchant-notify-url.com',
promotionInfo: {promotionCode: '<string>', couponId: '<string>'},
userCurrency: '<string>',
addressInfo: {
address: '<string>',
city: '<string>',
region: '<string>',
postcode: '<string>',
addressCountryCode: '<string>'
},
brandInfo: {
cashierLogoUrl: '<string>',
cashierDisplayName: '<string>',
cashierProductImageUrl: '<string>'
},
paymentInfo: {
productName: 'SUBSCRIPTION',
payMethodType: 'APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY'
},
startTime: '2023-11-07T05:31:56Z',
successRedirectUrl: 'https://merchant-success-redirecturl.com',
failedRedirectUrl: 'https://merchant-failed-redirecturl.com',
cancelRedirectUrl: 'https://merchant-cancel-url.com',
riskData: {
userType: 'Individual',
userCategory: 'Member',
userLegalName: 'John Doe',
userDisplayName: 'John',
userRegistrationIp: '192.168.1.1',
userLastSeenIp: '192.168.1.1',
userIsNew: 'No',
userIsFirstPurchase: 'No'
},
subscriptionManagementUrl: 'https://merchant.com/subscription/manage',
extendInfo: '<string>',
orderExpiredAt: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.example.com/api/v1/subscription/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://api.example.com/api/v1/subscription/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([
'subscriptionRequest' => '<string>',
'merchantSubscriptionId' => 'PLAN_001',
'currency' => 'USD',
'amount' => 100,
'productInfo' => [
'description' => 'Premium Monthly Subscription',
'periodType' => 'MONTHLY',
'periodInterval' => 1,
'numberOfPeriod' => 12,
'trialPeriodAmount' => 0,
'numberOfTrialPeriod' => 1,
'trialPeriodType' => 'MONTHLY',
'trialPeriodInterval' => 1,
'scheduledAmounts' => [
[
'period' => '<string>',
'amount' => '<string>'
]
]
],
'merchantInfo' => [
'merchantId' => 1000000201,
'subMerchantId' => '<string>'
],
'userInfo' => [
'userId' => 'USER001',
'userEmail' => 'user@example.com',
'userTerminal' => '<string>',
'userPhone' => '+62-08990013157',
'userFirstName' => '<string>',
'userLastName' => '<string>',
'userCreatedAt' => '2023-11-07T05:31:56Z'
],
'requestedAt' => '2023-11-07T05:31:56Z',
'notifyUrl' => 'https://merchant-notify-url.com',
'promotionInfo' => [
'promotionCode' => '<string>',
'couponId' => '<string>'
],
'userCurrency' => '<string>',
'addressInfo' => [
'address' => '<string>',
'city' => '<string>',
'region' => '<string>',
'postcode' => '<string>',
'addressCountryCode' => '<string>'
],
'brandInfo' => [
'cashierLogoUrl' => '<string>',
'cashierDisplayName' => '<string>',
'cashierProductImageUrl' => '<string>'
],
'paymentInfo' => [
'productName' => 'SUBSCRIPTION',
'payMethodType' => 'APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY'
],
'startTime' => '2023-11-07T05:31:56Z',
'successRedirectUrl' => 'https://merchant-success-redirecturl.com',
'failedRedirectUrl' => 'https://merchant-failed-redirecturl.com',
'cancelRedirectUrl' => 'https://merchant-cancel-url.com',
'riskData' => [
'userType' => 'Individual',
'userCategory' => 'Member',
'userLegalName' => 'John Doe',
'userDisplayName' => 'John',
'userRegistrationIp' => '192.168.1.1',
'userLastSeenIp' => '192.168.1.1',
'userIsNew' => 'No',
'userIsFirstPurchase' => 'No'
],
'subscriptionManagementUrl' => 'https://merchant.com/subscription/manage',
'extendInfo' => '<string>',
'orderExpiredAt' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"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.example.com/api/v1/subscription/create"
payload := strings.NewReader("{\n \"subscriptionRequest\": \"<string>\",\n \"merchantSubscriptionId\": \"PLAN_001\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"productInfo\": {\n \"description\": \"Premium Monthly Subscription\",\n \"periodType\": \"MONTHLY\",\n \"periodInterval\": 1,\n \"numberOfPeriod\": 12,\n \"trialPeriodAmount\": 0,\n \"numberOfTrialPeriod\": 1,\n \"trialPeriodType\": \"MONTHLY\",\n \"trialPeriodInterval\": 1,\n \"scheduledAmounts\": [\n {\n \"period\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ]\n },\n \"merchantInfo\": {\n \"merchantId\": 1000000201,\n \"subMerchantId\": \"<string>\"\n },\n \"userInfo\": {\n \"userId\": \"USER001\",\n \"userEmail\": \"user@example.com\",\n \"userTerminal\": \"<string>\",\n \"userPhone\": \"+62-08990013157\",\n \"userFirstName\": \"<string>\",\n \"userLastName\": \"<string>\",\n \"userCreatedAt\": \"2023-11-07T05:31:56Z\"\n },\n \"requestedAt\": \"2023-11-07T05:31:56Z\",\n \"notifyUrl\": \"https://merchant-notify-url.com\",\n \"promotionInfo\": {\n \"promotionCode\": \"<string>\",\n \"couponId\": \"<string>\"\n },\n \"userCurrency\": \"<string>\",\n \"addressInfo\": {\n \"address\": \"<string>\",\n \"city\": \"<string>\",\n \"region\": \"<string>\",\n \"postcode\": \"<string>\",\n \"addressCountryCode\": \"<string>\"\n },\n \"brandInfo\": {\n \"cashierLogoUrl\": \"<string>\",\n \"cashierDisplayName\": \"<string>\",\n \"cashierProductImageUrl\": \"<string>\"\n },\n \"paymentInfo\": {\n \"productName\": \"SUBSCRIPTION\",\n \"payMethodType\": \"APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY\"\n },\n \"startTime\": \"2023-11-07T05:31:56Z\",\n \"successRedirectUrl\": \"https://merchant-success-redirecturl.com\",\n \"failedRedirectUrl\": \"https://merchant-failed-redirecturl.com\",\n \"cancelRedirectUrl\": \"https://merchant-cancel-url.com\",\n \"riskData\": {\n \"userType\": \"Individual\",\n \"userCategory\": \"Member\",\n \"userLegalName\": \"John Doe\",\n \"userDisplayName\": \"John\",\n \"userRegistrationIp\": \"192.168.1.1\",\n \"userLastSeenIp\": \"192.168.1.1\",\n \"userIsNew\": \"No\",\n \"userIsFirstPurchase\": \"No\"\n },\n \"subscriptionManagementUrl\": \"https://merchant.com/subscription/manage\",\n \"extendInfo\": \"<string>\",\n \"orderExpiredAt\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/api/v1/subscription/create")
.header("Content-Type", "application/json")
.body("{\n \"subscriptionRequest\": \"<string>\",\n \"merchantSubscriptionId\": \"PLAN_001\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"productInfo\": {\n \"description\": \"Premium Monthly Subscription\",\n \"periodType\": \"MONTHLY\",\n \"periodInterval\": 1,\n \"numberOfPeriod\": 12,\n \"trialPeriodAmount\": 0,\n \"numberOfTrialPeriod\": 1,\n \"trialPeriodType\": \"MONTHLY\",\n \"trialPeriodInterval\": 1,\n \"scheduledAmounts\": [\n {\n \"period\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ]\n },\n \"merchantInfo\": {\n \"merchantId\": 1000000201,\n \"subMerchantId\": \"<string>\"\n },\n \"userInfo\": {\n \"userId\": \"USER001\",\n \"userEmail\": \"user@example.com\",\n \"userTerminal\": \"<string>\",\n \"userPhone\": \"+62-08990013157\",\n \"userFirstName\": \"<string>\",\n \"userLastName\": \"<string>\",\n \"userCreatedAt\": \"2023-11-07T05:31:56Z\"\n },\n \"requestedAt\": \"2023-11-07T05:31:56Z\",\n \"notifyUrl\": \"https://merchant-notify-url.com\",\n \"promotionInfo\": {\n \"promotionCode\": \"<string>\",\n \"couponId\": \"<string>\"\n },\n \"userCurrency\": \"<string>\",\n \"addressInfo\": {\n \"address\": \"<string>\",\n \"city\": \"<string>\",\n \"region\": \"<string>\",\n \"postcode\": \"<string>\",\n \"addressCountryCode\": \"<string>\"\n },\n \"brandInfo\": {\n \"cashierLogoUrl\": \"<string>\",\n \"cashierDisplayName\": \"<string>\",\n \"cashierProductImageUrl\": \"<string>\"\n },\n \"paymentInfo\": {\n \"productName\": \"SUBSCRIPTION\",\n \"payMethodType\": \"APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY\"\n },\n \"startTime\": \"2023-11-07T05:31:56Z\",\n \"successRedirectUrl\": \"https://merchant-success-redirecturl.com\",\n \"failedRedirectUrl\": \"https://merchant-failed-redirecturl.com\",\n \"cancelRedirectUrl\": \"https://merchant-cancel-url.com\",\n \"riskData\": {\n \"userType\": \"Individual\",\n \"userCategory\": \"Member\",\n \"userLegalName\": \"John Doe\",\n \"userDisplayName\": \"John\",\n \"userRegistrationIp\": \"192.168.1.1\",\n \"userLastSeenIp\": \"192.168.1.1\",\n \"userIsNew\": \"No\",\n \"userIsFirstPurchase\": \"No\"\n },\n \"subscriptionManagementUrl\": \"https://merchant.com/subscription/manage\",\n \"extendInfo\": \"<string>\",\n \"orderExpiredAt\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/subscription/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"subscriptionRequest\": \"<string>\",\n \"merchantSubscriptionId\": \"PLAN_001\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"productInfo\": {\n \"description\": \"Premium Monthly Subscription\",\n \"periodType\": \"MONTHLY\",\n \"periodInterval\": 1,\n \"numberOfPeriod\": 12,\n \"trialPeriodAmount\": 0,\n \"numberOfTrialPeriod\": 1,\n \"trialPeriodType\": \"MONTHLY\",\n \"trialPeriodInterval\": 1,\n \"scheduledAmounts\": [\n {\n \"period\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ]\n },\n \"merchantInfo\": {\n \"merchantId\": 1000000201,\n \"subMerchantId\": \"<string>\"\n },\n \"userInfo\": {\n \"userId\": \"USER001\",\n \"userEmail\": \"user@example.com\",\n \"userTerminal\": \"<string>\",\n \"userPhone\": \"+62-08990013157\",\n \"userFirstName\": \"<string>\",\n \"userLastName\": \"<string>\",\n \"userCreatedAt\": \"2023-11-07T05:31:56Z\"\n },\n \"requestedAt\": \"2023-11-07T05:31:56Z\",\n \"notifyUrl\": \"https://merchant-notify-url.com\",\n \"promotionInfo\": {\n \"promotionCode\": \"<string>\",\n \"couponId\": \"<string>\"\n },\n \"userCurrency\": \"<string>\",\n \"addressInfo\": {\n \"address\": \"<string>\",\n \"city\": \"<string>\",\n \"region\": \"<string>\",\n \"postcode\": \"<string>\",\n \"addressCountryCode\": \"<string>\"\n },\n \"brandInfo\": {\n \"cashierLogoUrl\": \"<string>\",\n \"cashierDisplayName\": \"<string>\",\n \"cashierProductImageUrl\": \"<string>\"\n },\n \"paymentInfo\": {\n \"productName\": \"SUBSCRIPTION\",\n \"payMethodType\": \"APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY\"\n },\n \"startTime\": \"2023-11-07T05:31:56Z\",\n \"successRedirectUrl\": \"https://merchant-success-redirecturl.com\",\n \"failedRedirectUrl\": \"https://merchant-failed-redirecturl.com\",\n \"cancelRedirectUrl\": \"https://merchant-cancel-url.com\",\n \"riskData\": {\n \"userType\": \"Individual\",\n \"userCategory\": \"Member\",\n \"userLegalName\": \"John Doe\",\n \"userDisplayName\": \"John\",\n \"userRegistrationIp\": \"192.168.1.1\",\n \"userLastSeenIp\": \"192.168.1.1\",\n \"userIsNew\": \"No\",\n \"userIsFirstPurchase\": \"No\"\n },\n \"subscriptionManagementUrl\": \"https://merchant.com/subscription/manage\",\n \"extendInfo\": \"<string>\",\n \"orderExpiredAt\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"msg": "success",
"data": {
"subscriptionRequest": "<string>",
"merchantSubscriptionId": "<string>",
"subscriptionId": "<string>",
"payMethodSubscriptionId": "<string>",
"subscriptionStatus": "<string>",
"subscriptionAction": "<string>"
}
}Body
Subscription request id sent from Merchant. It will also be used for idempotent check.
32Merchant subscription plan ID assigned to this user
64"PLAN_001"
Merchant subscription currency, for example USD
12"USD"
Merchant subscription amount, for example 100
24100
Subscription product info
Show child attributes
Show child attributes
Merchant info
Show child attributes
Show child attributes
User info
Show child attributes
Show child attributes
Merchant-side request time
The callback address to notify the merchant after the subscription is completed / failed
1024"https://merchant-notify-url.com"
Promotion info for coupon marketing
Show child attributes
Show child attributes
User payment currency. This is needed when merchant order currency is NOT the same as user payment currency
12Merchant goods information
Show child attributes
Show child attributes
Address Information
Show child attributes
Show child attributes
Brand display information for cashier
Show child attributes
Show child attributes
Payment information
Show child attributes
Show child attributes
{
"productName": "SUBSCRIPTION",
"payMethodType": "APPLEPAY,CREDITCARD,DEBITCARD,GOOGLEPAY"
}Specified subscription start time. If not provided, the subscription starts immediately.
The address of the merchant page to redirect to after successful subscription payment. If no value is provided, it will stay on the cashier page after successful payment.
1024"https://merchant-success-redirecturl.com"
The address of the merchant page to which the payment pre-verification fails, or the redirection after the payment fails. If no value is provided, it will stay on the cashier page after the payment fails
1024"https://merchant-failed-redirecturl.com"
User will be redirected to this page if user choose to cancel and not continue the payment
512"https://merchant-cancel-url.com"
Risk data for compliance
Show child attributes
Show child attributes
It refers to the subscription management page for users on the merchant side.
256"https://merchant.com/subscription/manage"
Reserved. Json format e.g. {"key1":"value1", "key2":"value2"}
256The order expiry time set by merchant. User is required to input payment data on Waffo cashier page prior to merchant's order expiry time. If not provided, the default is 4 hours