Skip to content

Commit

Permalink
PSPAYPAL-879 remove bug with vaulting checkout button
Browse files Browse the repository at this point in the history
  • Loading branch information
René Gust committed Jan 9, 2025
1 parent 0afa9f6 commit 706bbb1
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 41 deletions.
2 changes: 1 addition & 1 deletion out/src/js/paypal-frontend.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions resources/build/js/paypal-frontend-paypal-vault-checkout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function registerClickListenerForSavedVaultRadioButtons() {
document.querySelectorAll(".vaulting_paymentsource").forEach(function (paymentsource) {
paymentsource.onclick = function () {
if (paymentsource.checked) {
document.getElementById("paypalVaultCheckoutButton").disabled = false;
}
};
});
}

// clicking the vault checkout button will submit the form for payment
function registerClickListenerForTheVaultCheckoutButton() {
document.getElementById("paypalVaultCheckoutButton").onclick = function () {
document.querySelectorAll(".vaulting_paymentsource").forEach(function (paymentsource) {
if (paymentsource.checked) {
document.getElementById("payment_oscpaypal").click();

let input = document.createElement("input");
input.type = "hidden";
input.name = "vaultingpaymentsource";
input.value = paymentsource.dataset.index;
document.getElementById("payment").appendChild(input);

document.getElementById("paymentNextStepBottom").click();
}
});
};
}

document.addEventListener("DOMContentLoaded", function() {
registerClickListenerForSavedVaultRadioButtons();
registerClickListenerForTheVaultCheckoutButton();
});
1 change: 1 addition & 0 deletions resources/grunt/concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
"build/js/paypal-frontend-googlepay.js",
"build/js/paypal-frontend-googlepay-3ds.js",
"build/js/paypal-frontend-hateoaslinks.js",
"build/js/paypal-frontend-paypal-vault-checkout.js",
]
}
}
Expand Down
1 change: 1 addition & 0 deletions resources/grunt/uglify.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
"build/js/paypal-frontend-googlepay.js",
"build/js/paypal-frontend-googlepay-3ds.js",
"build/js/paypal-frontend-hateoaslinks.js",
"build/js/paypal-frontend-paypal-vault-checkout.js",
]
}
}
Expand Down
21 changes: 1 addition & 20 deletions views/tpl/flow/page/checkout/change_payment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,13 @@
<button type="submit" name="userform"
class="btn btn-primary pull-right submitButton nextStep largeButton"
id="paypalVaultCheckoutButton"
disabled
>
[{oxmultilang ident="OSC_PAYPAL_CONTINUE_TO_NEXT_STEP"}] <i class="fa fa-caret-right"></i>
</button>
</div>
</div>
</div>

<script>
window.onload = function () {
document.getElementById("paypalVaultCheckoutButton").onclick = function () {
document.querySelectorAll(".vaulting_paymentsource").forEach(function (paymentsource) {
if (paymentsource.checked) {
document.getElementById("payment_oscpaypal").click();
let input = document.createElement("input");
input.type = "hidden";
input.name = "vaultingpaymentsource";
input.value = paymentsource.dataset.index;
document.getElementById("payment").appendChild(input);
document.getElementById("paymentNextStepBottom").click();
}
});
}
}
</script>
[{/if}]

[{if 'oscpaypal_express'|array_key_exists:$oView->getPaymentList() && $oViewConf->isPayPalExpressSessionActive()}]
Expand Down
21 changes: 1 addition & 20 deletions views/tpl/wave/page/checkout/change_payment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,13 @@
<button type="submit" name="userform"
class="btn btn-primary pull-right submitButton nextStep largeButton"
id="paypalVaultCheckoutButton"
disabled
>
[{oxmultilang ident="OSC_PAYPAL_CONTINUE_TO_NEXT_STEP"}] <i class="fa fa-caret-right"></i>
</button>
</div>
</div>
</div>

<script>
window.onload = function () {
document.getElementById("paypalVaultCheckoutButton").onclick = function () {
document.querySelectorAll(".vaulting_paymentsource").forEach(function (paymentsource) {
if (paymentsource.checked) {
document.getElementById("payment_oscpaypal").click();
let input = document.createElement("input");
input.type = "hidden";
input.name = "vaultingpaymentsource";
input.value = paymentsource.dataset.index;
document.getElementById("payment").appendChild(input);
document.getElementById("paymentNextStepBottom").click();
}
});
}
}
</script>
[{/if}]
[{if 'oscpaypal_express'|array_key_exists:$oView->getPaymentList() && $oViewConf->isPayPalExpressSessionActive()}]
[{assign var="config" value=$oViewConf->getPayPalCheckoutConfig()}]
Expand Down

0 comments on commit 706bbb1

Please sign in to comment.