Skip to content

Commit

Permalink
Add onAvailable event for Apple Pay (#82)
Browse files Browse the repository at this point in the history
Co-authored-by: Dimitri BOUTEILLE <[email protected]>
Co-authored-by: Can Demiralp <[email protected]>
  • Loading branch information
3 people authored Apr 15, 2024
1 parent fe219b3 commit a1638cf
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions view/frontend/web/js/applepay/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,28 @@ define([
this.applePayComponent
.isAvailable()
.then(() => {
element.style.display = 'block';
this.applePayComponent.mount(element);
}).catch((e) => {
this.onAvailable(element);
})
.catch((e) => {
this.onNotAvailable(e);
});
},

/**
* @param {*} error
*/
onNotAvailable: function (error) {
console.log('Apple pay is unavailable.', error);
},

/**
* @param {HTMLElement} element
*/
onAvailable: function (element) {
element.style.display = 'block';
this.applePayComponent.mount(element);
},

unmountApplePay: function () {
if (this.applePayComponent) {
this.applePayComponent.unmount();
Expand Down

0 comments on commit a1638cf

Please sign in to comment.