From f0dbb10f93d95406f47704421fe7fdc2eabb0521 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 16 Oct 2023 20:49:07 +1100 Subject: [PATCH] fixes for Paypal PPCP --- .../PayPalPPCPPaymentDriver.php | 7 ++++-- .../gateways/paypal/ppcp/pay.blade.php | 23 ++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/PaymentDrivers/PayPalPPCPPaymentDriver.php b/app/PaymentDrivers/PayPalPPCPPaymentDriver.php index d08eeda3e796..1c2360846221 100644 --- a/app/PaymentDrivers/PayPalPPCPPaymentDriver.php +++ b/app/PaymentDrivers/PayPalPPCPPaymentDriver.php @@ -214,6 +214,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver public function processPaymentResponse($request) { + nlog($request['gateway_response']); $response = json_decode($request['gateway_response'], true); @@ -262,6 +263,8 @@ class PayPalPPCPPaymentDriver extends BaseDriver $_invoice = collect($this->payment_hash->data->invoices)->first(); + nlog($_invoice); + $invoice = Invoice::withTrashed()->find($this->decodePrimaryKey($_invoice->invoice_id)); $order = [ @@ -275,8 +278,8 @@ class PayPalPPCPPaymentDriver extends BaseDriver "address" => [ "address_line_1" => $this->client->address1, "address_line_2" => $this->client->address2, - "admin_area_1" => $this->client->city, - "admin_area_2" => $this->client->state, + "admin_area_2" => $this->client->city, + "admin_area_1" => $this->client->state, "postal_code" => $this->client->postal_code, "country_code" => $this->client->country->iso_3166_2, ] diff --git a/resources/views/portal/ninja2020/gateways/paypal/ppcp/pay.blade.php b/resources/views/portal/ninja2020/gateways/paypal/ppcp/pay.blade.php index 2c2718b2d582..df00529ae0ac 100644 --- a/resources/views/portal/ninja2020/gateways/paypal/ppcp/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/paypal/ppcp/pay.blade.php @@ -45,23 +45,24 @@ env: testMode ? 'sandbox' : 'production', fundingSource: fundingSource, client: testMode ? sandbox : production, - // Order is created on the server and the order id is returned createOrder: function(data, actions) { - return orderId; + return orderId; }, - // Finalize the transaction on the server after payer approval onApprove: function(data, actions) { + return actions.order.capture().then(function(details) { + document.getElementById("gateway_response").value =JSON.stringify( details ); + document.getElementById("server_response").submit(); + }); - return actions.order.capture().then(function(details) { - - document.getElementById("gateway_response").value =JSON.stringify( details ); - document.getElementById("server_response").submit(); - - }); - + }, + onCancel: function() { + window.location.href = "/client/invoices/"; }, onError: function(err) { - console.log(err); + console.log("there was an error") + console.log(err) + // document.getElementById("gateway_response").value =JSON.stringify( err ); + // document.getElementById("server_response").submit(); } }).render('#paypal-button-container');