https://github.com/datatrans/payment-button
Datatrans Payment Button integration (Apple Pay, Google Pay)
https://github.com/datatrans/payment-button
Last synced: 4 months ago
JSON representation
Datatrans Payment Button integration (Apple Pay, Google Pay)
- Host: GitHub
- URL: https://github.com/datatrans/payment-button
- Owner: datatrans
- License: mit
- Created: 2019-11-21T15:05:43.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-05-13T09:42:51.000Z (about 1 year ago)
- Last Synced: 2025-05-13T10:42:50.164Z (about 1 year ago)
- Language: HTML
- Homepage: https://paymentbutton.datatrans.dev
- Size: 242 KB
- Stars: 2
- Watchers: 6
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Datatrans Payment Button
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.
## Usage example
```js
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
')
PaymentButton.create(document.getElementById('paybutton'), payment)
})
PaymentButton.on('create', function () {
$('.console-content').append('create event dispatched
')
})
PaymentButton.on('authorization', function (response) {
$('.console-content').append('authorization response:' + '
' + response + '
')
})
PaymentButton.on('abort', function () {
$('.console-content').append('Payment request aborted' + '
')
})
PaymentButton.on('error', function (error) {
$('.console-content').append('Error:' + JSON.stringify(error) + '
')
})
PaymentButton.on('unsupported', function () {
$('.console-content').append('Payment method not supported in this browser
')
})
```
## Events
The following events can be subscribed to:
- `initialized` - emitted when the library was initialized
- `created` - emitted when all buttons were rendered
- `authorization` - emitted when the authorization process has completed
- `abort` - emitted when the payment request was aborted
- `error` - emitted when an error happens
- `unsupported` - emitted when no payment method is supported by the client