From 62949b2fad0166bef9176dad817f6568866762ea Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 30 Sep 2019 16:54:24 +1000 Subject: [PATCH] Paypal response --- app/PaymentDrivers/BasePaymentDriver.php | 13 ++++++++++++ .../PayPalExpressPaymentDriver.php | 20 +++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/app/PaymentDrivers/BasePaymentDriver.php b/app/PaymentDrivers/BasePaymentDriver.php index 108d55aa404e..f902de9a2725 100644 --- a/app/PaymentDrivers/BasePaymentDriver.php +++ b/app/PaymentDrivers/BasePaymentDriver.php @@ -11,10 +11,12 @@ namespace App\PaymentDrivers; +use App\Factory\PaymentFactory; use App\Models\Client; use App\Models\ClientContact; use App\Models\CompanyGateway; use App\Models\GatewayType; +use App\Models\Payment; use Illuminate\Support\Facades\Auth; use Omnipay\Omnipay; @@ -228,4 +230,15 @@ class BasePaymentDriver ->send(); } + public function createPayment($data) + { + + $payment = PaymentFactory::create($this->client->company->id, $this->client->user->id); + $payment->client_id = $this->client->id; + $payment->company_gateway_id = $this->company_gateway->id; + $payment->status_id = Payment::STATUS_COMPLETED; + $payment->payment_date = Carbon::now(); + return $payment; + + } } \ No newline at end of file diff --git a/app/PaymentDrivers/PayPalExpressPaymentDriver.php b/app/PaymentDrivers/PayPalExpressPaymentDriver.php index b81c6975237e..a17add2b0457 100644 --- a/app/PaymentDrivers/PayPalExpressPaymentDriver.php +++ b/app/PaymentDrivers/PayPalExpressPaymentDriver.php @@ -61,7 +61,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver { $response = $this->completePurchase($request->all()); - +\Log::error($request->all()); $transaction_reference = $response->getTransactionReference() ?: $request->input('token'); if ($response->isCancelled()) { @@ -69,8 +69,13 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver } elseif (! $response->isSuccessful()) { throw new Exception($response->getMessage()); } +//\Log::error(print_r($response,1)); +//\Log::error(print_r($response->getData())); +\Log::error($response->getData()); +//dd($response); + $payment = $this->createPayment($response); + - dd($response); } protected function paymentDetails($input) @@ -168,8 +173,15 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver return $items; } - private function createPayment($data) + public function createPayment($data) { - + $payment = parent::createPayment($data); + + $payment->amount = $this->convertFromStripeAmount($server_response->amount, $this->client->currency->precision); + $payment->payment_type_id = PaymentType::PAYPAL; + $payment->transaction_reference = $payment_method; + $payment->client_contact_id = $this->getContact(); + + } } \ No newline at end of file