From a09b8619d5d7c924bce348b59371596c3b20b270 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 6 Nov 2023 23:31:48 +1100 Subject: [PATCH] Fixes for PPCP --- .../PayPalPPCPPaymentDriver.php | 100 +++++++++--------- 1 file changed, 51 insertions(+), 49 deletions(-) diff --git a/app/PaymentDrivers/PayPalPPCPPaymentDriver.php b/app/PaymentDrivers/PayPalPPCPPaymentDriver.php index 328ab699d36e..673fdd4bcc9f 100644 --- a/app/PaymentDrivers/PayPalPPCPPaymentDriver.php +++ b/app/PaymentDrivers/PayPalPPCPPaymentDriver.php @@ -196,7 +196,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver private function checkPaymentsReceivable(): self { - if($this->company_gateway->getConfigField('status') != 'active'){ + if($this->company_gateway->getConfigField('status') != 'activated'){ if (class_exists(\Modules\Admin\Services\PayPal\PayPalService::class)) { $pp = new \Modules\Admin\Services\PayPal\PayPalService($this->company_gateway->company, $this->company_gateway->user); @@ -205,7 +205,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver $this->company_gateway = $this->company_gateway->fresh(); $config = $this->company_gateway->getConfig(); - if($config->status == 'active') + if($config->status == 'activated') return $this; } @@ -232,6 +232,8 @@ class PayPalPPCPPaymentDriver extends BaseDriver $data['gateway_type_id'] = $this->gateway_type_id; $data['merchantId'] = $this->company_gateway->getConfigField('merchantId'); + // nlog($data['merchantId']); + return render('gateways.paypal.ppcp.pay', $data); } @@ -313,59 +315,59 @@ class PayPalPPCPPaymentDriver extends BaseDriver })->implode("\n"); $order = [ - "intent" => "CAPTURE", - "payer" => [ - "name" => [ - "given_name" => $this->client->present()->first_name(), - "surname" => $this->client->present()->last_name(), - ], - "email_address" => $this->client->present()->email(), - "address" => [ - "address_line_1" => $this->client->address1, - "address_line_2" => $this->client->address2, - "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, - ] - ], - "purchase_units" => [ - [ - "description" =>ctrans('texts.invoice_number').'# '.$invoice->number, - "invoice_id" => $invoice->number, - "amount" => [ - "value" => (string)$data['amount_with_fee'], - "currency_code"=> $this->client->currency()->code, - "breakdown" => [ - "item_total" => [ - "currency_code" => $this->client->currency()->code, - "value" => (string)$data['amount_with_fee'] - ] - ] - ], - "items"=> [ - [ - "name" => ctrans('texts.invoice_number').'# '.$invoice->number, - "description" => substr($description, 0, 127), - "quantity" => "1", - "unit_amount" => [ - "currency_code" => $this->client->currency()->code, - "value" => (string)$data['amount_with_fee'] + + "intent" => "CAPTURE", + "payer" => [ + "name" => [ + "given_name" => $this->client->present()->first_name(), + "surname" => $this->client->present()->last_name(), ], + "email_address" => $this->client->present()->email(), + "address" => [ + "address_line_1" => $this->client->address1, + "address_line_2" => $this->client->address2, + "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, + ] ], - ], - ] - ] - ]; - - $data['payee'] = [ - "merchant_id" => $this->company_gateway->getConfigField('merchantId'), - [ + "purchase_units" => [ + [ + "description" =>ctrans('texts.invoice_number').'# '.$invoice->number, + "invoice_id" => $invoice->number, + "payee" => [ + "merchant_id" => $this->company_gateway->getConfigField('merchantId'), + ], "payment_instruction" => [ "disbursement_mode" => "INSTANT", ], + "amount" => [ + "value" => (string)$data['amount_with_fee'], + "currency_code"=> $this->client->currency()->code, + "breakdown" => [ + "item_total" => [ + "currency_code" => $this->client->currency()->code, + "value" => (string)$data['amount_with_fee'] + ] + ] + ], + "items"=> [ + [ + "name" => ctrans('texts.invoice_number').'# '.$invoice->number, + "description" => substr($description, 0, 127), + "quantity" => "1", + "unit_amount" => [ + "currency_code" => $this->client->currency()->code, + "value" => (string)$data['amount_with_fee'] + ], + ], + ], ], - ]; + ] + ]; + + nlog($order); $r = $this->gatewayRequest('/v2/checkout/orders', 'post', $order);