From 08b4d320cd5c26efcb9405d21fb275c23cc05f12 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 5 Nov 2023 19:04:31 +1100 Subject: [PATCH] Throw is payments are not yet receivable --- app/PaymentDrivers/PayPalPPCPPaymentDriver.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/PayPalPPCPPaymentDriver.php b/app/PaymentDrivers/PayPalPPCPPaymentDriver.php index 7e9e4a9f7f7c..4764c3b07f23 100644 --- a/app/PaymentDrivers/PayPalPPCPPaymentDriver.php +++ b/app/PaymentDrivers/PayPalPPCPPaymentDriver.php @@ -153,7 +153,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver ->withQueryParameters(['grant_type' => 'client_credentials']) ->post("{$this->api_endpoint_url}/v1/oauth2/token"); - nlog($response->body()); + // nlog($response->body()); if($response->successful()) { $this->access_token = $response->json()['access_token']; @@ -193,9 +193,19 @@ class PayPalPPCPPaymentDriver extends BaseDriver return $this; } + private function checkPaymentsReceivable(): self + { + + if(!$this->company_gateway->getConfigField('payments_receivable')) + throw new PaymentFailed('Unable to accept payments at this time, please contact PayPal for more information.', 401); + + return $this; + + } + public function processPaymentView($data) { - $this->init(); + $this->init()->checkPaymentsReceivable(); $data['gateway'] = $this; $this->payment_hash->data = array_merge((array) $this->payment_hash->data, ['amount' => $data['total']['amount_with_fee']]);