Merge pull request #9797 from turbo124/v5-develop

v5.10.12
This commit is contained in:
David Bomba 2024-07-20 13:38:35 +10:00 committed by GitHub
commit d967329bc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 126 additions and 94 deletions

View File

@ -1 +1 @@
5.10.11 5.10.12

View File

@ -530,56 +530,68 @@ class PayPalBasePaymentDriver extends BaseDriver
public function createNinjaPayment($request, $response) public function createNinjaPayment($request, $response)
{ {
$data = [ if(isset($response['purchase_units'][0]['payments']['captures'][0]['status']) && in_array($response['purchase_units'][0]['payments']['captures'][0]['status'], ['COMPLETED', 'PENDING']))
'payment_type' => $this->getPaymentMethod($request->gateway_type_id), {
'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'],
'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'],
'gateway_type_id' => GatewayType::PAYPAL,
];
$payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); $payment_status = $response['purchase_units'][0]['payments']['captures'][0]['status'] == 'COMPLETED' ? \App\Models\Payment::STATUS_COMPLETED : \App\Models\Payment::STATUS_PENDING;
if ($request->has('store_card') && $request->input('store_card') === true) { $data = [
$payment_source = $response->json()['payment_source'] ?? false; 'payment_type' => $this->getPaymentMethod($request->gateway_type_id),
'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'],
'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'],
'gateway_type_id' => GatewayType::PAYPAL,
];
if(isset($payment_source['card']) && ($payment_source['card']['attributes']['vault']['status'] ?? false) && $payment_source['card']['attributes']['vault']['status'] == 'VAULTED') { $payment = $this->createPayment($data, $payment_status);
$last4 = $payment_source['card']['last_digits']; if ($request->has('store_card') && $request->input('store_card') === true) {
$expiry = $payment_source['card']['expiry']; //'2025-01' $payment_source = $response->json()['payment_source'] ?? false;
$expiry_meta = explode('-', $expiry);
$brand = $payment_source['card']['brand'];
$payment_meta = new \stdClass(); if(isset($payment_source['card']) && ($payment_source['card']['attributes']['vault']['status'] ?? false) && $payment_source['card']['attributes']['vault']['status'] == 'VAULTED') {
$payment_meta->exp_month = $expiry_meta[1] ?? '';
$payment_meta->exp_year = $expiry_meta[0] ?? $expiry;
$payment_meta->brand = $brand;
$payment_meta->last4 = $last4;
$payment_meta->type = GatewayType::CREDIT_CARD;
$token = $payment_source['card']['attributes']['vault']['id']; // 09f28652d01257021 $last4 = $payment_source['card']['last_digits'];
$gateway_customer_reference = $payment_source['card']['attributes']['vault']['customer']['id']; //rbTHnLsZqE; $expiry = $payment_source['card']['expiry']; //'2025-01'
$expiry_meta = explode('-', $expiry);
$brand = $payment_source['card']['brand'];
$data['token'] = $token; $payment_meta = new \stdClass();
$data['payment_method_id'] = GatewayType::PAYPAL_ADVANCED_CARDS; $payment_meta->exp_month = $expiry_meta[1] ?? '';
$data['payment_meta'] = $payment_meta; $payment_meta->exp_year = $expiry_meta[0] ?? $expiry;
$payment_meta->brand = $brand;
$payment_meta->last4 = $last4;
$payment_meta->type = GatewayType::CREDIT_CARD;
$additional['gateway_customer_reference'] = $gateway_customer_reference; $token = $payment_source['card']['attributes']['vault']['id']; // 09f28652d01257021
$gateway_customer_reference = $payment_source['card']['attributes']['vault']['customer']['id']; //rbTHnLsZqE;
$this->storeGatewayToken($data, $additional); $data['token'] = $token;
$data['payment_method_id'] = GatewayType::PAYPAL_ADVANCED_CARDS;
$data['payment_meta'] = $payment_meta;
$additional['gateway_customer_reference'] = $gateway_customer_reference;
$this->storeGatewayToken($data, $additional);
}
} }
SystemLogger::dispatch(
['response' => $response->json(), 'data' => $data],
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_SUCCESS,
SystemLog::TYPE_PAYPAL,
$this->client,
$this->client->company,
);
return response()->json(['redirect' => route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)], false)]);
} }
SystemLogger::dispatch( SystemLogger::dispatch($response, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_PAYPAL, $this->client, $this->client->company);
['response' => $response->json(), 'data' => $data],
SystemLog::CATEGORY_GATEWAY_RESPONSE, $error = isset($response['purchase_units'][0]['payments']['captures'][0]['status_details'][0]) ? $response['purchase_units'][0]['payments']['captures'][0]['status_details'][0] : $response['purchase_units'][0]['payments']['captures'][0]['status'];
SystemLog::EVENT_GATEWAY_SUCCESS,
SystemLog::TYPE_PAYPAL, return response()->json(['message' => $error], 400);
$this->client,
$this->client->company,
);
return response()->json(['redirect' => route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)], false)]);
} }

View File

@ -288,8 +288,6 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
$orderId = $this->createOrder($data); $orderId = $this->createOrder($data);
// $r = $this->gatewayRequest("/v2/checkout/orders/{$orderId}", 'get', ['body' => '']);
try { try {
$r = $this->gatewayRequest("/v2/checkout/orders/{$orderId}", 'get', ['body' => '']); $r = $this->gatewayRequest("/v2/checkout/orders/{$orderId}", 'get', ['body' => '']);
@ -318,25 +316,33 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
$response = $r->json(); $response = $r->json();
$data = [ if(isset($response['purchase_units'][0]['payments']['captures'][0]['status']) && $response['purchase_units'][0]['payments']['captures'][0]['status'] == 'COMPLETED')
'payment_type' => $this->getPaymentMethod($request->gateway_type_id), {
'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'], $data = [
'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'], 'payment_type' => $this->getPaymentMethod($request->gateway_type_id),
'gateway_type_id' => $this->gateway_type_id, 'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'],
]; 'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'],
'gateway_type_id' => $this->gateway_type_id,
];
$payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); $payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED);
SystemLogger::dispatch( SystemLogger::dispatch(
['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,
$this->client, $this->client,
$this->client->company, $this->client->company,
); );
return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]); return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]);
}
} }
@ -387,24 +393,31 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
$response = $r->json(); $response = $r->json();
$data = [ if(isset($response['purchase_units'][0]['payments']['captures'][0]['status']) && $response['purchase_units'][0]['payments']['captures'][0]['status'] == 'COMPLETED')
'payment_type' => $this->getPaymentMethod((string)$cgt->gateway_type_id), {
'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'],
'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'],
'gateway_type_id' => $this->gateway_type_id,
];
$payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); $data = [
'payment_type' => $this->getPaymentMethod((string)$cgt->gateway_type_id),
'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'],
'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'],
'gateway_type_id' => $this->gateway_type_id,
];
SystemLogger::dispatch( $payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED);
['response' => $response, 'data' => $data],
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_SUCCESS,
SystemLog::TYPE_PAYPAL_PPCP,
$this->client,
$this->client->company,
);
SystemLogger::dispatch(
['response' => $response, 'data' => $data],
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_SUCCESS,
SystemLog::TYPE_PAYPAL_PPCP,
$this->client,
$this->client->company,
);
}
$this->processInternallyFailedPayment($this, new \Exception('Auto billing failed.', 400));
SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_PAYPAL, $this->client, $this->client->company);
} }
} }

View File

@ -11,6 +11,7 @@
namespace App\Repositories; namespace App\Repositories;
use App\Utils\Ninja;
use App\Models\Design; use App\Models\Design;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -54,4 +55,20 @@ class DesignRepository extends BaseRepository
return $design; return $design;
} }
/**
* @param $entity
*/
public function restore($design)
{
$design->name = str_ireplace("_deleted_", "_restored_", $design->name);
parent::restore($design);
return $design;
}
} }

View File

@ -17,8 +17,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true), 'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => env('APP_VERSION', '5.10.11'), 'app_version' => env('APP_VERSION', '5.10.12'),
'app_tag' => env('APP_TAG', '5.10.11'), 'app_tag' => env('APP_TAG', '5.10.12'),
'minimum_client_version' => '5.0.16', 'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1', 'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false), 'api_secret' => env('API_SECRET', false),

View File

@ -14,10 +14,10 @@
@endphp @endphp
@section('gateway_head') @section('gateway_head')
<meta http-equiv="Content-Security-Policy" content=" <!-- <meta http-equiv="Content-Security-Policy" content="
img-src 'self' https://c.paypal.com https://b.stats.paypal.com; img-src 'self' https://c.paypal.com https://b.stats.paypal.com;
frame-src 'self' https://c.paypal.com; frame-src 'self' https://c.paypal.com;
script-src 'self' https://c.paypal.com;"> script-src 'self' https://c.paypal.com;"> -->
@endsection @endsection
@section('gateway_content') @section('gateway_content')
@ -86,7 +86,7 @@
} }
</script> </script>
<script type="text/javascript" src="https://c.paypal.com/da/r/fb.js"></script> <!-- <script type="text/javascript" src="https://c.paypal.com/da/r/fb.js"></script> -->
@if(isset($merchantId)) @if(isset($merchantId))
<script src="https://www.paypal.com/sdk/js?client-id={!! $client_id !!}&merchant-id={!! $merchantId !!}&components=card-fields" data-partner-attribution-id="invoiceninja_SP_PPCP"></script> <script src="https://www.paypal.com/sdk/js?client-id={!! $client_id !!}&merchant-id={!! $merchantId !!}&components=card-fields" data-partner-attribution-id="invoiceninja_SP_PPCP"></script>
@ -138,10 +138,15 @@
body: formData, body: formData,
}) })
.then(response => { .then(response => {
if (!response.ok) { if (!response.ok) {
throw new Error('Network response was not ok ' + response.statusText); return response.json().then(errorData => {
throw new Error(errorData.message);
});
} }
return response.json(); return response.json();
}) })
.then(data => { .then(data => {
@ -164,7 +169,6 @@
document.getElementById('errors').textContent = `Sorry, your transaction could not be processed...\n\n${error.message}`; document.getElementById('errors').textContent = `Sorry, your transaction could not be processed...\n\n${error.message}`;
document.getElementById('errors').hidden = false; document.getElementById('errors').hidden = false;
}); });
}, },
@ -172,20 +176,6 @@
window.location.href = "/client/invoices/"; window.location.href = "/client/invoices/";
}, },
// onError: function(error) {
// console.log("submit catch");
// const errorM = parseError(error);
// console.log(errorM);
// const msg = handle422Error(errorM);
// document.getElementById('errors').textContent = `Sorry, your transaction could not be processed...\n\n${msg.description}`;
// document.getElementById('errors').hidden = false;
// },
onClick: function (){ onClick: function (){
} }
@ -195,8 +185,8 @@
// Render each field after checking for eligibility // Render each field after checking for eligibility
if (cardField.isEligible()) { if (cardField.isEligible()) {
// const nameField = cardField.NameField(); const nameField = cardField.NameField();
// nameField.render("#card-name-field-container"); nameField.render("#card-name-field-container");
const numberField = cardField.NumberField({ const numberField = cardField.NumberField({
inputEvents: { inputEvents: {