我想使用 https 库通过 https 调用连接 Stripe API。
var https = require('https');
我已经获得了密钥和可发布密钥并将其放在一个对象中:
var stripe = {
secret_key: 'secret_key_given_in_the_dashboard',
publishable_key: 'publishable_key_given_in_the_dashboard'
}
我现在正在创建 requestDetail 对象:
var requestDetails = {
'protocol' : 'https:',
'hostname' : 'api.stripe.com',
'method' : 'POST', //WHICH OF POST GET PUT DELETE SHOULD I USE?
'path' : '???????????????????????',// WHICH ENDPOINT SHOULD I USE?
'auth' : '???????????????????????',// SHOULD I USE THE SECRET AND PUBLISHABLE KEY HERE?
'headers' : {
'Content-Type' : 'application/x-www-form-urlencoded',
'Content-Length' : Buffer.byteLength(stringPayload)
}
};
我计划在使用 https 的调用中使用 requestDetails 对象:
var req = https.request(requestDetails, function(res){
// Grab the status of the sent request
var status = res.statusCode;
//Callback successfully if the request went through
if(status == 200 || status == 201) {
callback(false);
} else {
callback('Status code returned was ' + status);
}
});
我应该在哪里以及如何使用密钥和可发布密钥来调用条带 API?哪个端点?哪种方法(POST、GET、PUT 或 DELETE)?
我想最终创建一个订单并通过 STRIPE api 付款。但是现在,只要通过条带 api 进行任何经过身份验证的调用就可以了,因为我需要一个有效的示例格式......我不太确定在哪里添加密钥和可发布密钥......