mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
PayPal Rest Driver updates
This commit is contained in:
parent
8dde7024fc
commit
9d7bef3a94
@ -418,7 +418,6 @@ class PayPalBasePaymentDriver extends BaseDriver
|
|||||||
public function processWebhookRequest(Request $request)
|
public function processWebhookRequest(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
// nlog(json_encode($request->all()));
|
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
PayPalWebhook::dispatch($request->all(), $request->headers->all(), $this->access_token);
|
PayPalWebhook::dispatch($request->all(), $request->headers->all(), $this->access_token);
|
||||||
|
@ -98,7 +98,7 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
|
|||||||
$data['merchantId'] = $this->company_gateway->getConfigField('merchantId');
|
$data['merchantId'] = $this->company_gateway->getConfigField('merchantId');
|
||||||
$data['currency'] = $this->client->currency()->code;
|
$data['currency'] = $this->client->currency()->code;
|
||||||
|
|
||||||
if($this->paypal_payment_method == 29)
|
if($this->gateway_type_id == 29)
|
||||||
return render('gateways.paypal.ppcp.card', $data);
|
return render('gateways.paypal.ppcp.card', $data);
|
||||||
else
|
else
|
||||||
return render('gateways.paypal.ppcp.pay', $data);
|
return render('gateways.paypal.ppcp.pay', $data);
|
||||||
@ -117,6 +117,10 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
|
|||||||
$request['gateway_response'] = str_replace("Error: ", "", $request['gateway_response']);
|
$request['gateway_response'] = str_replace("Error: ", "", $request['gateway_response']);
|
||||||
$response = json_decode($request['gateway_response'], true);
|
$response = json_decode($request['gateway_response'], true);
|
||||||
|
|
||||||
|
if($request->has('token') && strlen($request->input('token')) > 2) {
|
||||||
|
return $this->processTokenPayment($request, $response);
|
||||||
|
}
|
||||||
|
|
||||||
//capture
|
//capture
|
||||||
$orderID = $response['orderID'];
|
$orderID = $response['orderID'];
|
||||||
|
|
||||||
@ -184,7 +188,7 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
|
|||||||
['response' => $response, 'data' => $data],
|
['response' => $response, 'data' => $data],
|
||||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||||
SystemLog::EVENT_GATEWAY_SUCCESS,
|
SystemLog::EVENT_GATEWAY_SUCCESS,
|
||||||
SystemLog::TYPE_PAYPAL,
|
SystemLog::TYPE_PAYPAL_PPCP,
|
||||||
$this->client,
|
$this->client,
|
||||||
$this->client->company,
|
$this->client->company,
|
||||||
);
|
);
|
||||||
@ -201,7 +205,7 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
|
|||||||
['response' => $response],
|
['response' => $response],
|
||||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||||
SystemLog::EVENT_GATEWAY_FAILURE,
|
SystemLog::EVENT_GATEWAY_FAILURE,
|
||||||
SystemLog::TYPE_PAYPAL,
|
SystemLog::TYPE_PAYPAL_PPCP,
|
||||||
$this->client,
|
$this->client,
|
||||||
$this->client->company,
|
$this->client->company,
|
||||||
);
|
);
|
||||||
@ -283,6 +287,10 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
|
|||||||
$order['purchase_units'][0]["shipping"] = $shipping;
|
$order['purchase_units'][0]["shipping"] = $shipping;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($data['payment_source'])) {
|
||||||
|
$order['payment_source'] = $data['payment_source'];
|
||||||
|
}
|
||||||
|
|
||||||
$r = $this->gatewayRequest('/v2/checkout/orders', 'post', $order);
|
$r = $this->gatewayRequest('/v2/checkout/orders', 'post', $order);
|
||||||
|
|
||||||
return $r->json()['id'];
|
return $r->json()['id'];
|
||||||
@ -343,7 +351,7 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
|
|||||||
['response' => $response, 'data' => $data],
|
['response' => $response, 'data' => $data],
|
||||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||||
SystemLog::EVENT_GATEWAY_SUCCESS,
|
SystemLog::EVENT_GATEWAY_SUCCESS,
|
||||||
SystemLog::TYPE_PAYPAL,
|
SystemLog::TYPE_PAYPAL_PPCP,
|
||||||
$this->client,
|
$this->client,
|
||||||
$this->client->company,
|
$this->client->company,
|
||||||
);
|
);
|
||||||
|
@ -12,18 +12,15 @@
|
|||||||
|
|
||||||
namespace App\PaymentDrivers;
|
namespace App\PaymentDrivers;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
use App\Models\GatewayType;
|
use App\Models\GatewayType;
|
||||||
use App\Models\PaymentType;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use App\Jobs\Util\SystemLogger;
|
use App\Jobs\Util\SystemLogger;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use App\Exceptions\PaymentFailed;
|
use App\Exceptions\PaymentFailed;
|
||||||
use App\Models\ClientGatewayToken;
|
use App\Models\ClientGatewayToken;
|
||||||
use App\PaymentDrivers\PayPal\PayPalBasePaymentDriver;
|
use App\PaymentDrivers\PayPal\PayPalBasePaymentDriver;
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
|
|
||||||
class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
|
class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
|
||||||
{
|
{
|
||||||
@ -47,7 +44,7 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
|
|||||||
$data['gateway_type_id'] = $this->gateway_type_id;
|
$data['gateway_type_id'] = $this->gateway_type_id;
|
||||||
$data['currency'] = $this->client->currency()->code;
|
$data['currency'] = $this->client->currency()->code;
|
||||||
|
|
||||||
if($this->paypal_payment_method == 29)
|
if($this->gateway_type_id == 29)
|
||||||
return render('gateways.paypal.ppcp.card', $data);
|
return render('gateways.paypal.ppcp.card', $data);
|
||||||
else
|
else
|
||||||
return render('gateways.paypal.pay', $data);
|
return render('gateways.paypal.pay', $data);
|
||||||
@ -125,6 +122,9 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
|
|||||||
|
|
||||||
$response = $r;
|
$response = $r;
|
||||||
|
|
||||||
|
nlog("Process response =>");
|
||||||
|
nlog($response->json());
|
||||||
|
|
||||||
if(isset($response['status']) && $response['status'] == 'COMPLETED' && isset($response['purchase_units'])) {
|
if(isset($response['status']) && $response['status'] == 'COMPLETED' && isset($response['purchase_units'])) {
|
||||||
|
|
||||||
return $this->createNinjaPayment($request, $response);
|
return $this->createNinjaPayment($request, $response);
|
||||||
@ -257,6 +257,8 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
|
|||||||
if(isset($data['payment_source']))
|
if(isset($data['payment_source']))
|
||||||
$order['payment_source'] = $data['payment_source'];
|
$order['payment_source'] = $data['payment_source'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$r = $this->gatewayRequest('/v2/checkout/orders', 'post', $order);
|
$r = $this->gatewayRequest('/v2/checkout/orders', 'post', $order);
|
||||||
|
|
||||||
return $r->json()['id'];
|
return $r->json()['id'];
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
<div id="checkout-form">
|
<div id="checkout-form">
|
||||||
<!-- Containers for Card Fields hosted by PayPal -->
|
<!-- Containers for Card Fields hosted by PayPal -->
|
||||||
<div id="card-number-field-container"></div>
|
<div id="card-number-field-container"></div>
|
||||||
|
<div id="card-name-field-container"></div>
|
||||||
<div class="expcvv" style="display:flex;">
|
<div class="expcvv" style="display:flex;">
|
||||||
<div id="card-expiry-field-container" style="width:50%"></div>
|
<div id="card-expiry-field-container" style="width:50%"></div>
|
||||||
<div id="card-cvv-field-container" style="width:50%"></div>
|
<div id="card-cvv-field-container" style="width:50%"></div>
|
||||||
@ -159,6 +160,9 @@
|
|||||||
// Render each field after checking for eligibility
|
// Render each field after checking for eligibility
|
||||||
if (cardField.isEligible()) {
|
if (cardField.isEligible()) {
|
||||||
|
|
||||||
|
const nameField = cardField.NameField();
|
||||||
|
nameField.render("#card-name-field-container");
|
||||||
|
|
||||||
const numberField = cardField.NumberField({
|
const numberField = cardField.NumberField({
|
||||||
inputEvents: {
|
inputEvents: {
|
||||||
onChange: (event)=> {
|
onChange: (event)=> {
|
||||||
@ -166,6 +170,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
numberField.render("#card-number-field-container");
|
numberField.render("#card-number-field-container");
|
||||||
|
|
||||||
const cvvField = cardField.CVVField({
|
const cvvField = cardField.CVVField({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user