我有PHP代码通过条带收取信用卡 我是php课程的初学者,所以我不知道如何判断付款是否成功
<?
require_once('lib/Stripe.php');
Stripe::setApiKey("sk_test_123ABC");
if(isset($_POST)) {
$payment = Stripe_Charge::create(array(
'amount' => '50',
'currency' => 'usd',
'card' => array(
'number'=> '4242424242424242',
'exp_month' => '12',
'exp_year'=> '14',
'cvc'=> '123'),
'description' => 'New payment'
)); }
print_r($payment);
?>
结果
Stripe_Charge Object
(
[_apiKey:protected] => sk_test_123ABC
[_values:protected] => Array
(
[id] => ch_157h99GwRVG4EfR7dCxslaAs
[object] => charge
[created] => 1418105445
[livemode] =>
[paid] => 1
[amount] => 50
[currency] => usd
[refunded] =>
[captured] => 1
[refunds] => Stripe_List Object
(
答案 0 :(得分:3)
您的问题有其答案。如果返回stripecharge对象的对象,则表示付款成功。
答案 1 :(得分:2)
抱歉,有没有办法专注于错误?以上仅确认收费是否成功。它没有说明拒绝的原因。
error:
message: "Your card has insufficient funds."
type: "card_error"
code: "card_declined"
charge: ch_12asdasweAAFdgooXDUd2tvKJgW
由于声誉较低,抱歉无法发表评论。 :(