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? | |||||
switch ($type) { | |||||
case self::TYPE_ONEOFF: | |||||
return [ | |||||
[ | |||||
'id' => 'creditcard', | |||||
'name' => "Credit Card", | |||||
'minimumAmount' => "10.00", | |||||
'currency' => 'CHF', | |||||
'icon' => "credit-card" | |||||
], | |||||
[ | |||||
'id' => 'paypal', | |||||
'name' => "PayPal", | |||||
'minimumAmount' => "10.00", | |||||
'currency' => 'CHF', | |||||
'icon' => "paypal" | |||||
] | |||||
]; | |||||
case self::TYPE_RECURRING: | |||||
return [ | |||||
[ | |||||
'id' => 'creditcard', | |||||
'name' => "Credit Card", | |||||
'minimumAmount' => "10.00", | |||||
'currency' => 'CHF', | |||||
'icon' => "credit-card" | |||||
] | |||||
]; | |||||
} | |||||
} | |||||
/** | |||||
* 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?