use*_*235 4 heroku node.js stripe-payments
你好,我现在在文档 https://stripe.com/docs/connect/standalone-accounts#token-request
所以我的问题是我不知道如何在节点中发出 Post 请求,
我尝试了很多例子,但无法得到它。有人能指导我正确的方向吗,谢谢。
编辑
这是我试过的
var app = express();
var server = app.listen(process.env.PORT || 3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
request.post(
'https://connect.stript.com/oauth/token', {
form: {
client_secret: "sk_test_QWnyIomfd2glLk9whe6gOC4f",
code: "AUTHORIZATION_CODE",
grant_type: "authorization_code",
}
},
function (error, response, body) {
console.log(response)
if (!error && response.statusCode == 200) {
console.log(body)
}
}
);
Run Code Online (Sandbox Code Playgroud)
这就是我跳过帐户表格时得到的
Cannot GET /?scope=read_write&code=ac_6B0uydoV7XrniZrssm3m2sivUx49cA8M
Run Code Online (Sandbox Code Playgroud)
您得到的原因Cannot GET /?scope=read_write&code=ac_6B0uydoV7XrniZrssm3m2sivUx49cA8M是,当条带尝试重定向到在平台设置下设置的重定向 URI 时,您可能没有设置重定向 URI,当条带以以下方式将代码发送到您的 url 时也有处理
app.get('/redirecurlforstripe',function(req,res){
var params = req.body; // or req.params.query; see which one works for you
request.post(
'https://connect.stript.com/oauth/token', {
form: {
client_secret: "sk_test_QWnyIomfd2glLk9whe6gOC4f",
code: params.code, //this will be the authorization code coming from stripe
,
grant_type: "authorization_code",
}
},
function (error, response, body) {
console.log(response)
if (!error && response.statusCode == 200) {
console.log(body)
}
}
);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1572 次 |
| 最近记录: |