H
H
hikkan_no_12021-04-26 10:49:01
PHP
hikkan_no_1, 2021-04-26 10:49:01

I'm trying to set up WeChat payments Stripe, but an error pops up?

I'm trying to set up WeChat payments Stripe. But the following error pops up "Fatal error: The source you provided is not in a chargeable state thrown". Can you please tell me what could be causing this error?

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)
})

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

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question