2019-09-26 07:14:07 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\PaymentDrivers;
|
|
|
|
|
|
|
|
use App\Models\ClientGatewayToken;
|
|
|
|
use App\Models\GatewayType;
|
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class PayPalExpressPaymentDriver extends BasePaymentDriver
|
|
|
|
{
|
|
|
|
|
|
|
|
use MakesHash;
|
|
|
|
|
|
|
|
protected $refundable = false;
|
|
|
|
|
|
|
|
protected $token_billing = false;
|
|
|
|
|
|
|
|
protected $can_authorise_credit_card = false;
|
|
|
|
|
|
|
|
protected $customer_reference = '';
|
|
|
|
|
|
|
|
|
|
|
|
public function gatewayTypes()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
GatewayType::PAYPAL,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2019-09-26 07:47:37 +02:00
|
|
|
/**
|
|
|
|
* Processes the payment with this gateway
|
|
|
|
*
|
|
|
|
* @var $data['invoices']
|
|
|
|
* @var $data['amount']
|
|
|
|
* @var $data['fee']
|
|
|
|
* @var $data['amount_with_fee']
|
|
|
|
* @var $data['token']
|
|
|
|
* @var $data['payment_method_id']
|
|
|
|
* @var $data['hashed_ids']
|
|
|
|
*
|
|
|
|
* @param array $data variables required to build payment page
|
|
|
|
* @return view Gateway and payment method specific view
|
|
|
|
*/
|
2019-09-26 07:14:07 +02:00
|
|
|
public function processPaymentView(array $data)
|
|
|
|
{
|
2019-09-29 23:49:43 +02:00
|
|
|
$this->purchase();
|
2019-09-26 07:14:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function processPaymentResponse($request)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-09-26 07:47:37 +02:00
|
|
|
protected function paymentDetails()
|
2019-09-26 07:14:07 +02:00
|
|
|
{
|
|
|
|
$data = parent::paymentDetails();
|
|
|
|
|
2019-09-26 07:47:37 +02:00
|
|
|
$data['amount'] = $invoice->getRequestedAmount();
|
|
|
|
$data['returnUrl'] = $completeUrl;
|
|
|
|
$data['cancelUrl'] = $this->invitation->getLink();
|
|
|
|
$data['description'] = trans('texts.' . $invoice->getEntityType()) . " {$invoice->invoice_number}";
|
|
|
|
$data['transactionId'] = $invoice->invoice_number;
|
|
|
|
|
2019-09-26 07:14:07 +02:00
|
|
|
$data['ButtonSource'] = 'InvoiceNinja_SP';
|
|
|
|
$data['solutionType'] = 'Sole'; // show 'Pay with credit card' option
|
|
|
|
$data['transactionId'] = $data['transactionId'] . '-' . time();
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
2019-09-29 23:49:43 +02:00
|
|
|
|
|
|
|
private function buildReturnUrl()
|
|
|
|
{
|
|
|
|
$url = $this->client->company->domain . "/payment_hook/{$this->company_gateway->id}/{GatewayType::PAYPAL}";
|
|
|
|
}
|
2019-09-26 23:54:03 +02:00
|
|
|
}
|