From 3981d59ef37203f82ff5872f6b093817a9e2b4d3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 21 Jul 2024 11:12:07 +1000 Subject: [PATCH 1/7] Fixes for translations --- .../PayPal/PayPalBasePaymentDriver.php | 1 + .../PayPalPPCPPaymentDriver.php | 79 +++++++++++-------- .../PayPalRestPaymentDriver.php | 7 +- app/Services/Client/PaymentMethod.php | 2 +- lang/en/texts.php | 2 +- .../ninja2020/gateways/paypal/pay.blade.php | 33 ++++---- .../gateways/paypal/ppcp/pay.blade.php | 9 ++- 7 files changed, 74 insertions(+), 59 deletions(-) diff --git a/app/PaymentDrivers/PayPal/PayPalBasePaymentDriver.php b/app/PaymentDrivers/PayPal/PayPalBasePaymentDriver.php index ec637548d3..56824c8402 100644 --- a/app/PaymentDrivers/PayPal/PayPalBasePaymentDriver.php +++ b/app/PaymentDrivers/PayPal/PayPalBasePaymentDriver.php @@ -525,6 +525,7 @@ class PayPalBasePaymentDriver extends BaseDriver $this->init(); PayPalWebhook::dispatch($request->all(), $request->headers->all(), $this->access_token); + } public function createNinjaPayment($request, $response) diff --git a/app/PaymentDrivers/PayPalPPCPPaymentDriver.php b/app/PaymentDrivers/PayPalPPCPPaymentDriver.php index 14fd0ace2d..4cb22ad728 100644 --- a/app/PaymentDrivers/PayPalPPCPPaymentDriver.php +++ b/app/PaymentDrivers/PayPalPPCPPaymentDriver.php @@ -306,7 +306,6 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver * * @param mixed $request * @param array $response - * @return void */ public function processTokenPayment($request, array $response) { @@ -362,26 +361,32 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver } $response = $r->json(); + + if(isset($response['purchase_units'][0]['payments']['captures'][0]['status']) && $response['purchase_units'][0]['payments']['captures'][0]['status'] == 'COMPLETED') + { - $data = [ - 'payment_type' => $this->getPaymentMethod($request->gateway_type_id), - 'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'], - 'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'], - 'gateway_type_id' => $this->gateway_type_id, - ]; + $data = [ + 'payment_type' => $this->getPaymentMethod($request->gateway_type_id), + 'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'], + 'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'], + 'gateway_type_id' => $this->gateway_type_id, + ]; - $payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); + $payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); - SystemLogger::dispatch( - ['response' => $response, 'data' => $data], - SystemLog::CATEGORY_GATEWAY_RESPONSE, - SystemLog::EVENT_GATEWAY_SUCCESS, - SystemLog::TYPE_PAYPAL_PPCP, - $this->client, - $this->client->company, - ); + SystemLogger::dispatch( + ['response' => $response, 'data' => $data], + SystemLog::CATEGORY_GATEWAY_RESPONSE, + SystemLog::EVENT_GATEWAY_SUCCESS, + SystemLog::TYPE_PAYPAL_PPCP, + $this->client, + $this->client->company, + ); - return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]); + return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]); + } + + return response()->json(['message' => 'Error processing token payment'], 400); } @@ -431,26 +436,36 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver } $response = $r->json(); + if(isset($response['purchase_units'][0]['payments']['captures'][0]['status']) && $response['purchase_units'][0]['payments']['captures'][0]['status'] == 'COMPLETED') + { - $data = [ - 'payment_type' => $this->getPaymentMethod((string)$cgt->gateway_type_id), - 'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'], - 'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'], - 'gateway_type_id' => $this->gateway_type_id, - ]; + $data = [ + 'payment_type' => $this->getPaymentMethod((string)$cgt->gateway_type_id), + 'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'], + 'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'], + 'gateway_type_id' => $this->gateway_type_id, + ]; - $payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); + $payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); - SystemLogger::dispatch( - ['response' => $response, 'data' => $data], - SystemLog::CATEGORY_GATEWAY_RESPONSE, - SystemLog::EVENT_GATEWAY_SUCCESS, - SystemLog::TYPE_PAYPAL_PPCP, - $this->client, - $this->client->company, - ); + SystemLogger::dispatch( + ['response' => $response, 'data' => $data], + SystemLog::CATEGORY_GATEWAY_RESPONSE, + SystemLog::EVENT_GATEWAY_SUCCESS, + SystemLog::TYPE_PAYPAL_PPCP, + $this->client, + $this->client->company, + ); + } + + $this->processInternallyFailedPayment($this, new \Exception('Auto billing failed.', 400)); + + SystemLogger::dispatch($response, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_PAYPAL, $this->client, $this->client->company); } + + + } diff --git a/app/PaymentDrivers/PayPalRestPaymentDriver.php b/app/PaymentDrivers/PayPalRestPaymentDriver.php index 524b59f8c6..ba1cbc62e7 100644 --- a/app/PaymentDrivers/PayPalRestPaymentDriver.php +++ b/app/PaymentDrivers/PayPalRestPaymentDriver.php @@ -340,9 +340,7 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver } - - - + return response()->json(['message' => 'Error processing token payment'], 400); } @@ -413,11 +411,12 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver $this->client, $this->client->company, ); + } $this->processInternallyFailedPayment($this, new \Exception('Auto billing failed.', 400)); - SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_PAYPAL, $this->client, $this->client->company); + SystemLogger::dispatch($response, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_PAYPAL, $this->client, $this->client->company); } } diff --git a/app/Services/Client/PaymentMethod.php b/app/Services/Client/PaymentMethod.php index 8a27f31831..de5e162258 100644 --- a/app/Services/Client/PaymentMethod.php +++ b/app/Services/Client/PaymentMethod.php @@ -169,7 +169,7 @@ class PaymentMethod if (isset($gateway->fees_and_limits) && is_object($gateway->fees_and_limits) && property_exists($gateway->fees_and_limits, GatewayType::CREDIT_CARD)) { //@phpstan-ignore-line if ($this->validGatewayForAmount($gateway->fees_and_limits->{GatewayType::CREDIT_CARD}, $this->amount)) { // $this->payment_methods[] = [$gateway->id => $type]; - //@15-06-2024 + // @15-06-2024 $this->buildUrl($gateway, $type); } } else { diff --git a/lang/en/texts.php b/lang/en/texts.php index fbfdef2e61..e2bad2efda 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -5238,7 +5238,7 @@ $lang = array( 'local_domain_help' => 'EHLO domain (optional)', 'port_help' => 'ie. 25,587,465', 'host_help' => 'ie. smtp.gmail.com', - 'always_show_required_fields' => 'Allows show required fields form', + 'always_show_required_fields' => 'Always show required fields form', 'always_show_required_fields_help' => 'Displays the required fields form always at checkout', 'advanced_cards' => 'Advanced Cards', 'activity_140' => 'Statement sent to :client', diff --git a/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php b/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php index 29137b17a4..b11b968a7f 100644 --- a/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php @@ -30,16 +30,6 @@ @push('footer') - - - - -