From 8aa8d6521c5a67c17f270cf70899f64bc0558dc4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 23 Jul 2023 09:32:05 +1000 Subject: [PATCH] Updates for paypal rest --- app/Models/Gateway.php | 14 ++-- .../PayPalRestPaymentDriver.php | 69 +++++++++---------- .../ninja2020/gateways/paypal/pay.blade.php | 2 +- 3 files changed, 41 insertions(+), 44 deletions(-) diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php index f041adac7909..2d3107a14138 100644 --- a/app/Models/Gateway.php +++ b/app/Models/Gateway.php @@ -195,13 +195,13 @@ class Gateway extends StaticModel GatewayType::PAYPAL => ['refund' => false, 'token_billing' => false], GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => false], GatewayType::VENMO => ['refund' => false, 'token_billing' => false], - GatewayType::SEPA => ['refund' => false, 'token_billing' => false], - GatewayType::BANCONTACT => ['refund' => false, 'token_billing' => false], - GatewayType::EPS => ['refund' => false, 'token_billing' => false], - GatewayType::MYBANK => ['refund' => false, 'token_billing' => false], - GatewayType::PAYLATER => ['refund' => false, 'token_billing' => false], - GatewayType::PRZELEWY24 => ['refund' => false, 'token_billing' => false], - GatewayType::SOFORT => ['refund' => false, 'token_billing' => false], + // GatewayType::SEPA => ['refund' => false, 'token_billing' => false], + // GatewayType::BANCONTACT => ['refund' => false, 'token_billing' => false], + // GatewayType::EPS => ['refund' => false, 'token_billing' => false], + // GatewayType::MYBANK => ['refund' => false, 'token_billing' => false], + // GatewayType::PAYLATER => ['refund' => false, 'token_billing' => false], + // GatewayType::PRZELEWY24 => ['refund' => false, 'token_billing' => false], + // GatewayType::SOFORT => ['refund' => false, 'token_billing' => false], ]; //Paypal default: diff --git a/app/PaymentDrivers/PayPalRestPaymentDriver.php b/app/PaymentDrivers/PayPalRestPaymentDriver.php index a522e2887b8a..1157554cef8a 100644 --- a/app/PaymentDrivers/PayPalRestPaymentDriver.php +++ b/app/PaymentDrivers/PayPalRestPaymentDriver.php @@ -38,25 +38,28 @@ class PayPalRestPaymentDriver extends BaseDriver private string $api_endpoint_url = ''; + private string $paypal_payment_method = ''; + + private array $funding_options = [ + 3 => 'paypal', + 1 => 'card', + 25 => 'venmo', + 9 => 'sepa', + 12 => 'bancontact', + 17 => 'eps', + 15 => 'giropay', + 13 => 'ideal', + 26 => 'mercadopago', + 27 => 'mybank', + 28 => 'paylater', + 16 => 'p24', + 7 => 'sofort' + ]; + + public function gatewayTypes() { - $enums = [ - 3 => 'paypal', - 1 => 'card', - 25 => 'venmo', - 9 => 'sepa', - 12 => 'bancontact', - 17 => 'eps', - 15 => 'giropay', - 13 => 'ideal', - 26 => 'mercadopago', - 27 => 'mybank', - 28 => 'paylater', - 16 => 'p24', - 7 => 'sofort' - ]; - $funding_options = []; foreach ($this->company_gateway->fees_and_limits as $key => $value) { @@ -65,12 +68,8 @@ class PayPalRestPaymentDriver extends BaseDriver } } - return $funding_options; + return $funding_options; - - // return [ - // GatewayType::PAYPAL, - // ]; } public function init() @@ -88,6 +87,8 @@ class PayPalRestPaymentDriver extends BaseDriver public function setPaymentMethod($payment_method_id) { + $this->paypal_payment_method = $this->funding_options[$payment_method_id]; + return $this; } @@ -117,7 +118,7 @@ class PayPalRestPaymentDriver extends BaseDriver $data['client_id'] = $this->company_gateway->getConfigField('clientId'); $data['token'] = $this->getClientToken(); $data['order_id'] = $this->createOrder($data); - $data['funding_options'] = $this->getFundingOptions(); + $data['funding_options'] = $this->paypal_payment_method; return render('gateways.paypal.pay', $data); @@ -130,16 +131,16 @@ class PayPalRestPaymentDriver extends BaseDriver 3 => 'paypal', 1 => 'card', 25 => 'venmo', - 9 => 'sepa', - 12 => 'bancontact', - 17 => 'eps', - 15 => 'giropay', - 13 => 'ideal', - 26 => 'mercadopago', - 27 => 'mybank', - 28 => 'paylater', - 16 => 'p24', - 7 => 'sofort' + // 9 => 'sepa', + // 12 => 'bancontact', + // 17 => 'eps', + // 15 => 'giropay', + // 13 => 'ideal', + // 26 => 'mercadopago', + // 27 => 'mybank', + // 28 => 'paylater', + // 16 => 'p24', + // 7 => 'sofort' ]; $funding_options = ''; @@ -231,10 +232,6 @@ class PayPalRestPaymentDriver extends BaseDriver [ "description" =>ctrans('texts.invoice_number').'# '.$invoice->number, "invoice_id" => $invoice->number, - // 'reference_id' => 'PUHF', - // 'description' => 'Sporting Goods', - // 'custom_id' => 'CUST-HighFashions', - // 'soft_descriptor' => 'HighFashions', "amount" => [ "value" => (string)$data['amount_with_fee'], "currency_code"=> $this->client->currency()->code, diff --git a/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php b/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php index c86f619d5c1b..3c7cd18d0a5c 100644 --- a/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php @@ -28,7 +28,7 @@ @endsection @push('footer') -