mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
commit
d967329bc5
@ -1 +1 @@
|
||||
5.10.11
|
||||
5.10.12
|
@ -530,56 +530,68 @@ class PayPalBasePaymentDriver extends BaseDriver
|
||||
public function createNinjaPayment($request, $response)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'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($response['purchase_units'][0]['payments']['captures'][0]['status']) && in_array($response['purchase_units'][0]['payments']['captures'][0]['status'], ['COMPLETED', 'PENDING']))
|
||||
{
|
||||
|
||||
$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) {
|
||||
$payment_source = $response->json()['payment_source'] ?? false;
|
||||
$data = [
|
||||
'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'];
|
||||
$expiry = $payment_source['card']['expiry']; //'2025-01'
|
||||
$expiry_meta = explode('-', $expiry);
|
||||
$brand = $payment_source['card']['brand'];
|
||||
if ($request->has('store_card') && $request->input('store_card') === true) {
|
||||
$payment_source = $response->json()['payment_source'] ?? false;
|
||||
|
||||
$payment_meta = new \stdClass();
|
||||
$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;
|
||||
if(isset($payment_source['card']) && ($payment_source['card']['attributes']['vault']['status'] ?? false) && $payment_source['card']['attributes']['vault']['status'] == 'VAULTED') {
|
||||
|
||||
$token = $payment_source['card']['attributes']['vault']['id']; // 09f28652d01257021
|
||||
$gateway_customer_reference = $payment_source['card']['attributes']['vault']['customer']['id']; //rbTHnLsZqE;
|
||||
$last4 = $payment_source['card']['last_digits'];
|
||||
$expiry = $payment_source['card']['expiry']; //'2025-01'
|
||||
$expiry_meta = explode('-', $expiry);
|
||||
$brand = $payment_source['card']['brand'];
|
||||
|
||||
$data['token'] = $token;
|
||||
$data['payment_method_id'] = GatewayType::PAYPAL_ADVANCED_CARDS;
|
||||
$data['payment_meta'] = $payment_meta;
|
||||
$payment_meta = new \stdClass();
|
||||
$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;
|
||||
|
||||
$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(
|
||||
['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($response, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_PAYPAL, $this->client, $this->client->company);
|
||||
|
||||
$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'];
|
||||
|
||||
return response()->json(['message' => $error], 400);
|
||||
|
||||
}
|
||||
|
||||
|
@ -288,8 +288,6 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
|
||||
|
||||
$orderId = $this->createOrder($data);
|
||||
|
||||
// $r = $this->gatewayRequest("/v2/checkout/orders/{$orderId}", 'get', ['body' => '']);
|
||||
|
||||
try {
|
||||
|
||||
$r = $this->gatewayRequest("/v2/checkout/orders/{$orderId}", 'get', ['body' => '']);
|
||||
@ -318,25 +316,33 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
|
||||
|
||||
$response = $r->json();
|
||||
|
||||
$data = [
|
||||
'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' => $this->gateway_type_id,
|
||||
];
|
||||
if(isset($response['purchase_units'][0]['payments']['captures'][0]['status']) && $response['purchase_units'][0]['payments']['captures'][0]['status'] == 'COMPLETED')
|
||||
{
|
||||
$data = [
|
||||
'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' => $this->gateway_type_id,
|
||||
];
|
||||
|
||||
$payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED);
|
||||
$payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED);
|
||||
|
||||
SystemLogger::dispatch(
|
||||
['response' => $response, 'data' => $data],
|
||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
SystemLog::EVENT_GATEWAY_SUCCESS,
|
||||
SystemLog::TYPE_PAYPAL,
|
||||
$this->client,
|
||||
$this->client->company,
|
||||
);
|
||||
SystemLogger::dispatch(
|
||||
['response' => $response, 'data' => $data],
|
||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
SystemLog::EVENT_GATEWAY_SUCCESS,
|
||||
SystemLog::TYPE_PAYPAL,
|
||||
$this->client,
|
||||
$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();
|
||||
|
||||
$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,
|
||||
];
|
||||
if(isset($response['purchase_units'][0]['payments']['captures'][0]['status']) && $response['purchase_units'][0]['payments']['captures'][0]['status'] == 'COMPLETED')
|
||||
{
|
||||
|
||||
$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(
|
||||
['response' => $response, 'data' => $data],
|
||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
SystemLog::EVENT_GATEWAY_SUCCESS,
|
||||
SystemLog::TYPE_PAYPAL_PPCP,
|
||||
$this->client,
|
||||
$this->client->company,
|
||||
);
|
||||
$payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED);
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Design;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@ -54,4 +55,20 @@ class DesignRepository extends BaseRepository
|
||||
|
||||
return $design;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $entity
|
||||
*/
|
||||
public function restore($design)
|
||||
{
|
||||
|
||||
$design->name = str_ireplace("_deleted_", "_restored_", $design->name);
|
||||
|
||||
parent::restore($design);
|
||||
|
||||
return $design;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ return [
|
||||
'require_https' => env('REQUIRE_HTTPS', true),
|
||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||
'app_version' => env('APP_VERSION', '5.10.11'),
|
||||
'app_tag' => env('APP_TAG', '5.10.11'),
|
||||
'app_version' => env('APP_VERSION', '5.10.12'),
|
||||
'app_tag' => env('APP_TAG', '5.10.12'),
|
||||
'minimum_client_version' => '5.0.16',
|
||||
'terms_version' => '1.0.1',
|
||||
'api_secret' => env('API_SECRET', false),
|
||||
|
@ -14,10 +14,10 @@
|
||||
|
||||
@endphp
|
||||
@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;
|
||||
frame-src 'self' https://c.paypal.com;
|
||||
script-src 'self' https://c.paypal.com;">
|
||||
script-src 'self' https://c.paypal.com;"> -->
|
||||
@endsection
|
||||
|
||||
@section('gateway_content')
|
||||
@ -86,7 +86,7 @@
|
||||
}
|
||||
</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))
|
||||
<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,
|
||||
})
|
||||
.then(response => {
|
||||
|
||||
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();
|
||||
|
||||
})
|
||||
.then(data => {
|
||||
|
||||
@ -164,7 +169,6 @@
|
||||
|
||||
document.getElementById('errors').textContent = `Sorry, your transaction could not be processed...\n\n${error.message}`;
|
||||
document.getElementById('errors').hidden = false;
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
@ -172,20 +176,6 @@
|
||||
|
||||
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 (){
|
||||
|
||||
}
|
||||
@ -195,8 +185,8 @@
|
||||
// Render each field after checking for eligibility
|
||||
if (cardField.isEligible()) {
|
||||
|
||||
// const nameField = cardField.NameField();
|
||||
// nameField.render("#card-name-field-container");
|
||||
const nameField = cardField.NameField();
|
||||
nameField.render("#card-name-field-container");
|
||||
|
||||
const numberField = cardField.NumberField({
|
||||
inputEvents: {
|
||||
|
Loading…
Reference in New Issue
Block a user