Minor fixes for PayPalOM

This commit is contained in:
David Bomba 2024-09-06 08:54:26 +10:00
parent 7444355dee
commit 0017307e39
7 changed files with 39 additions and 29 deletions

View File

@ -481,6 +481,7 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
$data['guid'] = $this->risk_guid; $data['guid'] = $this->risk_guid;
$data['identifier'] = "s:INN_".$this->company_gateway->getConfigField('merchantId')."_CHCK"; $data['identifier'] = "s:INN_".$this->company_gateway->getConfigField('merchantId')."_CHCK";
$data['pp_client_reference'] = $this->getClientHash(); $data['pp_client_reference'] = $this->getClientHash();
$data['invoice_hash'] = $this->payment_hash->fee_invoice->hashed_id;
return $data; return $data;
} }

View File

@ -434,7 +434,8 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
$data['guid'] = $this->risk_guid; $data['guid'] = $this->risk_guid;
$data['identifier'] = "s:INN_ACDC_CHCK"; $data['identifier'] = "s:INN_ACDC_CHCK";
$data['pp_client_reference'] = $this->getClientHash(); $data['pp_client_reference'] = $this->getClientHash();
$data['invoice_hash'] = $this->payment_hash->fee_invoice->hashed_id;
return $data; return $data;
} }

1
public/build/assets/app-fee1da41.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,12 @@
@extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.paypal'), 'card_title' => '']) @extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.paypal'), 'card_title' => ''])
@section('gateway_head') @section('gateway_head')
<meta http-equiv="Content-Security-Policy" content="
frame-src 'self' https://c.paypal.com https://www.sandbox.paypal.com https://www.paypal.com https://www.paypalobjects.com;
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://c.paypal.com https://www.paypalobjects.com https://www.paypal.com https://www.sandbox.paypal.com https://www.google-analytics.com;
img-src * data: 'self';
style-src 'self' 'unsafe-inline';"
>
@endsection @endsection
@section('gateway_content') @section('gateway_content')
@ -82,6 +87,7 @@ inset: 6px;
}, },
onApprove: function(data, actions) { onApprove: function(data, actions) {
document.getElementById('paypal-button-container').hidden = true;
document.getElementById('is_working').classList.remove('hidden'); document.getElementById('is_working').classList.remove('hidden');
document.getElementById("gateway_response").value =JSON.stringify( data ); document.getElementById("gateway_response").value =JSON.stringify( data );
@ -125,14 +131,19 @@ inset: 6px;
document.getElementById("server_response").submit(); document.getElementById("server_response").submit();
}) })
.catch(error => { .catch(error => {
document.getElementById('is_working').classList.add('hidden');
document.getElementById('paypal-button-container').hidden = false;
console.error('Error:', error); console.error('Error:', error);
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;
}); });
}, },
onCancel: function() { onCancel: function() {
window.location.href = "/client/invoices/"; window.location.href = "/client/invoices/{{ $invoice_hash }}";
}, },
onError: function(error) { onError: function(error) {
@ -143,14 +154,6 @@ inset: 6px;
document.getElementById("server_response").submit(); document.getElementById("server_response").submit();
}, },
onClick: function (){ onClick: function (){
console.log(fundingSource);
if(fundingSource != 'card')
document.getElementById('paypal-button-container').hidden = true;
// document.getElementById('is_working').classList.remove('hidden');
document.querySelector('div[data-ref="required-fields-container').classList.add('hidden');
}, },
onInit: function (){ onInit: function (){

View File

@ -1,5 +1,14 @@
<div class="rounded-lg border bg-card text-card-foreground shadow-sm overflow-hidden p-5 bg-white sm:gap-4" <div class="rounded-lg border bg-card text-card-foreground shadow-sm overflow-hidden p-5 bg-white sm:gap-4"
id="paypal-payment"> id="paypal-payment">
@section('gateway_head')
<meta http-equiv="Content-Security-Policy" content="
frame-src 'self' https://c.paypal.com https://www.sandbox.paypal.com https://www.paypal.com https://www.paypalobjects.com;
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://c.paypal.com https://www.paypalobjects.com https://www.paypal.com https://www.sandbox.paypal.com https://www.google-analytics.com;
img-src * data: 'self';
style-src 'self' 'unsafe-inline';"
>
@endsection
<style type="text/css"> <style type="text/css">
.loader { .loader {
width: 48px; width: 48px;
@ -106,8 +115,9 @@
}, },
onApprove: function(data, actions) { onApprove: function(data, actions) {
console.log(data); document.getElementById('paypal-button-container').hidden = true;
document.getElementById('is_working').classList.remove('hidden');
document.getElementById("gateway_response").value =JSON.stringify( data ); document.getElementById("gateway_response").value =JSON.stringify( data );
formData = JSON.stringify(Object.fromEntries(new FormData(document.getElementById("server_response")))), formData = JSON.stringify(Object.fromEntries(new FormData(document.getElementById("server_response")))),
@ -144,34 +154,27 @@
document.getElementById("server_response").submit(); document.getElementById("server_response").submit();
}) })
.catch(error => { .catch(error => {
document.getElementById('is_working').classList.add('hidden');
document.getElementById('paypal-button-container').hidden = false;
console.error('Error:', error); console.error('Error:', error);
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;
}); });
}, },
onCancel: function() { onCancel: function() {
window.location.href = "/client/invoices/"; window.location.href = "/client/invoices/{{ $invoice_hash }}";
}, },
onError: function(error) { onError: function(error) {
console.log("on error"); console.log("on error");
console.log(error); console.log(error);
document.getElementById("gateway_response").value = error; document.getElementById("gateway_response").value = error;
document.getElementById("server_response").submit(); document.getElementById("server_response").submit();
}, },
onClick: function (){ onClick: function (data, actions){
if(fundingSource != 'card')
document.getElementById('paypal-button-container').hidden = true;
document.getElementById('is_working').classList.remove('hidden');
// document.querySelector('div[data-ref="required-fields-container').classList.add('hidden');
}, },
onInit: function (){ onInit: function (){
console.log("init"); console.log("init");
@ -192,5 +195,7 @@
document.getElementById("server_response").classList.add('is-submitting'); document.getElementById("server_response").classList.add('is-submitting');
}); });
</script> </script>
@endscript @endscript

View File

@ -185,8 +185,7 @@
}, },
onCancel: function() { onCancel: function() {
window.location.href = "/client/invoices/{{ $invoice_hash }}";
window.location.href = "/client/invoices/";
}, },
onClick: function (){ onClick: function (){

View File

@ -167,7 +167,7 @@
}, },
onCancel: function() { onCancel: function() {
window.location.href = "/client/invoices/"; window.location.href = "/client/invoices/{{ $invoice_hash }}";
}, },
// onError: function(error) { // onError: function(error) {