条纹不同的可能的电荷值 - >状态

时间:2018-03-03 14:27:44

标签: php stripe-payments

令牌是通过卡付款生成的。

$ charge->状态有哪些不同的值,知道任何失败都会因为异常而破坏代码。

    try {
        if (!isset($_POST['stripeToken']))
            throw new Exception('The Stripe Token was not generated correctly');

        $charge = \Stripe\Charge::create(array(
            "amount" => 1000,
            "currency" => "eur",
            "description" => "Basket items",
            "source" => $_POST['stripeToken'],
        ));


    } catch (Exception $e) {

        $error = $e->getMessage();

        show__errorPayment($error);

        exit;

    }

if($charge->status == 'succeeded') {
  // Payment done, inserting in db, making PDF invoice...etc...
}

我没有在文档中找到状态,例如" pending"。没有失败,但待决......

如果是这样,我必须在我的代码中使用它:

if($charge->status == 'succeeded') {
  // Payment done, inserting in db, making PDF invoice...etc...
} else if($charge->status == 'pending') {
  //To do...
}

0 个答案:

没有答案