Changeset View
Changeset View
Standalone View
Standalone View
src/app/Providers/Payment/Stripe.php
Show First 20 Lines • Show All 464 Lines • ▼ Show 20 Lines | protected static function paymentMethod($details, $default = ''): string | ||||
'%s (**** **** **** %s)', | '%s (**** **** **** %s)', | ||||
\ucfirst($details->card->brand) ?: 'Card', | \ucfirst($details->card->brand) ?: 'Card', | ||||
$details->card->last4 | $details->card->last4 | ||||
); | ); | ||||
} | } | ||||
return $default; | return $default; | ||||
} | } | ||||
/** | |||||
* List supported payment methods. | |||||
* | |||||
* @param string $type type: oneoff/recurring | |||||
* | |||||
* @return array Array of array with available payment methods: | |||||
* - id: id of the method | |||||
* - name: User readable name of the payment method | |||||
* - minimumAmount: Minimum amount to be charged | |||||
* - currency: Currency used for the method | |||||
* - image|icon: An image (url) or icon (icon name) representing the method | |||||
*/ | |||||
public function paymentMethods($type): ?array | |||||
{ | |||||
//TODO get this from the stripe API? | |||||
$availableMethods = []; | |||||
switch ($type) { | |||||
case self::TYPE_ONEOFF: | |||||
$availableMethods = [ | |||||
self::METHOD_CREDITCARD => [ | |||||
'id' => self::METHOD_CREDITCARD, | |||||
'name' => "Credit Card", | |||||
'minimumAmount' => self::MIN_AMOUNT, | |||||
'currency' => 'CHF', | |||||
'exchangeRate' => 1.0 | |||||
], | |||||
self::METHOD_PAYPAL => [ | |||||
'id' => self::METHOD_PAYPAL, | |||||
'name' => "PayPal", | |||||
'minimumAmount' => self::MIN_AMOUNT, | |||||
'currency' => 'CHF', | |||||
'exchangeRate' => 1.0 | |||||
] | |||||
]; | |||||
break; | |||||
case self::TYPE_RECURRING: | |||||
$availableMethods = [ | |||||
self::METHOD_CREDITCARD => [ | |||||
'id' => self::METHOD_CREDITCARD, | |||||
'name' => "Credit Card", | |||||
'minimumAmount' => self::MIN_AMOUNT, // Converted to cents, | |||||
'currency' => 'CHF', | |||||
'exchangeRate' => 1.0 | |||||
] | |||||
]; | |||||
break; | |||||
} | |||||
return $this->applyMethodWhitelist($type, $availableMethods); | |||||
} | |||||
/** | |||||
* Get a payment. | |||||
* | |||||
* @param string $paymentId Payment identifier | |||||
* | |||||
* @return array|null Payment information: | |||||
* - id: Payment identifier | |||||
* - status: Payment status | |||||
* - isCancelable: The payment can be canceled | |||||
* - chceckoutUrl: The checkout url to complete the payment or null if non | |||||
*/ | |||||
public function getPayment($paymentId): ?array | |||||
{ | |||||
return [ | |||||
'id' => $paymentId, | |||||
'status' => null, | |||||
'isCancelable' => false, | |||||
'checkoutUrl' => null | |||||
]; | |||||
} | |||||
machniak: I know we do not use Stripe right now, but if we ever wanted to switch to it how do we know… | |||||
} | } |
I know we do not use Stripe right now, but if we ever wanted to switch to it how do we know that this needs to be implemented first?