Get session id from request when page is pay for order

This commit is contained in:
dinamiko 2022-05-11 16:11:05 +02:00
parent 564caa418c
commit 5bf95fbca3
2 changed files with 16 additions and 0 deletions

View file

@ -30,6 +30,15 @@ window.addEventListener('load', function() {
script.text = JSON.stringify(configuration);
document.body.appendChild(script);
const payForOrderForm = document.forms.order_review;
if(payForOrderForm) {
const puiPayForOrderSessionId = document.createElement('input');
puiPayForOrderSessionId.setAttribute('type', 'hidden');
puiPayForOrderSessionId.setAttribute('name', 'pui_pay_for_order_session_id');
puiPayForOrderSessionId.setAttribute('value', FraudNetConfig.f);
payForOrderForm.appendChild(puiPayForOrderSessionId);
}
_loadBeaconJS({fnUrl: "https://c.paypal.com/da/r/fb.js"})
}

View file

@ -31,6 +31,13 @@ class FraudNetSessionId {
return WC()->session->get( 'ppcp_fraudnet_session_id' );
}
if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) {
$pui_pay_for_order_session_id = filter_input( INPUT_POST, 'pui_pay_for_order_session_id', FILTER_SANITIZE_STRING );
if ( $pui_pay_for_order_session_id && '' !== $pui_pay_for_order_session_id ) {
return $pui_pay_for_order_session_id;
}
}
$session_id = bin2hex( random_bytes( 16 ) );
WC()->session->set( 'ppcp_fraudnet_session_id', $session_id );