Changeset View
Changeset View
Standalone View
Standalone View
src/app/Providers/Payment/Stripe.php
Show First 20 Lines • Show All 477 Lines • ▼ Show 20 Lines | protected static function paymentMethod($details, $default = ''): string | ||||
} | } | ||||
return $default; | return $default; | ||||
} | } | ||||
/** | /** | ||||
* List supported payment methods. | * List supported payment methods. | ||||
* | * | ||||
* @param string $type The payment type for which we require a method (oneoff/recurring). | * @param string $type The payment type for which we require a method (oneoff/recurring). | ||||
* @param string $currency Currency code | |||||
* | * | ||||
* @return array Array of array with available payment methods: | * @return array Array of array with available payment methods: | ||||
* - id: id of the method | * - id: id of the method | ||||
* - name: User readable name of the payment method | * - name: User readable name of the payment method | ||||
* - minimumAmount: Minimum amount to be charged in cents | * - minimumAmount: Minimum amount to be charged in cents | ||||
* - currency: Currency used for the method | * - currency: Currency used for the method | ||||
* - exchangeRate: The projected exchange rate (actual rate is determined during payment) | * - exchangeRate: The projected exchange rate (actual rate is determined during payment) | ||||
* - icon: An icon (icon name) representing the method | * - icon: An icon (icon name) representing the method | ||||
*/ | */ | ||||
public function providerPaymentMethods($type): array | public function providerPaymentMethods(string $type, string $currency): array | ||||
{ | { | ||||
//TODO get this from the stripe API? | //TODO get this from the stripe API? | ||||
$availableMethods = []; | $availableMethods = []; | ||||
switch ($type) { | switch ($type) { | ||||
case self::TYPE_ONEOFF: | case self::TYPE_ONEOFF: | ||||
$availableMethods = [ | $availableMethods = [ | ||||
self::METHOD_CREDITCARD => [ | self::METHOD_CREDITCARD => [ | ||||
'id' => self::METHOD_CREDITCARD, | 'id' => self::METHOD_CREDITCARD, | ||||
'name' => "Credit Card", | 'name' => "Credit Card", | ||||
'minimumAmount' => self::MIN_AMOUNT, | 'minimumAmount' => self::MIN_AMOUNT, | ||||
'currency' => 'CHF', | 'currency' => $currency, | ||||
'exchangeRate' => 1.0 | 'exchangeRate' => 1.0 | ||||
], | ], | ||||
self::METHOD_PAYPAL => [ | self::METHOD_PAYPAL => [ | ||||
'id' => self::METHOD_PAYPAL, | 'id' => self::METHOD_PAYPAL, | ||||
'name' => "PayPal", | 'name' => "PayPal", | ||||
'minimumAmount' => self::MIN_AMOUNT, | 'minimumAmount' => self::MIN_AMOUNT, | ||||
'currency' => 'CHF', | 'currency' => $currency, | ||||
'exchangeRate' => 1.0 | 'exchangeRate' => 1.0 | ||||
] | ] | ||||
]; | ]; | ||||
break; | break; | ||||
case self::TYPE_RECURRING: | case self::TYPE_RECURRING: | ||||
$availableMethods = [ | $availableMethods = [ | ||||
self::METHOD_CREDITCARD => [ | self::METHOD_CREDITCARD => [ | ||||
'id' => self::METHOD_CREDITCARD, | 'id' => self::METHOD_CREDITCARD, | ||||
'name' => "Credit Card", | 'name' => "Credit Card", | ||||
'minimumAmount' => self::MIN_AMOUNT, // Converted to cents, | 'minimumAmount' => self::MIN_AMOUNT, // Converted to cents, | ||||
'currency' => 'CHF', | 'currency' => $currency, | ||||
'exchangeRate' => 1.0 | 'exchangeRate' => 1.0 | ||||
] | ] | ||||
]; | ]; | ||||
break; | break; | ||||
} | } | ||||
return $availableMethods; | return $availableMethods; | ||||
} | } | ||||
Show All 25 Lines |