Build Widget
Tokidoki API is for implementing subscription solution when product information is stored in Merchant Area Tokidoki section.
Please pass X-ApiKey
through HttpHeader
, the value is Project Key
,which can be found in Merchant Area.
Parameters
Name | Description |
---|---|
key required string |
The project key which can be found in Merchant Area→ My Projects. |
user_email required string |
Email of the end-user in your system. |
package_id required int |
It can be found in Merchant Area–>Tokidoki–>Packages section It’s not required if request already includes package_sku_id |
package_sku_id required varchar |
Each package will be idenfified by an unique SKU ID. This is the SKU ID that you already inputted when you setup the package It’s not required if request already includes package_id |
custom optional array |
Refer to more optional parameters for extra needs or user profile parameters for risk scoring. |
Endpoint
POST https://payments.terminal3.com/developers/tokidoki-api/widget-url
Sample Request
<?php
require_once('path/to/lib/paymentwall.php');
$key = 'YOUR_PROJECT_KEY';
$params = [
'user_email' => 'YOUR_EMAIL@email.com',
'package_id' => 59,
'package_sku_id' => 'your_package_sku_id',
'custom' => [
'success_url' => 'https://www.xxx.com',
'failure_url' => 'https://www.yyy.com'
]
];
$curlOptions = [
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-ApiKey:' . $key
],
CURLOPT_POSTFIELDS => json_encode($params)
];
$endpoint = 'https://payments.terminal3.com/developers/tokidoki-api/widget-url';
$curl = curl_init();
curl_setopt_array($curl, $curlOptions);
curl_setopt($curl, CURLOPT_URL, $endpoint);
$content = curl_exec($curl);
curl_close($curl);
$response = json_decode($content, true);
if ($response['success'] == 1) {
header("Location: ".$response['data'] . PHP_EOL);
} else {
echo $response['error'] . PHP_EOL;
}
?>