Phase 2 complete: - buildPurchaseDataLayer() called in przelewy24() controller, payload passed to template - dataLayer.push added to templates/tickets/przelewy24.php (fires at order commitment) - dataLayer.push removed from templates/tickets/order-confirm.php - Captures 100% of orders regardless of user returning from payment gateway Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
68 lines
2.8 KiB
PHP
68 lines
2.8 KiB
PHP
<?php
|
|
$purchaseDataLayerJson = null;
|
|
if (is_array($this->purchase_data_layer ?? null)) {
|
|
$purchaseDataLayerJson = json_encode(
|
|
$this->purchase_data_layer,
|
|
JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_INVALID_UTF8_SUBSTITUTE
|
|
);
|
|
}
|
|
?>
|
|
|
|
<?php if($purchaseDataLayerJson) : ?>
|
|
<script type="text/javascript">
|
|
window.dataLayer = window.dataLayer || [];
|
|
window.dataLayer.push({ ecommerce: null });
|
|
window.dataLayer.push(<?= $purchaseDataLayerJson; ?>);
|
|
</script>
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
$clientData = $this->order;
|
|
$merchant_id = $this->settings['p24']['merchant_id'];
|
|
$pos_id = $this->settings['p24']['pos_id'];
|
|
|
|
$crc_key = '';
|
|
|
|
if($this->settings['p24']['sandbox']) {
|
|
$crc_key = $this->settings['p24']['sandbox_crc_key'];
|
|
} else {
|
|
$crc_key = $this->settings['p24']['crc_key'];
|
|
}
|
|
?>
|
|
|
|
<div class="spinner_container">
|
|
<?= \Tpl::view( 'components/spinner'); ?>
|
|
</div>
|
|
|
|
<form
|
|
action="<?= $this -> settings['p24']['sandbox'] ? 'https://sandbox.przelewy24.pl/trnDirect' : 'https://secure.przelewy24.pl/trnDirect';?>"
|
|
method="post" class="form" id="form_data" accept-charset="ISO-8859-2">
|
|
<input type="hidden" name="p24_session_id" value="<?= $this -> przelewy24_hash; ?>" />
|
|
<input type="hidden" name="p24_merchant_id" value="<?= $merchant_id; ?>" />
|
|
<input type="hidden" name="p24_pos_id" value="<?= $pos_id; ?>" />
|
|
<input type="hidden" name="p24_amount" value="<?= $clientData['order_price'] * 100;?>" />
|
|
<input type="hidden" name="p24_currency" value="PLN" />
|
|
<input type="hidden" name="p24_description" value="Zamówienie nr <?= $clientData['id']; ?>" />
|
|
<input type="hidden" name="p24_client" value="<?= $clientData['name'] . ' ' . $clientData['surname'];?>" />
|
|
<input type="hidden" name="p24_zip" value="<?= $clientData['zip_code']; ?>" />
|
|
<input type="hidden" name="p24_city" value="<?= $clientData['city']; ?>" />
|
|
<input type="hidden" name="p24_country" value="PL" />
|
|
<input type="hidden" name="p24_email" value="<?= $clientData['email']; ?>" />
|
|
<input type="hidden" name="p24_language" value="pl" />
|
|
<input type="hidden" name="p24_url_status"
|
|
value="https://<?= $_SERVER['SERVER_NAME'];?>/tickets/przelewy24_response/" />
|
|
<input type="hidden" name="p24_url_return"
|
|
value="https://<?= $_SERVER['SERVER_NAME'];?>/tickets/order_confirm/order=<?= $this -> order['hash'];?>" />
|
|
<input type="hidden" name="p24_api_version" value="3.2" />
|
|
<input type="hidden" name="p24_wait_for_result" value="1">
|
|
<input type="hidden" name="p24_method" value="227">
|
|
<input type="hidden" name="p24_sign"
|
|
value="<?= md5( $this -> przelewy24_hash . '|' . $merchant_id . '|' . ( $clientData['order_price'] * 100 ) . '|PLN|' . $crc_key );?>" />
|
|
</form>
|
|
|
|
<script type="text/javascript">
|
|
$( document ).ready( function() {
|
|
$( "#form_data" ).submit();
|
|
});
|
|
</script>
|