private function createGateways()
 {
     $gateways = [['name' => 'BeanStream', 'provider' => 'BeanStream', 'payment_library_id' => 2], ['name' => 'Psigate', 'provider' => 'Psigate', 'payment_library_id' => 2], ['name' => 'moolah', 'provider' => 'AuthorizeNet_AIM', 'sort_order' => 1, 'recommended' => 1, 'site_url' => 'https://invoiceninja.mymoolah.com/', 'payment_library_id' => 1], ['name' => 'Alipay', 'provider' => 'Alipay_Express', 'payment_library_id' => 1], ['name' => 'Buckaroo', 'provider' => 'Buckaroo_CreditCard', 'payment_library_id' => 1], ['name' => 'Coinbase', 'provider' => 'Coinbase', 'payment_library_id' => 1], ['name' => 'DataCash', 'provider' => 'DataCash', 'payment_library_id' => 1], ['name' => 'Neteller', 'provider' => 'Neteller', 'payment_library_id' => 2], ['name' => 'Pacnet', 'provider' => 'Pacnet', 'payment_library_id' => 1], ['name' => 'PaymentSense', 'provider' => 'PaymentSense', 'payment_library_id' => 1], ['name' => 'Realex', 'provider' => 'Realex_Remote', 'payment_library_id' => 1], ['name' => 'Sisow', 'provider' => 'Sisow', 'payment_library_id' => 1], ['name' => 'Skrill', 'provider' => 'Skrill', 'payment_library_id' => 1], ['name' => 'BitPay', 'provider' => 'BitPay', 'payment_library_id' => 1], ['name' => 'Dwolla', 'provider' => 'Dwolla', 'payment_library_id' => 1], ['name' => 'Eway Rapid', 'provider' => 'Eway_RapidShared', 'payment_library_id' => 1], ['name' => 'AGMS', 'provider' => 'Agms', 'payment_library_id' => 1], ['name' => 'Barclays', 'provider' => 'BarclaysEpdq\\Essential', 'payment_library_id' => 1], ['name' => 'Cardgate', 'provider' => 'Cardgate', 'payment_library_id' => 1], ['name' => 'Checkout.com', 'provider' => 'CheckoutCom', 'payment_library_id' => 1], ['name' => 'Creditcall', 'provider' => 'Creditcall', 'payment_library_id' => 1], ['name' => 'Cybersource', 'provider' => 'Cybersource', 'payment_library_id' => 1], ['name' => 'ecoPayz', 'provider' => 'Ecopayz', 'payment_library_id' => 1], ['name' => 'Fasapay', 'provider' => 'Fasapay', 'payment_library_id' => 1], ['name' => 'Komoju', 'provider' => 'Komoju', 'payment_library_id' => 1], ['name' => 'Multicards', 'provider' => 'Multicards', 'payment_library_id' => 1], ['name' => 'Pagar.Me', 'provider' => 'Pagarme', 'payment_library_id' => 1], ['name' => 'Paysafecard', 'provider' => 'Paysafecard', 'payment_library_id' => 1], ['name' => 'Paytrace', 'provider' => 'Paytrace_CreditCard', 'payment_library_id' => 1], ['name' => 'Secure Trading', 'provider' => 'SecureTrading', 'payment_library_id' => 1], ['name' => 'SecPay', 'provider' => 'SecPay', 'payment_library_id' => 1], ['name' => 'WeChat Express', 'provider' => 'WeChat_Express', 'payment_library_id' => 1], ['name' => 'WePay', 'provider' => 'WePay', 'payment_library_id' => 1]];
     foreach ($gateways as $gateway) {
         $record = Gateway::where('name', '=', $gateway['name'])->first();
         if ($record) {
             $record->provider = $gateway['provider'];
             $record->save();
         } else {
             Gateway::create($gateway);
         }
     }
 }
 private function createGateways()
 {
     $gateways = [['name' => 'BeanStream', 'provider' => 'BeanStream', 'payment_library_id' => 2], ['name' => 'Psigate', 'provider' => 'Psigate', 'payment_library_id' => 2], ['name' => 'moolah', 'provider' => 'AuthorizeNet_AIM', 'sort_order' => 1, 'recommended' => 1, 'site_url' => 'https://invoiceninja.mymoolah.com/', 'payment_library_id' => 1], ['name' => 'Alipay', 'provider' => 'Alipay_Express', 'payment_library_id' => 1], ['name' => 'Buckaroo', 'provider' => 'Buckaroo_CreditCard', 'payment_library_id' => 1], ['name' => 'Coinbase', 'provider' => 'Coinbase', 'payment_library_id' => 1], ['name' => 'DataCash', 'provider' => 'DataCash', 'payment_library_id' => 1], ['name' => 'Neteller', 'provider' => 'Neteller', 'payment_library_id' => 1], ['name' => 'Pacnet', 'provider' => 'Pacnet', 'payment_library_id' => 1], ['name' => 'PaymentSense', 'provider' => 'PaymentSense', 'payment_library_id' => 1], ['name' => 'Realex', 'provider' => 'Realex_Remote', 'payment_library_id' => 1], ['name' => 'Sisow', 'provider' => 'Sisow', 'payment_library_id' => 1], ['name' => 'Skrill', 'provider' => 'Skrill', 'payment_library_id' => 1], ['name' => 'BitPay', 'provider' => 'BitPay', 'payment_library_id' => 1], ['name' => 'Dwolla', 'provider' => 'Dwolla', 'payment_library_id' => 1], ['name' => 'Eway Rapid', 'provider' => 'Eway_RapidShared', 'payment_library_id' => 1]];
     foreach ($gateways as $gateway) {
         $record = Gateway::where('name', '=', $gateway['name'])->first();
         if ($record) {
             $record->provider = $gateway['provider'];
             $record->save();
         } else {
             Gateway::create($gateway);
         }
     }
 }
 public function run()
 {
     Eloquent::unguard();
     $gateways = [['name' => 'Authorize.Net AIM', 'provider' => 'AuthorizeNet_AIM', 'sort_order' => 4], ['name' => 'Authorize.Net SIM', 'provider' => 'AuthorizeNet_SIM', 'payment_library_id' => 2], ['name' => 'CardSave', 'provider' => 'CardSave'], ['name' => 'Eway Rapid', 'provider' => 'Eway_RapidShared', 'is_offsite' => true], ['name' => 'FirstData Connect', 'provider' => 'FirstData_Connect'], ['name' => 'GoCardless', 'provider' => 'GoCardless', 'is_offsite' => true], ['name' => 'Migs ThreeParty', 'provider' => 'Migs_ThreeParty'], ['name' => 'Migs TwoParty', 'provider' => 'Migs_TwoParty'], ['name' => 'Mollie', 'provider' => 'Mollie', 'is_offsite' => true, 'sort_order' => 7], ['name' => 'MultiSafepay', 'provider' => 'MultiSafepay'], ['name' => 'Netaxept', 'provider' => 'Netaxept'], ['name' => 'NetBanx', 'provider' => 'NetBanx'], ['name' => 'PayFast', 'provider' => 'PayFast', 'is_offsite' => true], ['name' => 'Payflow Pro', 'provider' => 'Payflow_Pro'], ['name' => 'PaymentExpress PxPay', 'provider' => 'PaymentExpress_PxPay'], ['name' => 'PaymentExpress PxPost', 'provider' => 'PaymentExpress_PxPost'], ['name' => 'PayPal Express', 'provider' => 'PayPal_Express', 'is_offsite' => true, 'sort_order' => 3], ['name' => 'PayPal Pro', 'provider' => 'PayPal_Pro'], ['name' => 'Pin', 'provider' => 'Pin'], ['name' => 'SagePay Direct', 'provider' => 'SagePay_Direct'], ['name' => 'SagePay Server', 'provider' => 'SagePay_Server'], ['name' => 'SecurePay DirectPost', 'provider' => 'SecurePay_DirectPost'], ['name' => 'Stripe', 'provider' => 'Stripe', 'sort_order' => 1], ['name' => 'TargetPay Direct eBanking', 'provider' => 'TargetPay_Directebanking'], ['name' => 'TargetPay Ideal', 'provider' => 'TargetPay_Ideal'], ['name' => 'TargetPay Mr Cash', 'provider' => 'TargetPay_Mrcash'], ['name' => 'TwoCheckout', 'provider' => 'TwoCheckout', 'is_offsite' => true], ['name' => 'WorldPay', 'provider' => 'WorldPay'], ['name' => 'BeanStream', 'provider' => 'BeanStream', 'payment_library_id' => 2], ['name' => 'Psigate', 'provider' => 'Psigate', 'payment_library_id' => 2], ['name' => 'moolah', 'provider' => 'AuthorizeNet_AIM'], ['name' => 'Alipay', 'provider' => 'Alipay_Express'], ['name' => 'Buckaroo', 'provider' => 'Buckaroo_CreditCard'], ['name' => 'Coinbase', 'provider' => 'Coinbase'], ['name' => 'DataCash', 'provider' => 'DataCash'], ['name' => 'Neteller', 'provider' => 'Neteller', 'payment_library_id' => 2], ['name' => 'Pacnet', 'provider' => 'Pacnet'], ['name' => 'PaymentSense', 'provider' => 'PaymentSense'], ['name' => 'Realex', 'provider' => 'Realex_Remote'], ['name' => 'Sisow', 'provider' => 'Sisow'], ['name' => 'Skrill', 'provider' => 'Skrill'], ['name' => 'BitPay', 'provider' => 'BitPay', 'is_offsite' => true, 'sort_order' => 6], ['name' => 'Dwolla', 'provider' => 'Dwolla', 'is_offsite' => true, 'sort_order' => 5], ['name' => 'AGMS', 'provider' => 'Agms'], ['name' => 'Barclays', 'provider' => 'BarclaysEpdq\\Essential'], ['name' => 'Cardgate', 'provider' => 'Cardgate'], ['name' => 'Checkout.com', 'provider' => 'CheckoutCom'], ['name' => 'Creditcall', 'provider' => 'Creditcall'], ['name' => 'Cybersource', 'provider' => 'Cybersource'], ['name' => 'ecoPayz', 'provider' => 'Ecopayz'], ['name' => 'Fasapay', 'provider' => 'Fasapay'], ['name' => 'Komoju', 'provider' => 'Komoju'], ['name' => 'Multicards', 'provider' => 'Multicards'], ['name' => 'Pagar.Me', 'provider' => 'Pagarme'], ['name' => 'Paysafecard', 'provider' => 'Paysafecard'], ['name' => 'Paytrace', 'provider' => 'Paytrace_CreditCard'], ['name' => 'Secure Trading', 'provider' => 'SecureTrading'], ['name' => 'SecPay', 'provider' => 'SecPay'], ['name' => 'WeChat Express', 'provider' => 'WeChat_Express'], ['name' => 'WePay', 'provider' => 'WePay', 'is_offsite' => false], ['name' => 'Braintree', 'provider' => 'Braintree', 'sort_order' => 2], ['name' => 'Custom', 'provider' => 'Custom', 'is_offsite' => true, 'sort_order' => 8]];
     foreach ($gateways as $gateway) {
         $record = Gateway::where('name', '=', $gateway['name'])->first();
         if ($record) {
             $record->fill($gateway);
             $record->save();
         } else {
             Gateway::create($gateway);
         }
     }
 }
 private function getViewModel($accountGateway = false)
 {
     $selectedCards = $accountGateway ? $accountGateway->accepted_credit_cards : 0;
     $account = Auth::user()->account;
     $paymentTypes = [];
     foreach (Gateway::$paymentTypes as $type) {
         if ($accountGateway || !$account->getGatewayByType($type)) {
             $paymentTypes[$type] = trans('texts.' . strtolower($type));
             if ($type == PAYMENT_TYPE_BITCOIN) {
                 $paymentTypes[$type] .= ' - BitPay';
             }
             if ($type == PAYMENT_TYPE_DIRECT_DEBIT) {
                 $paymentTypes[$type] .= ' - GoCardless';
             }
         }
     }
     $creditCardsArray = unserialize(CREDIT_CARDS);
     $creditCards = [];
     foreach ($creditCardsArray as $card => $name) {
         if ($selectedCards > 0 && ($selectedCards & $card) == $card) {
             $creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card']), 'checked' => 'checked'];
         } else {
             $creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card'])];
         }
     }
     $account->load('account_gateways');
     $currentGateways = $account->account_gateways;
     $gateways = Gateway::where('payment_library_id', '=', 1)->orderBy('name')->get();
     foreach ($gateways as $gateway) {
         $fields = $gateway->getFields();
         asort($fields);
         $gateway->fields = $fields;
         if ($accountGateway && $accountGateway->gateway_id == $gateway->id) {
             $accountGateway->fields = $gateway->fields;
         }
     }
     $tokenBillingOptions = [];
     for ($i = 1; $i <= 4; $i++) {
         $tokenBillingOptions[$i] = trans("texts.token_billing_{$i}");
     }
     return ['paymentTypes' => $paymentTypes, 'account' => $account, 'accountGateway' => $accountGateway, 'config' => false, 'gateways' => $gateways, 'creditCardTypes' => $creditCards, 'tokenBillingOptions' => $tokenBillingOptions, 'countGateways' => count($currentGateways)];
 }
 private function getViewModel($accountGateway = false)
 {
     $selectedCards = $accountGateway ? $accountGateway->accepted_credit_cards : 0;
     $user = Auth::user();
     $account = $user->account;
     $creditCardsArray = unserialize(CREDIT_CARDS);
     $creditCards = [];
     foreach ($creditCardsArray as $card => $name) {
         if ($selectedCards > 0 && ($selectedCards & $card) == $card) {
             $creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card']), 'checked' => 'checked'];
         } else {
             $creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card'])];
         }
     }
     $account->load('account_gateways');
     $currentGateways = $account->account_gateways;
     $gateways = Gateway::where('payment_library_id', '=', 1)->orderBy('name')->get();
     foreach ($gateways as $gateway) {
         $fields = $gateway->getFields();
         asort($fields);
         $gateway->fields = $gateway->id == GATEWAY_WEPAY ? [] : $fields;
         if ($accountGateway && $accountGateway->gateway_id == $gateway->id) {
             $accountGateway->fields = $gateway->fields;
         }
     }
     return ['account' => $account, 'user' => $user, 'accountGateway' => $accountGateway, 'config' => false, 'gateways' => $gateways, 'creditCardTypes' => $creditCards, 'countGateways' => count($currentGateways)];
 }