POST /api/v1/accounts
Create Accounts
Creates a new account.
betaThis API is a pre-release. Please contact KOMOJU to obtain more usage instructions before using it.
サンプル
- cURL
- Node.js
- Ruby
curl -X POST https://komoju.com/api/v1/accounts \
-u sk_123456: \
-d "name=Submerchant" \
-d "default_currency=TWD" \
-d "time_zone=Europe/London"
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({
'name': 'Submerchant',
'default_currency': 'TWD',
'time_zone': 'Europe/London'
});
var post_options = {
host: 'komoju.com',
port: '443',
path: '/api/v1/accounts',
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/accounts')
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 = {
name: "Submerchant",
default_currency: "TWD",
time_zone: "Europe/London"
}
res = https.post(
uri.path,
body.to_json,
headers
)
puts res.body
{
"id": "0sf3wwxqv0vbuvxhur81yyw51",
"resource": "account",
"name": "Submerchant",
"default_currency": "TWD",
"time_zone": "Europe/London",
"live_merchant": "4nmn1oy49gllocv86ixgfqwvx",
"test_merchant": "1ugmg5i09mifg6zlyn2mzh3p7",
"accepted_service_agreement_at": null,
"accepted_service_agreement_ip": null,
"created_at": "2021-02-17T03:01:31Z",
"updated_at": "2021-02-17T03:01:31Z"
}
パラメータ
名前 | 説明 |
---|---|
name 必須 |
The unique name of the account. |
default_currency 必須 |
The three-letter ISO currency code serving as the default currency of the account. |
time_zone 必須 |
The time zone of the account. |