Changeset View
Changeset View
Standalone View
Standalone View
src/app/Providers/Payment/Mollie.php
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | class Mollie 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 (optional) | * - amount: Value in cents (optional) | ||||
* - currency: The operation currency | * - currency: The operation currency | ||||
* - description: Operation desc. | * - description: Operation desc. | ||||
* - methodId: Payment method | * - methodId: Payment method | ||||
* - redirectUrl: The location to goto after checkout | |||||
* | * | ||||
* @return array Provider payment data: | * @return array Provider payment data: | ||||
* - id: Operation identifier | * - id: Operation identifier | ||||
* - redirectUrl: the location to redirect to | * - redirectUrl: the location to redirect to | ||||
*/ | */ | ||||
public function createMandate(Wallet $wallet, array $payment): ?array | public function createMandate(Wallet $wallet, array $payment): ?array | ||||
{ | { | ||||
// Register the user in Mollie, if not yet done | // Register the user in Mollie, if not yet done | ||||
Show All 10 Lines | public function createMandate(Wallet $wallet, array $payment): ?array | ||||
'amount' => [ | 'amount' => [ | ||||
'currency' => $payment['currency'], | 'currency' => $payment['currency'], | ||||
'value' => sprintf('%.2f', $amount / 100), | 'value' => sprintf('%.2f', $amount / 100), | ||||
], | ], | ||||
'customerId' => $customer_id, | 'customerId' => $customer_id, | ||||
'sequenceType' => 'first', | 'sequenceType' => 'first', | ||||
'description' => $payment['description'], | 'description' => $payment['description'], | ||||
'webhookUrl' => Utils::serviceUrl('/api/webhooks/payment/mollie'), | 'webhookUrl' => Utils::serviceUrl('/api/webhooks/payment/mollie'), | ||||
'redirectUrl' => self::redirectUrl(), | 'redirectUrl' => $payment['redirectUrl'] ?? self::redirectUrl(), | ||||
'locale' => 'en_US', | 'locale' => 'en_US', | ||||
'method' => $payment['methodId'] | 'method' => $payment['methodId'] | ||||
]; | ]; | ||||
// Create the payment in Mollie | // Create the payment in Mollie | ||||
$response = mollie()->payments()->create($request); | $response = mollie()->payments()->create($request); | ||||
if ($response->mandateId) { | if ($response->mandateId) { | ||||
▲ Show 20 Lines • Show All 538 Lines • Show Last 20 Lines |