Changeset View
Changeset View
Standalone View
Standalone View
src/app/Providers/Payment/Stripe.php
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | class Stripe extends \App\Providers\PaymentProvider | ||||
/** | /** | ||||
* Create a new auto-payment mandate for a wallet. | * Create a new auto-payment mandate for a wallet. | ||||
* | * | ||||
* @param \App\Wallet $wallet The wallet | * @param \App\Wallet $wallet The wallet | ||||
* @param array $payment Payment data: | * @param array $payment Payment data: | ||||
* - amount: Value in cents (not used) | * - amount: Value in cents (not used) | ||||
* - currency: The operation currency | * - currency: The operation currency | ||||
* - description: Operation desc. | * - description: Operation desc. | ||||
* - redirectUrl: The location to goto after checkout | |||||
* | * | ||||
* @return array Provider payment/session data: | * @return array Provider payment/session data: | ||||
* - id: Session identifier | * - id: Session identifier | ||||
*/ | */ | ||||
public function createMandate(Wallet $wallet, array $payment): ?array | public function createMandate(Wallet $wallet, array $payment): ?array | ||||
{ | { | ||||
// Register the user in Stripe, if not yet done | // Register the user in Stripe, if not yet done | ||||
$customer_id = self::stripeCustomerId($wallet, true); | $customer_id = self::stripeCustomerId($wallet, true); | ||||
$request = [ | $request = [ | ||||
'customer' => $customer_id, | 'customer' => $customer_id, | ||||
'cancel_url' => self::redirectUrl(), // required | 'cancel_url' => $payment['redirectUrl'] ?? self::redirectUrl(), // required | ||||
'success_url' => self::redirectUrl(), // required | 'success_url' => $payment['redirectUrl'] ?? self::redirectUrl(), // required | ||||
'payment_method_types' => ['card'], // required | 'payment_method_types' => ['card'], // required | ||||
'locale' => 'en', | 'locale' => 'en', | ||||
'mode' => 'setup', | 'mode' => 'setup', | ||||
]; | ]; | ||||
// Note: Stripe does not allow to set amount for 'setup' operation | // Note: Stripe does not allow to set amount for 'setup' operation | ||||
// We'll dispatch WalletCharge job when we receive a webhook request | // We'll dispatch WalletCharge job when we receive a webhook request | ||||
▲ Show 20 Lines • Show All 472 Lines • Show Last 20 Lines |