diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index ca7201960326..cb56c2e60019 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -787,6 +787,27 @@ class CreateSingleAccount extends Command $cg->fees_and_limits = $fees_and_limits; $cg->save(); } + + if (config('ninja.testvars.square') && ($this->gateway == 'all' || $this->gateway == 'square')) { + $cg = new CompanyGateway; + $cg->company_id = $company->id; + $cg->user_id = $user->id; + $cg->gateway_key = '65faab2ab6e3223dbe848b1686490baz'; + $cg->require_cvv = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; + $cg->update_details = true; + $cg->config = encrypt(config('ninja.testvars.square')); + $cg->save(); + + $gateway_types = $cg->driver(new Client)->gatewayTypes(); + + $fees_and_limits = new stdClass; + $fees_and_limits->{$gateway_types[0]} = new FeesAndLimits; + + $cg->fees_and_limits = $fees_and_limits; + $cg->save(); + } } private function createRecurringInvoice($client) diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php index 424d3b843486..573ac39c5f8f 100644 --- a/app/Models/Gateway.php +++ b/app/Models/Gateway.php @@ -81,9 +81,13 @@ class Gateway extends StaticModel case 1: return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true]];//Authorize.net break; - case 1: + case 11: return [GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => false]];//Payfast break; + case 7: + return [ + GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true], // Mollie + ]; case 15: return [GatewayType::PAYPAL => ['refund' => true, 'token_billing' => false]]; //Paypal break; @@ -110,11 +114,12 @@ class Gateway extends StaticModel GatewayType::PAYPAL => ['refund' => true, 'token_billing' => true] ]; break; - case 7: + case 57: return [ - GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => true], // Mollie + GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true], //Square ]; break; + break; default: return []; break; diff --git a/app/PaymentDrivers/SquarePaymentDriver.php b/app/PaymentDrivers/SquarePaymentDriver.php index 10647bf54992..d500e420f9ef 100644 --- a/app/PaymentDrivers/SquarePaymentDriver.php +++ b/app/PaymentDrivers/SquarePaymentDriver.php @@ -30,22 +30,22 @@ class SquarePaymentDriver extends BaseDriver public $can_authorise_credit_card = true; //does this gateway support authorizations? - public $square; //initialized gateway + public $square; - public $payment_method; //initialized payment method + public $payment_method; public static $methods = [ GatewayType::CREDIT_CARD => CreditCard::class, //maps GatewayType => Implementation class ]; - const SYSTEM_LOG_TYPE = SystemLog::TYPE_SQUARE; //define a constant for your gateway ie TYPE_YOUR_CUSTOM_GATEWAY - set the const in the SystemLog model + const SYSTEM_LOG_TYPE = SystemLog::TYPE_SQUARE; public function init() { $this->square = new Square\SquareClient([ - 'accessToken' => 'EAAAEHeoSxEUZWXCd0makP0-HA0V4OLZ-S-T2Gmc91llp08ColiOX9NpP-LQZIId', - 'environment' => Square\Environment::SANDBOX, + 'accessToken' => $this->company_gateway->getConfigField('accessToken'), + 'environment' => $this->company_gateway->getConfigField('testMode') ? Square\Environment::SANDBOX : Square\Environment::PRODUCTION, ]); return $this; /* This is where you boot the gateway with your auth credentials*/ diff --git a/config/ninja.php b/config/ninja.php index eb3f54f5b066..321ec8e009f6 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -90,6 +90,7 @@ return [ 'decrypted' => env('PAYTRACE_KEYS', ''), ], 'mollie' => env('MOLLIE_KEYS', ''), + 'square' => env('SQUARE_KEYS',''), ], 'contact' => [ 'email' => env('MAIL_FROM_ADDRESS'), diff --git a/database/seeders/PaymentLibrariesSeeder.php b/database/seeders/PaymentLibrariesSeeder.php index c74ab2940ae8..df2ded688cc1 100644 --- a/database/seeders/PaymentLibrariesSeeder.php +++ b/database/seeders/PaymentLibrariesSeeder.php @@ -80,6 +80,7 @@ class PaymentLibrariesSeeder extends Seeder ['id' => 53, 'name' => 'PagSeguro', 'provider' => 'PagSeguro', 'key' => 'ef498756b54db63c143af0ec433da803', 'fields' => '{"email":"","token":"","sandbox":false}'], ['id' => 54, 'name' => 'PAYMILL', 'provider' => 'Paymill', 'key' => 'ca52f618a39367a4c944098ebf977e1c', 'fields' => '{"apiKey":""}'], ['id' => 55, 'name' => 'Custom', 'provider' => 'Custom', 'is_offsite' => true, 'sort_order' => 21, 'key' => '54faab2ab6e3223dbe848b1686490baa', 'fields' => '{"name":"","text":""}'], + ['id' => 57, 'name' => 'Square', 'provider' => 'Square', 'is_offsite' => false, 'sort_order' => 21, 'key' => '65faab2ab6e3223dbe848b1686490baz', 'fields' => '{"accessToken":"","applicationId":"","locationId":"","testMode":"false"}'], ]; foreach ($gateways as $gateway) { @@ -96,7 +97,7 @@ class PaymentLibrariesSeeder extends Seeder Gateway::query()->update(['visible' => 0]); - Gateway::whereIn('id', [1,7,15,20,39,46,55,50])->update(['visible' => 1]); + Gateway::whereIn('id', [1,7,15,20,39,46,55,50,57])->update(['visible' => 1]); if (Ninja::isHosted()) { Gateway::whereIn('id', [20])->update(['visible' => 0]); diff --git a/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php b/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php new file mode 100644 index 000000000000..e3a431097476 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php @@ -0,0 +1,57 @@ +@extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.payment_type_credit_card'), 'card_title' +=> ctrans('texts.payment_type_credit_card')]) + +@section('gateway_head') +@endsection + +@section('gateway_content') +
+ @csrf + + + + + + + + @component('portal.ninja2020.components.general.card-element-single') +
+ +
+ +
+ @endcomponent + +@endsection + +@section('gateway_footer') + +. + + + @endsection \ No newline at end of file