Complete paypal response

This commit is contained in:
David Bomba 2019-09-30 11:15:57 +10:00
parent e89d7cebaa
commit 0b7054b315
3 changed files with 24 additions and 3 deletions

View File

@ -208,5 +208,13 @@ class BasePaymentDriver
$this->purchaseResponse = (array)$response->getData();*/
}
public function completePurchase($data)
{
$this->gateway();
return $this->gateway
->completePurchase($data)
->send();
}
}

View File

@ -60,6 +60,17 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
public function processPaymentResponse($request)
{
$response = $this->completePurchase($request->all());
$paymentRef = $response->getTransactionReference() ?: $transRef;
if ($response->isCancelled()) {
return false;
} elseif (! $response->isSuccessful()) {
throw new Exception($response->getMessage());
}
dd($response);
}
protected function paymentDetails($input)
@ -81,8 +92,9 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
private function buildReturnUrl($input)
{
$url = $this->client->company->domain . "/payment_hook/{$this->company_gateway->id}/{GatewayType::PAYPAL}/";
$url .= "?hashed_ids=" . implode(",", $input['hashed_ids']);
$url = $this->client->company->domain . "client/payments/process/response";
$url .= "?company_gateway_id={$this->company_gateway->id}&gateway_type_id=".GatewayType::PAYPAL;
$url .= "&hashed_ids=" . implode(",", $input['hashed_ids']);
$url .= "&amount=".$input['amount'];
$url .= "&fee=".$input['fee'];

View File

@ -27,6 +27,7 @@ Route::group(['middleware' => ['auth:contact'], 'prefix' => 'client', 'as' => 'c
Route::get('payments/{payment}', 'ClientPortal\PaymentController@show')->name('payments.show');
Route::post('payments/process', 'ClientPortal\PaymentController@process')->name('payments.process');
Route::post('payments/process/response', 'ClientPortal\PaymentController@response')->name('payments.response');
Route::get('payments/process/response', 'ClientPortal\PaymentController@response')->name('payments.response.get');
Route::get('profile/{client_contact}/edit', 'ClientPortal\ProfileController@edit')->name('profile.edit');
Route::put('profile/{client_contact}/edit', 'ClientPortal\ProfileController@update')->name('profile.update');
@ -46,7 +47,7 @@ Route::group(['middleware' => ['domain_db'], 'prefix' => 'client', 'as' => 'clie
/*Invitation catches*/
Route::get('invoice/{invitation_id}','ClientPortal\InvitationController@invoiceRouter');
Route::get('payment_hook/{invitation_id}','ClientPortal\PaymentHookController@process');
Route::get('payment_hook/{company_gateway_id}/{gateway_type_id}','ClientPortal\PaymentHookController@process');
});