Php 您提供的源未处于收费状态
我正在尝试设置stripe微信,但我遇到了一个问题“致命错误:您提供的源未处于收费状态。已被抛出”。有什么问题吗Php 您提供的源未处于收费状态,php,stripe-payments,Php,Stripe Payments,我正在尝试设置stripe微信,但我遇到了一个问题“致命错误:您提供的源未处于收费状态。已被抛出”。有什么问题吗 stripe.createSource({ type: 'wechat', amount: sum*100, currency: 'eur', }).then(function(result) { console.log(result) $('#wee-wee-chat').prop('href', result.source.wechat.qr_code_
stripe.createSource({
type: 'wechat',
amount: sum*100,
currency: 'eur',
}).then(function(result) {
console.log(result)
$('#wee-wee-chat').prop('href', result.source.wechat.qr_code_url)
$.ajax({
url: 'index.php?route=module/StripePayment/create',
type: 'post',
dataType: 'json',
data: JSON.stringify({...purchase, ...result.source, ...price}),
success: function (json) {
console.log(purchase)
clientSecret = String(result.source.client_secret);
some = json.some;
}, error: function(e){
console.log(e)
}
});
}).then(function(result){
console.log(result)
}).catch(function(err){
console.log(err)
})
您在尝试收费之前是否验证了来源?您好kmdfm,如果不看到您的代码,就不可能理解正在发生的事情。请发布一个最小的可复制示例。您好!我已经发布了一个例子。
php
try {
// retrieve JSON from POST body
$json_str = file_get_contents('php://input');
$json_obj = json_decode($json_str);
$charge = \Stripe\Charge::create([
'amount' => $json_obj->price,
'currency' => 'eur',
'source' => $json_obj->id,
]);
echo json_encode($output);
} catch (Error $e) {
http_response_code(500);
echo json_encode(['error' => $e->getMessage()]);
}