From 07701779ff73e272dc599c7bd5594a4b83b06ae9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 6 Oct 2020 14:01:28 +1100 Subject: [PATCH] Add options property to gateway table --- app/Models/Gateway.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php index 5ab72a3b8147..801d4d5eec3e 100644 --- a/app/Models/Gateway.php +++ b/app/Models/Gateway.php @@ -26,6 +26,11 @@ class Gateway extends StaticModel 'created_at' => 'timestamp', 'default_gateway_type_id' => 'string', 'fields' => 'json', + 'options' => 'array', + ]; + + protected $appends = [ + 'options', ]; protected $dateFormat = 'Y-m-d H:i:s.u'; @@ -45,6 +50,12 @@ class Gateway extends StaticModel } } + public function getOptionsAttribute() + { + return $this->getMethods(); + } + + /** * Test if gateway is custom. * @return bool TRUE|FALSE @@ -83,4 +94,30 @@ class Gateway extends StaticModel //return $key != $str ? $str : ''; } + + /** + * Returns an array of methods and the gatewaytypes possible + * + * @return array + */ + public function getMethods() + { + switch ($this->id) { + case 1: + return ['methods' => [GatewayType::CREDIT_CARD], 'refund' => true, 'token_billing' => true ]; //Authorize.net + break; + case 15: + return ['methods' => [GatewayType::PAYPAL], 'refund' => true, 'token_billing' => false ]; //Paypal + break; + case 20: + return ['methods' => [GatewayType::CREDIT_CARD, GatewayType::BANK_TRANSFER, GatewayType::ALIPAY, GatewayType::APPLE_PAY], 'refund' => true, 'token_billing' => true ]; //Stripe + break; + case 39: + return ['methods' => [GatewayType::CREDIT_CARD], 'refund' => true, 'token_billing' => true ]; //Checkout + break; + default: + return []; + break; + } + } }