diff --git a/app/Models/SystemLog.php b/app/Models/SystemLog.php index 7614c01ecccc..4e0f739af243 100644 --- a/app/Models/SystemLog.php +++ b/app/Models/SystemLog.php @@ -68,7 +68,7 @@ class SystemLog extends Model const TYPE_BRAINTREE = 307; const TYPE_WEPAY = 309; const TYPE_PAYFAST = 310; - + const TYPE_EWAY = 311; const TYPE_QUOTA_EXCEEDED = 400; const TYPE_UPSTREAM_FAILURE = 401; diff --git a/app/PaymentDrivers/Eway/CreditCard.php b/app/PaymentDrivers/Eway/CreditCard.php index 8a4d5a07a248..c4d68ba37af6 100644 --- a/app/PaymentDrivers/Eway/CreditCard.php +++ b/app/PaymentDrivers/Eway/CreditCard.php @@ -29,21 +29,42 @@ use Illuminate\Support\Str; class CreditCard { - public $eway; + public $eway_driver; - public function __construct(EwayPaymentDriver $eway) + public function __construct(EwayPaymentDriver $eway_driver) { - $this->eway = $eway; + $this->eway_driver = $eway_driver; } public function authorizeView($data) { + $data['gateway'] = $this->eway_driver; + $data['api_key'] = $this->eway_driver->company_gateway->getConfigField('apiKey'); + $data['public_api_key'] = 'epk-8C1675E6-8E07-4C86-8946-71B3DE390F44'; + + return render('gateways.eway.authorize', $data); + } public function authorizeRequest($request) { + $transaction = [ + 'Title' => 'Mr.', + 'FirstName' => 'John', + 'LastName' => 'Smith', + 'Country' => 'au', + 'Payment' => [ + 'TotalAmount' => 0, + ], + 'TransactionType' => \Eway\Rapid\Enum\TransactionType::PURCHASE, + 'Method' => \Eway\Rapid\Enum\PaymentMethod::CREATE_TOKEN_CUSTOMER, + 'SecuredCardData' => $request->input('SecuredCardData'), + ]; + + $response = $client->createTransaction(\Eway\Rapid\Enum\ApiMethod::DIRECT, $transaction); + } public function paymentView($data) diff --git a/app/PaymentDrivers/EwayPaymentDriver.php b/app/PaymentDrivers/EwayPaymentDriver.php index a96fd503bdaa..925d1df9589d 100644 --- a/app/PaymentDrivers/EwayPaymentDriver.php +++ b/app/PaymentDrivers/EwayPaymentDriver.php @@ -38,7 +38,7 @@ class EwayPaymentDriver extends BaseDriver GatewayType::CREDIT_CARD => CreditCard::class, //maps GatewayType => Implementation class ]; - const SYSTEM_LOG_TYPE = SystemLog::TYPE_STRIPE; //define a constant for your gateway ie TYPE_YOUR_CUSTOM_GATEWAY - set the const in the SystemLog model + const SYSTEM_LOG_TYPE = SystemLog::TYPE_EWAY; //define a constant for your gateway ie TYPE_YOUR_CUSTOM_GATEWAY - set the const in the SystemLog model public function init() { diff --git a/database/migrations/2021_07_21_234227_activate_eway_payment_driver.php b/database/migrations/2021_07_21_234227_activate_eway_payment_driver.php index 18b23cb826d1..a0fc56152ddd 100644 --- a/database/migrations/2021_07_21_234227_activate_eway_payment_driver.php +++ b/database/migrations/2021_07_21_234227_activate_eway_payment_driver.php @@ -18,6 +18,11 @@ class ActivateEwayPaymentDriver extends Migration { $eway->visible = true; $eway->provider = 'Eway'; + + $fields = json_decode($eway->fields); + $fields->publicApiKey = ''; + $eway->fields = json_encode($fields); + $eway->save(); } diff --git a/database/seeders/PaymentLibrariesSeeder.php b/database/seeders/PaymentLibrariesSeeder.php index 4a5374beb2d5..d90c4692f657 100644 --- a/database/seeders/PaymentLibrariesSeeder.php +++ b/database/seeders/PaymentLibrariesSeeder.php @@ -27,7 +27,7 @@ class PaymentLibrariesSeeder extends Seeder '], ['id' => 2, 'name' => 'CardSave', 'provider' => 'CardSave', 'key' => '46c5c1fed2c43acf4f379bae9c8b9f76', 'fields' => '{"merchantId":"","password":""} '], - ['id' => 3, 'name' => 'Eway Rapid', 'provider' => 'Eway', 'is_offsite' => true, 'key' => '944c20175bbe6b9972c05bcfe294c2c7', 'fields' => '{"apiKey":"","password":"","testMode":false}'], + ['id' => 3, 'name' => 'Eway Rapid', 'provider' => 'Eway', 'is_offsite' => true, 'key' => '944c20175bbe6b9972c05bcfe294c2c7', 'fields' => '{"apiKey":"","password":"","publicApiKey":"",testMode":false}'], ['id' => 4, 'name' => 'FirstData Connect', 'provider' => 'FirstData_Connect', 'key' => '4e0ed0d34552e6cb433506d1ac03a418', 'fields' => '{"storeId":"","sharedSecret":"","testMode":false}'], ['id' => 5, 'name' => 'Migs ThreeParty', 'provider' => 'Migs_ThreeParty', 'key' => '513cdc81444c87c4b07258bc2858d3fa', 'fields' => '{"merchantId":"","merchantAccessCode":"","secureHash":""}'], ['id' => 6, 'name' => 'Migs TwoParty', 'provider' => 'Migs_TwoParty', 'key' => '99c2a271b5088951334d1302e038c01a', 'fields' => '{"merchantId":"","merchantAccessCode":"","secureHash":""}'], diff --git a/resources/views/portal/ninja2020/gateways/eway/authorize.blade.php b/resources/views/portal/ninja2020/gateways/eway/authorize.blade.php index 74773c67172a..55912ed4724f 100644 --- a/resources/views/portal/ninja2020/gateways/eway/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/eway/authorize.blade.php @@ -4,8 +4,10 @@ @endsection @section('gateway_content') -