v1.7 beta.8

This commit is contained in:
carodej
2020-07-20 08:54:57 +02:00
parent 827b34e1dd
commit 6f95fc2565
17 changed files with 149 additions and 29 deletions
+11 -1
View File
@@ -8,6 +8,7 @@ use Artisan;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use Laravel\Cashier\Exceptions\IncompletePayment;
use Laravel\Cashier\Exceptions\PaymentActionRequired;
use Stripe;
use Symfony\Component\HttpKernel\Exception\HttpException;
@@ -116,6 +117,7 @@ class StripeService
* @param $request
* @param $user
* @param $paymentMethod
* @return \Illuminate\Http\RedirectResponse
*/
public function createOrReplaceSubscription($request, $user)
{
@@ -138,7 +140,15 @@ class StripeService
} catch (IncompletePayment $exception) {
throw new HttpException(400, 'We can\'t charge your card');
if ($exception instanceof PaymentActionRequired) {
$cashier_route = route('cashier.payment', [$exception->payment->id, 'redirect' => url('/settings/subscription')]);
throw new HttpException(402, $cashier_route);
} else {
throw new HttpException(400, $exception->getMessage());
}
}
}