PATCH /api/v1/customers/:id
Update Customers
Updates the customer with the given id
. A new set of payment_details
may be specified.
サンプル
- cURL
- Node.js
- Ruby
curl -X PATCH https://komoju.com/api/v1/customers/5idn4n9ll38ovn1657478mtbw \
-u sk_123456: \
-d "payment_details=tok_dnma6a58sobtp46ef350grao8"
var querystring = require('querystring');
var https = require('https');
var secret_key = 'sk_123456'
var auth = 'Basic ' + Buffer.from(secret_key + ':').toString('base64');
var patch_data = querystring.stringify({
'payment_details': 'tok_dnma6a58sobtp46ef350grao8'
});
var patch_options = {
host: 'komoju.com',
port: '443',
path: '/api/v1/customers/5idn4n9ll38ovn1657478mtbw',
method: 'PATCH',
headers: {
'Authorization': auth,
'Content-Length': Buffer.byteLength(patch_data)
}
};
var patch_req = https.request(patch_options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log(chunk);
});
});
patch_req.write(patch_data);
patch_req.end();
require 'uri'
require 'net/https'
require 'json'
require 'base64'
require 'pp'
uri = URI.parse('https://komoju.com/api/v1/customers/5idn4n9ll38ovn1657478mtbw')
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 = {
payment_details: "tok_dnma6a58sobtp46ef350grao8"
}
res = https.patch(
uri.path,
body.to_json,
headers
)
puts res.body
{
"id": "5idn4n9ll38ovn1657478mtbw",
"resource": "customer",
"email": "mathilda@grimes.net",
"source": {
"type": "credit_card",
"brand": "visa",
"last_four_digits": "1111",
"month": 1,
"year": 2025
},
"metadata": {
"order_id": "abcdefg"
},
"created_at": "2020-06-09T07:41:51Z"
}
パラメータ
名前 | 説明 |
---|---|
currency 任意 |
3 letter ISO currency code used to pay. |
payment_details 任意 |
A hash or token describing the payment method used to make the payment. This or |
email 任意 |
Customer's email address. |
metadata 任意 |
A set of key-value pairs. |