Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 您提供的源未处于收费状态_Php_Stripe Payments - Fatal编程技术网

Php 您提供的源未处于收费状态

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微信,但我遇到了一个问题“致命错误:您提供的源未处于收费状态。已被抛出”。有什么问题吗

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()]);
}