-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgooglepay-example.js
More file actions
38 lines (34 loc) · 973 Bytes
/
googlepay-example.js
File metadata and controls
38 lines (34 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Payload('test_client_key_3bcr16ohAy8aEcwK3Vffs')
const paymentsClient = new google.payments.api.PaymentsClient({
environment: 'TEST',
})
const button = paymentsClient.createButton({
onClick: () => console.log('TODO: click handler'),
})
$('.google-pay-support>div').html(button)
const checkoutForm = new Payload.Form({
form: $('#checkout-form').get(0),
styles: { invalid: 'is-invalid' },
preventDefaultOnSubmit: true,
payment: {
processing_id: 'acct_3bcr6L5qxxnXJjNwu4MHg',
},
})
checkoutForm
.on('declined', function (error) {
console.log(error)
})
.on('error', function (error) {
console.log(error)
})
.on('processed', function (data) {
$('#paid-modal .alert').html('Transaction ID: ' + data.transaction_id)
$('#paid-modal').modal('show')
})
.googlepay(button, function (active) {
if (!active) {
$('#google-pay')
.tooltip({ title: 'Google Pay not available' })
.addClass('disabled')
}
})