2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Ninja\PaymentDrivers;
|
2016-06-20 16:14:43 +02:00
|
|
|
|
|
|
|
class PayPalExpressPaymentDriver extends BasePaymentDriver
|
|
|
|
{
|
2016-06-22 20:42:09 +02:00
|
|
|
public function gatewayTypes()
|
2016-06-20 16:14:43 +02:00
|
|
|
{
|
|
|
|
return [
|
2017-01-30 20:40:43 +01:00
|
|
|
GATEWAY_TYPE_PAYPAL,
|
2016-06-20 16:14:43 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-07-21 14:35:23 +02:00
|
|
|
protected function paymentDetails($paymentMethod = false)
|
2016-06-20 16:14:43 +02:00
|
|
|
{
|
|
|
|
$data = parent::paymentDetails();
|
|
|
|
|
|
|
|
$data['ButtonSource'] = 'InvoiceNinja_SP';
|
2016-09-26 08:20:06 +02:00
|
|
|
$data['solutionType'] = 'Sole'; // show 'Pay with credit card' option
|
2017-03-28 11:47:11 +02:00
|
|
|
$data['transactionId'] = $data['transactionId'] . '-' . time();
|
2016-06-20 16:14:43 +02:00
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
2016-07-21 14:35:23 +02:00
|
|
|
protected function creatingPayment($payment, $paymentMethod)
|
2016-06-20 16:14:43 +02:00
|
|
|
{
|
|
|
|
$payment->payer_id = $this->input['PayerID'];
|
|
|
|
|
|
|
|
return $payment;
|
|
|
|
}
|
2017-03-29 20:45:41 +02:00
|
|
|
|
|
|
|
protected function paymentUrl($gatewayTypeAlias)
|
|
|
|
{
|
|
|
|
$url = parent::paymentUrl($gatewayTypeAlias);
|
|
|
|
|
|
|
|
// PayPal doesn't allow being run in an iframe so we need to open in new tab
|
|
|
|
if ($this->account()->iframe_url) {
|
|
|
|
return 'javascript:window.open("' . $url . '", "_blank")';
|
|
|
|
} else {
|
|
|
|
return $url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-20 16:14:43 +02:00
|
|
|
}
|