mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add click listener for place order button
This commit is contained in:
parent
a1dfb52cbb
commit
8a4bcc55a1
1 changed files with 10 additions and 2 deletions
|
@ -75,7 +75,7 @@ const init = () => {
|
|||
clientId: ppcp_add_payment_method.client_id,
|
||||
merchantId: ppcp_add_payment_method.merchant_id,
|
||||
dataUserIdToken: ppcp_add_payment_method.id_token,
|
||||
components: 'card-fields'
|
||||
components: 'card-fields',
|
||||
}, true)
|
||||
.then((paypal) => {
|
||||
const cardField = paypal.CardFields({
|
||||
|
@ -92,7 +92,6 @@ const init = () => {
|
|||
})
|
||||
|
||||
const result = await response.json()
|
||||
|
||||
if (result.data.id) {
|
||||
return result.data.id
|
||||
}
|
||||
|
@ -147,6 +146,15 @@ const init = () => {
|
|||
cvvField.hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
document.querySelector('#place_order').addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
cardField.submit()
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue