Skip to content

Commit

Permalink
examples - fix json parse error when paying in modal box
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed Jun 6, 2024
1 parent ea3e4b9 commit 507aabf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/THREED-SECURE-AND-PAY-PAYMENT-IN-MODALBOX-EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ $renderedForm = ob_get_clean();
*/
let displayResponse = function (event) {
let alertBox = $('#result-alert');
let data = JSON.parse(event.data);
let data = JSON.parse(atob(event.data));
$('#result-response').append(JSON.stringify(data, null, '\t'));
if (data.status === 'approved') {
alertBox.append('payment successful');
Expand Down Expand Up @@ -277,7 +277,7 @@ try {
if (window.parent) {
// response.php iframe'de calisti
// odeme sonucunu ana window'a yani form.php'e gonderiyoruz.
window.parent.postMessage(`<?= json_encode($response); ?>`);
window.parent.postMessage(`<?= base64_encode(json_encode($response)); ?>`);
}
</script>
```
2 changes: 1 addition & 1 deletion examples/_common-codes/3d/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent): void {
*/
let displayResponse = function (event) {
let alertBox = $('#result-alert');
let data = JSON.parse(event.data);
let data = JSON.parse(atob(event.data));
$('#result-response').append(JSON.stringify(data, null, '\t'));
if (data.status === 'approved') {
alertBox.append('payment successful');
Expand Down
4 changes: 2 additions & 2 deletions examples/_templates/_payment_secure_response.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@
if (window.opener && window.opener !== window) {
// you are in a popup
// send result data to parent window
window.opener.parent.postMessage(`<?= json_encode($response); ?>`);
window.opener.parent.postMessage(`<?= base64_encode(json_encode($response)); ?>`);
} else if (window.parent) {
// you are in iframe
// send result data to parent window
window.parent.postMessage(`<?= json_encode($response); ?>`);
window.parent.postMessage(`<?= base64_encode(json_encode($response)); ?>`);
}
</script>
<?php require __DIR__.'/_footer.php'; ?>

0 comments on commit 507aabf

Please sign in to comment.