[英]How to cancel the stripe payment and debit the money to client account
您好,我正在使用以下代碼進行交易
require_once('Stripe/lib/Stripe.php');
Stripe::setApiKey("<Api key>");
$customer = Stripe_Charge::create(array(
"amount" => 1500,
"currency" => "usd",
"card" => $_POST['stripeToken'],
"description" => "Charge for Facebook Login code."
));
echo "<pre>";print_r($customer);die;
// Charge the Customer instead of the card
$charge = Stripe_Charge::create(array(
"amount" => 1500,
"currency" => "usd",
"customer" => $customer->id)
);
echo 'Transaction Id '.$charge->id;
我有一個取消按鈕,如果我點擊用戶完成的付款將返回到客戶帳戶
您很可能需要退還從卡中收取的款項,然后使用“取消”按鈕向客戶收取費用。
這可以按如下方式完成:
(1) 檢索費用的標識符:
$charge = \Stripe\Charge::create(array(
...
));
// you can use the var_dump function to see what's inside the $charge object
// var_dump($charge);
$chargeID = $charge->id;
(2) 退款給用戶:
$re = \Stripe\Refund::create(array(
"charge" => $chargeID
));
(3) 向客戶收費:
// Charge the Customer instead of the card
$charge = Stripe_Charge::create(array(
"amount" => 1500,
"currency" => "usd",
"customer" => $customer->id)
);
echo 'Transaction Id '.$charge->id;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.