Changeset View
Changeset View
Standalone View
Standalone View
src/app/Providers/PaymentProvider.php
<?php | <?php | ||||
namespace App\Providers; | namespace App\Providers; | ||||
use App\Transaction; | |||||
use App\Payment; | use App\Payment; | ||||
use App\Transaction; | |||||
use App\Wallet; | use App\Wallet; | ||||
use Illuminate\Support\Facades\Cache; | use Illuminate\Support\Facades\Cache; | ||||
abstract class PaymentProvider | abstract class PaymentProvider | ||||
{ | { | ||||
public const STATUS_OPEN = 'open'; | |||||
public const STATUS_CANCELED = 'canceled'; | |||||
public const STATUS_PENDING = 'pending'; | |||||
public const STATUS_AUTHORIZED = 'authorized'; | |||||
public const STATUS_EXPIRED = 'expired'; | |||||
public const STATUS_FAILED = 'failed'; | |||||
public const STATUS_PAID = 'paid'; | |||||
public const TYPE_ONEOFF = 'oneoff'; | |||||
public const TYPE_RECURRING = 'recurring'; | |||||
public const TYPE_MANDATE = 'mandate'; | |||||
public const TYPE_REFUND = 'refund'; | |||||
public const TYPE_CHARGEBACK = 'chargeback'; | |||||
public const METHOD_CREDITCARD = 'creditcard'; | public const METHOD_CREDITCARD = 'creditcard'; | ||||
public const METHOD_PAYPAL = 'paypal'; | public const METHOD_PAYPAL = 'paypal'; | ||||
public const METHOD_BANKTRANSFER = 'banktransfer'; | public const METHOD_BANKTRANSFER = 'banktransfer'; | ||||
public const METHOD_DIRECTDEBIT = 'directdebit'; | public const METHOD_DIRECTDEBIT = 'directdebit'; | ||||
public const METHOD_BITCOIN = 'bitcoin'; | public const METHOD_BITCOIN = 'bitcoin'; | ||||
public const PROVIDER_MOLLIE = 'mollie'; | public const PROVIDER_MOLLIE = 'mollie'; | ||||
public const PROVIDER_STRIPE = 'stripe'; | public const PROVIDER_STRIPE = 'stripe'; | ||||
public const PROVIDER_COINBASE = 'coinbase'; | public const PROVIDER_COINBASE = 'coinbase'; | ||||
/** const int Minimum amount of money in a single payment (in cents) */ | |||||
public const MIN_AMOUNT = 1000; | |||||
private static $paymentMethodIcons = [ | private static $paymentMethodIcons = [ | ||||
self::METHOD_CREDITCARD => ['prefix' => 'far', 'name' => 'credit-card'], | self::METHOD_CREDITCARD => ['prefix' => 'far', 'name' => 'credit-card'], | ||||
self::METHOD_PAYPAL => ['prefix' => 'fab', 'name' => 'paypal'], | self::METHOD_PAYPAL => ['prefix' => 'fab', 'name' => 'paypal'], | ||||
self::METHOD_BANKTRANSFER => ['prefix' => 'fas', 'name' => 'building-columns'], | self::METHOD_BANKTRANSFER => ['prefix' => 'fas', 'name' => 'building-columns'], | ||||
self::METHOD_BITCOIN => ['prefix' => 'fab', 'name' => 'bitcoin'], | self::METHOD_BITCOIN => ['prefix' => 'fab', 'name' => 'bitcoin'], | ||||
]; | ]; | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | abstract class PaymentProvider | ||||
* @param string $type The payment type for which we require a method. | * @param string $type The payment type for which we require a method. | ||||
* | * | ||||
* @return array Array of methods | * @return array Array of methods | ||||
*/ | */ | ||||
protected static function paymentMethodsWhitelist($type): array | protected static function paymentMethodsWhitelist($type): array | ||||
{ | { | ||||
$methods = []; | $methods = []; | ||||
switch ($type) { | switch ($type) { | ||||
case self::TYPE_ONEOFF: | case Payment::TYPE_ONEOFF: | ||||
$methods = explode(',', \config('app.payment.methods_oneoff')); | $methods = explode(',', \config('app.payment.methods_oneoff')); | ||||
break; | break; | ||||
case PaymentProvider::TYPE_RECURRING: | case Payment::TYPE_RECURRING: | ||||
$methods = explode(',', \config('app.payment.methods_recurring')); | $methods = explode(',', \config('app.payment.methods_recurring')); | ||||
break; | break; | ||||
default: | default: | ||||
\Log::error("Unknown payment type: " . $type); | \Log::error("Unknown payment type: " . $type); | ||||
} | } | ||||
$methods = array_map('strtolower', array_map('trim', $methods)); | $methods = array_map('strtolower', array_map('trim', $methods)); | ||||
return $methods; | return $methods; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines |