POST /api/v1/secure_tokens
Create Secure Tokens

Create a new Secure Token. Navigate your customers to authentication_url and process 3D Secure 2.0. Note, we are currently expanding 3D Secure 2.0 support for merchants. This API might not be available on your merchants.

サンプル

  • cURL
  • Node.js
  • Ruby
curl -X POST https://komoju.com/api/v1/secure_tokens \
  -u sk_123456: \
  -d "amount=1000" \
  -d "currency=JPY" \
  -d "return_url=https://example.com/complete" \
  -d "payment_details[type]=credit_card" \
  -d "payment_details[email]=test@example.com" \
  -d "payment_details[number]=4100000000000100" \
  -d "payment_details[month]=08" \
  -d "payment_details[year]=2025" \
  -d "payment_details[verification_value]=123" \
  -d "payment_details[name]=Test Card" 
var querystring = require('querystring');
var https = require('https');
var secret_key = 'sk_123456'
var auth = 'Basic ' + Buffer.from(secret_key + ':').toString('base64');
var post_data = querystring.stringify({
  'amount': '1000',
  'currency': 'JPY',
  'return_url': 'https://example.com/complete',
  'payment_details[type]': 'credit_card',
  'payment_details[email]': 'test@example.com',
  'payment_details[number]': '4100000000000100',
  'payment_details[month]': '08',
  'payment_details[year]': '2025',
  'payment_details[verification_value]': '123',
  'payment_details[name]': 'Test Card'
});

var post_options = {
  host: 'komoju.com',
  port: '443',
  path: '/api/v1/secure_tokens',
  method: 'POST',
  headers: {
    'Authorization': auth,
    'Content-Length': Buffer.byteLength(post_data)
  }
};

var post_req = https.request(post_options, function(res) {
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
        console.log(chunk);
    });
});

post_req.write(post_data);
post_req.end();
require 'uri'
require 'net/https'
require 'json'
require 'base64'
require 'pp'
uri = URI.parse('https://komoju.com/api/v1/secure_tokens')
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
secret_key = 'sk_123456'
auth = Base64.encode64("#{secret_key}:")
headers = {
  'Content-Type' => 'application/json',
  'Authorization' => "Basic #{auth}"
}

body = {
  amount: "1000",
  currency: "JPY",
  return_url: "https://example.com/complete",
  payment_details: {
    type: "credit_card",
    email: "test@example.com",
    number: "4100000000000100",
    month: "08",
    year: "2025",
    verification_value: "123",
    name: "Test Card"
  }
}

res = https.post(
  uri.path,
  body.to_json,
  headers
)

puts res.body
{
  "id": "tok_1234567890abcdefghijklmnop",
  "verification_status": "NEEDS_VERIFY",
  "created_at": "2022-05-18T09:03:57Z",
  "authentication_url": "https://hats.localhost.labs.degica.com/three_d_secure/offsite?token=tok_1234567890abcdefghijklmnop"
}

パラメータ

名前 説明
amount
必須

The amount to be charged before tax. Must be equal or greater than 0, without thousands separator. The amount cannot be a decimal value. For example, for an amount of 10 and currency of EUR, the payment will be 0.10 EUR.

currency
必須

3 letter ISO currency code used to pay.

return_url
必須

The URL where customers are redirected after a payment has been completed.

payment_details
必須

A hash or token describing the payment method used to make the payment