Paypal response

This commit is contained in:
David Bomba 2019-09-30 16:54:24 +10:00
parent c4f777b20e
commit 62949b2fad
2 changed files with 29 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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();
}
}