[英]I am getting Received Unknown Parameter Source Error on Wix stripe recurring payment
我已经在 Wix 网站中集成了条带以进行条带定期付款,但是当我发送请求时,它显示错误:“收到未知参数来源”:! 这是我的帖子请求正文:
{
"customer": "cus_Fzo88vAVFgZpAu",
"items": {
"0": {
"plan": "prod_FznbhQKMCL2NCw"
}
},
"source": "tok_1FToWRDTT6jCg8kd1lxdqukE"
}
这是我的后端 function:
//stripe.jsw
import { fetch } from 'wix-fetch';
export async function subscription(token, item) {
const cart = item;
const apiKey = "sk_test_JHQ5ZDHh7iLrEvUAkHdw7ART001pdYVfam";
const response = await fetch("https://api.stripe.com/v1/subscriptions", {
method: 'post',
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Bearer " + apiKey
},
body: encodeBody(token, cart)
});
if (response.status >= 200 && response.status < 300) {
// transaction successful - get charge ID
const ret = await response.json();
return { "chargeId": ret.id };
}
// transaction failed - return error messages and codes
let res = await response.json();
let err = res.error.message;
let code = res.error.code;
let type = res.error.type;
return { "error": err, "code": code, "type": type };
}
function encodeBody(token, cart) {
let encoded = "";
for (let [k, v] of Object.entries(cart)) {
encoded = encoded.concat(k, "=", encodeURI(v), "&");
}
encoded = encoded.concat("source=", encodeURI(token));
return encoded;
}
根据订阅 API ,问题似乎是“源”不是可接受的参数。 相反,您需要在创建客户时传递您的源代码,即令牌。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.