Fixes for translations

This commit is contained in:
David Bomba 2024-07-21 11:12:07 +10:00
parent d967329bc5
commit 3981d59ef3
7 changed files with 74 additions and 59 deletions

View File

@ -525,6 +525,7 @@ class PayPalBasePaymentDriver extends BaseDriver
$this->init();
PayPalWebhook::dispatch($request->all(), $request->headers->all(), $this->access_token);
}
public function createNinjaPayment($request, $response)

View File

@ -306,7 +306,6 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
*
* @param mixed $request
* @param array $response
* @return void
*/
public function processTokenPayment($request, array $response)
{
@ -362,26 +361,32 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
}
$response = $r->json();
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,
];
$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_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,
);
return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]);
return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]);
}
return response()->json(['message' => 'Error processing token payment'], 400);
}
@ -431,26 +436,36 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
}
$response = $r->json();
if(isset($response['purchase_units'][0]['payments']['captures'][0]['status']) && $response['purchase_units'][0]['payments']['captures'][0]['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,
];
$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,
];
$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_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($response, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_PAYPAL, $this->client, $this->client->company);
}
}

View File

@ -340,9 +340,7 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
}
return response()->json(['message' => 'Error processing token payment'], 400);
}
@ -413,11 +411,12 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
$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);
SystemLogger::dispatch($response, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_PAYPAL, $this->client, $this->client->company);
}
}

View File

@ -169,7 +169,7 @@ class PaymentMethod
if (isset($gateway->fees_and_limits) && is_object($gateway->fees_and_limits) && property_exists($gateway->fees_and_limits, GatewayType::CREDIT_CARD)) { //@phpstan-ignore-line
if ($this->validGatewayForAmount($gateway->fees_and_limits->{GatewayType::CREDIT_CARD}, $this->amount)) {
// $this->payment_methods[] = [$gateway->id => $type];
//@15-06-2024
// @15-06-2024
$this->buildUrl($gateway, $type);
}
} else {

View File

@ -5238,7 +5238,7 @@ $lang = array(
'local_domain_help' => 'EHLO domain (optional)',
'port_help' => 'ie. 25,587,465',
'host_help' => 'ie. smtp.gmail.com',
'always_show_required_fields' => 'Allows show required fields form',
'always_show_required_fields' => 'Always show required fields form',
'always_show_required_fields_help' => 'Displays the required fields form always at checkout',
'advanced_cards' => 'Advanced Cards',
'activity_140' => 'Statement sent to :client',

View File

@ -30,16 +30,6 @@
@push('footer')
<script type="application/json" fncls="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99">
{
"f":"{{ $guid }}",
"s":"paypal.pay" // unique ID for each web page
}
</script>
<script type="text/javascript" src="https://c.paypal.com/da/r/fb.js"></script>
<style type="text/css">
.loader {
width: 48px;
@ -91,9 +81,9 @@ inset: 6px;
return orderId;
},
onApprove: function(data, actions) {
console.log(data);
document.getElementById('is_working').classList.remove('hidden');
document.getElementById("gateway_response").value =JSON.stringify( data );
formData = JSON.stringify(Object.fromEntries(new FormData(document.getElementById("server_response")))),
@ -108,10 +98,15 @@ inset: 6px;
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 ?? 'Unknown error.');
});
}
return response.json(); // or response.json() if the response is JSON
return response.json();
})
.then(data => {
@ -135,8 +130,6 @@ inset: 6px;
document.getElementById('errors').hidden = false;
});
},
onCancel: function() {
window.location.href = "/client/invoices/";
@ -151,11 +144,12 @@ inset: 6px;
},
onClick: function (){
console.log(fundingSource);
if(fundingSource != 'card')
document.getElementById('paypal-button-container').hidden = true;
document.getElementById('is_working').classList.remove('hidden');
// document.getElementById('is_working').classList.remove('hidden');
document.querySelector('div[data-ref="required-fields-container').classList.add('hidden');
},
@ -174,8 +168,9 @@ inset: 6px;
if (document.getElementById("server_response").classList.contains('is-submitting')) {
e.preventDefault();
}
document.getElementById("server_response").classList.add('is-submitting');
});
</script>

View File

@ -66,10 +66,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 ?? 'Unknown error.');
});
}
return response.json();
return response.json();
})
.then(data => {