【问题标题】:Laravel 7.0 Cashier - Stripe Payment ExceptionLaravel 7.0 Cashier - 条纹支付异常
【发布时间】:2020-11-08 00:37:02
【问题描述】:

我在使用 Laravel Cashier Stripe 付款时遇到问题。我需要将费用和新订阅合二为一,这样当出现 IncompletePayment 异常时,我仍然可以获得条带 webhook。

try{
  $user->charge(1000, $creditCard->id, [
                'description' => 'Premium Registration',
            ])
  $user->newSubscription('premium_member', $recurring)
          ->create($creditCard->id);

}
} catch (IncompletePayment $e) {

            $intent = \Stripe\PaymentIntent::retrieve($e->payment->id);
            $intent->confirm([
                'return_url' => url('api/payments-3d-success'),
            ]);

            return response()->json([
                'e' => $intent,
            ]);
        }

另一种方法是捕获异常并构建类似 laravel 的方式来处理不完整的异常。

try{

  $subscription = \Stripe\Subscription::create([
                'customer' => $customer->id,
                'items' => [[
                    'price' => $recurring,
                ]],
                'add_invoice_items' => [[
                    'price' => $oneTime,
                ]],
            ]);

}
//I need to catch the exception here from stripe and build like a laravel way like IncompletePayment exceptions
catch(Exception $e){
$intent = \Stripe\PaymentIntent::retrieve($e->payment->id);
            $intent->confirm([
                'return_url' => url('api/payments-3d-success'),
            ]);

            return response()->json([
                'e' => $intent,
            ]);
}

请告诉我你是如何处理这个问题的。谢谢

【问题讨论】:

    标签: php stripe-payments


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 2020-03-26
      • 1970-01-01
      • 1970-01-01
      • 2018-07-26
      • 2017-09-14
      • 2021-08-02
      • 2020-12-30
      • 1970-01-01
      • 2021-01-13
      相关资源
      最近更新 更多