Render Apple Pay and Google Pay buttons for payments via Datatrans. Buttons are only rendered if the client supports any of the mentioned payment methods.
constpaymentButton=newPaymentButton();paymentButton.init({merchantId: '1100002476',merchantName: 'Test',useGooglePay: true,useApplePay: true,auto: true,allowedCardNetworks: ['AMEX','DISCOVER','MASTERCARD','VISA'],googlePayConfiguration: {buttonType: 'long',buttonStyle: 'black',merchantId: '01234567890123456789'},applePayConfiguration: {buttonType: 'plain',buttonStyle: 'black'}})paymentButton.on('init',function(){$('.console-content').append('init event dispatched <br>')paymentButton.create(document.getElementById('paybutton'),payment)})paymentButton.on('create',function(){$('.console-content').append('create event dispatched <br>')})paymentButton.on('authorization',function(response){$('.console-content').append('authorization response:'+'<br>'+response+'<br>')})paymentButton.on('abort',function(){$('.console-content').append('Payment request aborted'+'<br>')})paymentButton.on('error',function(error){$('.console-content').append('Error:'+JSON.stringify(error)+'<br>')})paymentButton.on('unsupported',function(){$('.console-content').append('Payment method not supported in this browser <br>')})The following events can be subscribed to:
init- emitted when the library was initializedcreate- emitted when all buttons were renderedauthorization- emitted when the authorization process has completedtoken- emitted when a token was received from the payment provider (iftokenOnlyis set totrue)abort- emitted when the payment request was abortederror- emitted when an error happensunsupported- emitted when no payment method is supported by the client