@justifi/webcomponents 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/cjs/index-c1726348.js +1347 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/justifi-card-form_2.cjs.entry.js +4305 -0
- package/dist/cjs/justifi-webcomponents.cjs.js +19 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/collection/api/Api.js +44 -0
- package/dist/collection/api/Pagination.js +8 -0
- package/dist/collection/api/Payment.js +67 -0
- package/dist/collection/api/index.js +4 -0
- package/dist/collection/api/mockData/MockPayments.js +216 -0
- package/dist/collection/collection-manifest.json +13 -0
- package/dist/collection/components/card-form/card-form.css +9 -0
- package/dist/collection/components/card-form/card-form.js +191 -0
- package/dist/collection/components/payments-list/payments-list.css +3 -0
- package/dist/collection/components/payments-list/payments-list.js +92 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/utils.js +33 -0
- package/dist/components/index.d.ts +23 -0
- package/dist/components/index.js +3 -0
- package/dist/components/justifi-card-form.d.ts +11 -0
- package/dist/components/justifi-card-form.js +93 -0
- package/dist/components/justifi-payments-list.d.ts +11 -0
- package/dist/components/justifi-payments-list.js +4253 -0
- package/dist/esm/index-df3d4282.js +1320 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/justifi-card-form_2.entry.js +4300 -0
- package/dist/esm/justifi-webcomponents.js +17 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/justifi-webcomponents/index.esm.js +0 -0
- package/dist/justifi-webcomponents/justifi-webcomponents.esm.js +1 -0
- package/dist/justifi-webcomponents/p-3487f6b8.js +2 -0
- package/dist/justifi-webcomponents/p-69e18be7.entry.js +1 -0
- package/dist/types/api/Api.d.ts +25 -0
- package/dist/types/api/Pagination.d.ts +13 -0
- package/dist/types/api/Payment.d.ts +99 -0
- package/dist/types/api/index.d.ts +4 -0
- package/dist/types/api/mockData/MockPayments.d.ts +3 -0
- package/dist/types/components/card-form/card-form.d.ts +17 -0
- package/dist/types/components/payments-list/payments-list.d.ts +11 -0
- package/dist/types/components.d.ts +65 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1581 -0
- package/dist/types/utils/utils.d.ts +4 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +11 -0
- package/package.json +45 -0
- package/readme.md +75 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index-c1726348.js');
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Stencil Client Patch Browser v2.19.3 | MIT Licensed | https://stenciljs.com
|
|
7
|
+
*/
|
|
8
|
+
const patchBrowser = () => {
|
|
9
|
+
const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('justifi-webcomponents.cjs.js', document.baseURI).href));
|
|
10
|
+
const opts = {};
|
|
11
|
+
if (importMeta !== '') {
|
|
12
|
+
opts.resourcesUrl = new URL('.', importMeta).href;
|
|
13
|
+
}
|
|
14
|
+
return index.promiseResolve(opts);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
patchBrowser().then(options => {
|
|
18
|
+
return index.bootstrapLazy([["justifi-card-form_2.cjs",[[1,"justifi-card-form",{"iframeOrigin":[1,"iframe-origin"],"tokenize":[64]}],[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}]]]], options);
|
|
19
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-c1726348.js');
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Stencil Client Patch Esm v2.19.3 | MIT Licensed | https://stenciljs.com
|
|
9
|
+
*/
|
|
10
|
+
const patchEsm = () => {
|
|
11
|
+
return index.promiseResolve();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const defineCustomElements = (win, options) => {
|
|
15
|
+
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
|
+
return patchEsm().then(() => {
|
|
17
|
+
return index.bootstrapLazy([["justifi-card-form_2.cjs",[[1,"justifi-card-form",{"iframeOrigin":[1,"iframe-origin"],"tokenize":[64]}],[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}]]]], options);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.defineCustomElements = defineCustomElements;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
const Api = (authToken) => {
|
|
3
|
+
const apiOrigin = 'http://localhost:3000';
|
|
4
|
+
async function getAuthorizationHeader() {
|
|
5
|
+
return {
|
|
6
|
+
Authorization: `Bearer ${authToken}`,
|
|
7
|
+
'Idempotency-Key': uuidv4(),
|
|
8
|
+
'Content-Type': 'application/json'
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
async function makeRequest(endpoint, method, params, body, signal) {
|
|
12
|
+
const url = `${apiOrigin}/v1/${endpoint}`;
|
|
13
|
+
const requestUrl = params ? `${url}?${new URLSearchParams(params)}` : url;
|
|
14
|
+
const response = await fetch(requestUrl, {
|
|
15
|
+
method: method,
|
|
16
|
+
headers: await getAuthorizationHeader(),
|
|
17
|
+
body: body,
|
|
18
|
+
signal: signal
|
|
19
|
+
});
|
|
20
|
+
if (response) {
|
|
21
|
+
return response.status === 204 ? {} : response.json();
|
|
22
|
+
}
|
|
23
|
+
;
|
|
24
|
+
handleError(requestUrl);
|
|
25
|
+
}
|
|
26
|
+
;
|
|
27
|
+
async function get(endpoint, params, signal) {
|
|
28
|
+
return makeRequest(endpoint, 'GET', params, null, signal);
|
|
29
|
+
}
|
|
30
|
+
async function post(endpoint, body, params, signal) {
|
|
31
|
+
return makeRequest(endpoint, 'POST', params, body, signal);
|
|
32
|
+
}
|
|
33
|
+
async function patch(endpoint, body, params, signal) {
|
|
34
|
+
return makeRequest(endpoint, 'PATCH', params, body, signal);
|
|
35
|
+
}
|
|
36
|
+
async function destroy(endpoint, params, signal) {
|
|
37
|
+
return makeRequest(endpoint, 'DELETE', params, null, signal);
|
|
38
|
+
}
|
|
39
|
+
return { get, post, patch, destroy };
|
|
40
|
+
};
|
|
41
|
+
function handleError(requestUrl) {
|
|
42
|
+
console.error(`Error fetching from ${requestUrl}`);
|
|
43
|
+
}
|
|
44
|
+
export default Api;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export class Pagination {
|
|
2
|
+
constructor(pagination) {
|
|
3
|
+
this.has_previous = (pagination === null || pagination === void 0 ? void 0 : pagination.has_previous) || false;
|
|
4
|
+
this.has_next = (pagination === null || pagination === void 0 ? void 0 : pagination.has_next) || false;
|
|
5
|
+
this.start_cursor = (pagination === null || pagination === void 0 ? void 0 : pagination.start_cursor) || '';
|
|
6
|
+
this.end_cursor = (pagination === null || pagination === void 0 ? void 0 : pagination.end_cursor) || '';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export var CaptureStrategy;
|
|
2
|
+
(function (CaptureStrategy) {
|
|
3
|
+
CaptureStrategy["automatic"] = "automatic";
|
|
4
|
+
CaptureStrategy["manual"] = "manual";
|
|
5
|
+
})(CaptureStrategy || (CaptureStrategy = {}));
|
|
6
|
+
export var PaymentMethodTypes;
|
|
7
|
+
(function (PaymentMethodTypes) {
|
|
8
|
+
PaymentMethodTypes["card"] = "card";
|
|
9
|
+
PaymentMethodTypes["bankAccount"] = "bank_account";
|
|
10
|
+
})(PaymentMethodTypes || (PaymentMethodTypes = {}));
|
|
11
|
+
export var PaymentStatuses;
|
|
12
|
+
(function (PaymentStatuses) {
|
|
13
|
+
PaymentStatuses["pending"] = "pending";
|
|
14
|
+
PaymentStatuses["authorized"] = "authorized";
|
|
15
|
+
PaymentStatuses["succeeded"] = "succeeded";
|
|
16
|
+
PaymentStatuses["failed"] = "failed";
|
|
17
|
+
PaymentStatuses["disputed"] = "disputed";
|
|
18
|
+
PaymentStatuses["fully_refunded"] = "fully_refunded";
|
|
19
|
+
PaymentStatuses["partially_refunded"] = "partially_refunded";
|
|
20
|
+
})(PaymentStatuses || (PaymentStatuses = {}));
|
|
21
|
+
export var PaymentDisputedStatuses;
|
|
22
|
+
(function (PaymentDisputedStatuses) {
|
|
23
|
+
// if a dispute is 'won', we don't show a dispute status, just general status
|
|
24
|
+
PaymentDisputedStatuses["lost"] = "lost";
|
|
25
|
+
PaymentDisputedStatuses["open"] = "open";
|
|
26
|
+
})(PaymentDisputedStatuses || (PaymentDisputedStatuses = {}));
|
|
27
|
+
export class Payment {
|
|
28
|
+
constructor(payment) {
|
|
29
|
+
this.id = payment.id;
|
|
30
|
+
this.account_id = payment.account_id;
|
|
31
|
+
this.amount = payment.amount;
|
|
32
|
+
this.amount_disputed = payment.amount_disputed;
|
|
33
|
+
this.amount_refundable = payment.amount_refundable;
|
|
34
|
+
this.amount_refunded = payment.amount_refunded;
|
|
35
|
+
this.balance = payment.balance;
|
|
36
|
+
this.captured = payment.captured;
|
|
37
|
+
this.capture_strategy = payment.capture_strategy;
|
|
38
|
+
this.currency = payment.currency;
|
|
39
|
+
this.description = payment.description;
|
|
40
|
+
this.disputed = payment.disputed;
|
|
41
|
+
this.disputes = payment.disputes;
|
|
42
|
+
this.error_code = payment.error_code;
|
|
43
|
+
this.error_description = payment.error_description;
|
|
44
|
+
this.fee_amount = payment.fee_amount;
|
|
45
|
+
this.is_test = payment.is_test;
|
|
46
|
+
this.metadata = payment.metadata;
|
|
47
|
+
this.payment_method = payment.payment_method;
|
|
48
|
+
this.payment_intent_id = payment.payment_intent_id;
|
|
49
|
+
this.refunded = payment.refunded;
|
|
50
|
+
this.status = payment.status;
|
|
51
|
+
this.created_at = payment.created_at;
|
|
52
|
+
this.updated_at = payment.updated_at;
|
|
53
|
+
}
|
|
54
|
+
get disputedStatus() {
|
|
55
|
+
const lost = this.disputes.some((dispute) => dispute.status === PaymentDisputedStatuses.lost);
|
|
56
|
+
// if a dispute is 'won', we don't show a dispute status, just general status
|
|
57
|
+
if (!this.disputed) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
else if (lost) {
|
|
61
|
+
return PaymentDisputedStatuses.lost;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return PaymentDisputedStatuses.open;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { CaptureStrategy, Payment, PaymentStatuses } from '../Payment';
|
|
2
|
+
const mockPayments = [
|
|
3
|
+
// payment 0: succeeded
|
|
4
|
+
new Payment({
|
|
5
|
+
account_id: 'acc_5wEk41rFZVPsqK5xQ7K0eG',
|
|
6
|
+
amount: 363393,
|
|
7
|
+
amount_disputed: 0,
|
|
8
|
+
amount_refundable: 363393,
|
|
9
|
+
amount_refunded: 0,
|
|
10
|
+
balance: 363368,
|
|
11
|
+
capture_strategy: CaptureStrategy.automatic,
|
|
12
|
+
captured: true,
|
|
13
|
+
created_at: '2022-01-10T15:29:58.940Z',
|
|
14
|
+
currency: 'usd',
|
|
15
|
+
description: 'Successful Payment',
|
|
16
|
+
disputed: false,
|
|
17
|
+
disputes: [],
|
|
18
|
+
error_code: null,
|
|
19
|
+
error_description: null,
|
|
20
|
+
fee_amount: 25,
|
|
21
|
+
id: 'py_6vbEiTROeuEoA1Hs1s2exQ',
|
|
22
|
+
is_test: false,
|
|
23
|
+
metadata: {
|
|
24
|
+
city: 'Vienna',
|
|
25
|
+
state: 'Nevada',
|
|
26
|
+
customer_id: 234,
|
|
27
|
+
customer_first_name: 'Elvis',
|
|
28
|
+
customer_last_name: 'Presley',
|
|
29
|
+
source: 'app',
|
|
30
|
+
items: [
|
|
31
|
+
{
|
|
32
|
+
name: 'Pullover',
|
|
33
|
+
amount: 4500
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Jeans',
|
|
37
|
+
amount: 5567
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
payment_intent_id: null,
|
|
42
|
+
payment_method: {
|
|
43
|
+
card: {
|
|
44
|
+
acct_last_four: '6449',
|
|
45
|
+
brand: 'mastercard',
|
|
46
|
+
created_at: '2022-01-13T14:19:11.803Z',
|
|
47
|
+
id: 'pm_7f66GJQoSofG3s9nOHPgaq',
|
|
48
|
+
name: 'Nick Name',
|
|
49
|
+
token: 'fake-token',
|
|
50
|
+
updated_at: '2022-01-13T14:19:11.803Z'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
refunded: false,
|
|
54
|
+
status: PaymentStatuses.succeeded,
|
|
55
|
+
updated_at: '2022-01-10T15:29:58.940Z'
|
|
56
|
+
}),
|
|
57
|
+
// payment 1: fully refunded
|
|
58
|
+
new Payment({
|
|
59
|
+
account_id: 'acc_5wEk41rFZVPsqK5xQ7K0eG',
|
|
60
|
+
amount: 3393,
|
|
61
|
+
amount_disputed: 0,
|
|
62
|
+
amount_refundable: 0,
|
|
63
|
+
amount_refunded: 3393,
|
|
64
|
+
balance: 0,
|
|
65
|
+
capture_strategy: CaptureStrategy.automatic,
|
|
66
|
+
captured: true,
|
|
67
|
+
created_at: '2021-01-10T15:29:58.940Z',
|
|
68
|
+
currency: 'usd',
|
|
69
|
+
description: 'Fully Refunded Payment',
|
|
70
|
+
disputed: false,
|
|
71
|
+
disputes: [],
|
|
72
|
+
error_code: null,
|
|
73
|
+
error_description: null,
|
|
74
|
+
fee_amount: 25,
|
|
75
|
+
id: 'py_22cEiTROeuEoA1Hs1s24ls3',
|
|
76
|
+
is_test: false,
|
|
77
|
+
metadata: null,
|
|
78
|
+
payment_intent_id: null,
|
|
79
|
+
payment_method: {
|
|
80
|
+
card: {
|
|
81
|
+
acct_last_four: '1213',
|
|
82
|
+
brand: 'visa',
|
|
83
|
+
created_at: '2021-01-13T14:19:11.803Z',
|
|
84
|
+
id: 'pm_7f66GJQoSofG3s9nOHPgaq',
|
|
85
|
+
name: 'Good Customer',
|
|
86
|
+
token: 'fake-token',
|
|
87
|
+
updated_at: '2021-01-13T14:19:11.803Z'
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
refunded: true,
|
|
91
|
+
status: PaymentStatuses.fully_refunded,
|
|
92
|
+
updated_at: '2021-01-10T15:29:58.940Z'
|
|
93
|
+
}),
|
|
94
|
+
// payment 2: partially refunded
|
|
95
|
+
new Payment({
|
|
96
|
+
account_id: 'acc_5wEk41rFZVPsqK5xQ7K0eG',
|
|
97
|
+
amount: 3393,
|
|
98
|
+
amount_disputed: 0,
|
|
99
|
+
amount_refundable: 3300,
|
|
100
|
+
amount_refunded: 193,
|
|
101
|
+
balance: 3275,
|
|
102
|
+
capture_strategy: CaptureStrategy.automatic,
|
|
103
|
+
captured: true,
|
|
104
|
+
created_at: '2021-11-10T15:29:58.940Z',
|
|
105
|
+
currency: 'usd',
|
|
106
|
+
description: 'Partially Refunded Payment',
|
|
107
|
+
disputed: false,
|
|
108
|
+
disputes: [],
|
|
109
|
+
error_code: null,
|
|
110
|
+
error_description: null,
|
|
111
|
+
fee_amount: 25,
|
|
112
|
+
id: 'py_8reEiTROeuEoA1Hs1s24zue',
|
|
113
|
+
is_test: false,
|
|
114
|
+
metadata: null,
|
|
115
|
+
payment_intent_id: null,
|
|
116
|
+
payment_method: {
|
|
117
|
+
card: {
|
|
118
|
+
acct_last_four: '9780',
|
|
119
|
+
brand: 'american_express',
|
|
120
|
+
created_at: '2021-11-13T14:19:11.803Z',
|
|
121
|
+
id: 'pm_7f66GJQoSofG3s9nOHPgaq',
|
|
122
|
+
name: 'Sal Gleason',
|
|
123
|
+
token: 'fake-token',
|
|
124
|
+
updated_at: '2021-11-13T14:19:11.803Z'
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
refunded: true,
|
|
128
|
+
status: PaymentStatuses.partially_refunded,
|
|
129
|
+
updated_at: '2022-01-10T15:29:58.940Z'
|
|
130
|
+
}),
|
|
131
|
+
// payment 3: disputed
|
|
132
|
+
new Payment({
|
|
133
|
+
account_id: 'acc_5wEk41rFZVPsqK5xQ7K0eG',
|
|
134
|
+
amount: 403393,
|
|
135
|
+
amount_disputed: 403393,
|
|
136
|
+
amount_refundable: 0,
|
|
137
|
+
amount_refunded: 0,
|
|
138
|
+
balance: 0,
|
|
139
|
+
capture_strategy: CaptureStrategy.automatic,
|
|
140
|
+
captured: true,
|
|
141
|
+
created_at: '2021-09-10T15:29:58.940Z',
|
|
142
|
+
currency: 'usd',
|
|
143
|
+
description: 'Rustic Marble Pants',
|
|
144
|
+
disputed: true,
|
|
145
|
+
disputes: [{
|
|
146
|
+
amount_cents: 10000,
|
|
147
|
+
created_at: '2021-09-10T16:34:47.940Z',
|
|
148
|
+
currency: 'usd',
|
|
149
|
+
gateway_ref_id: 'dp_4f67775b-d6e0-4c4a-afb0-6ecf2d0df1a8',
|
|
150
|
+
id: 'ed5dfa9d-b29d-4658-b76d-fff0c592171f',
|
|
151
|
+
payment_id: '41ebfb2a-f8c8-4cee-9eca-cb7d86e863bc',
|
|
152
|
+
reason: null,
|
|
153
|
+
status: 'needs_response',
|
|
154
|
+
updated_at: '2021-09-10T16:34:47.940Z'
|
|
155
|
+
}],
|
|
156
|
+
error_code: null,
|
|
157
|
+
error_description: null,
|
|
158
|
+
fee_amount: 35,
|
|
159
|
+
id: 'py_123EiTROeuEoA1Hs1s24r4w',
|
|
160
|
+
is_test: false,
|
|
161
|
+
metadata: null,
|
|
162
|
+
payment_intent_id: null,
|
|
163
|
+
payment_method: {
|
|
164
|
+
card: {
|
|
165
|
+
acct_last_four: '1554',
|
|
166
|
+
brand: 'discover',
|
|
167
|
+
created_at: '2021-09-13T14:19:11.803Z',
|
|
168
|
+
id: 'pm_7f66GJQoSofG3s9nOHPgaq',
|
|
169
|
+
name: 'Sal Gleason',
|
|
170
|
+
token: 'fake-token',
|
|
171
|
+
updated_at: '2021-09-13T14:19:11.803Z'
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
refunded: false,
|
|
175
|
+
status: PaymentStatuses.disputed,
|
|
176
|
+
updated_at: '2021-09-10T15:29:58.940Z'
|
|
177
|
+
}),
|
|
178
|
+
// payment 4: failed
|
|
179
|
+
new Payment({
|
|
180
|
+
account_id: 'acc_5wEk41rFZVPsqK5xQ7K0eG',
|
|
181
|
+
amount: 24170,
|
|
182
|
+
amount_disputed: 0,
|
|
183
|
+
amount_refundable: 0,
|
|
184
|
+
amount_refunded: 0,
|
|
185
|
+
balance: 0,
|
|
186
|
+
capture_strategy: CaptureStrategy.automatic,
|
|
187
|
+
captured: false,
|
|
188
|
+
created_at: '2022-01-18T12:54:44.822Z',
|
|
189
|
+
currency: 'usd',
|
|
190
|
+
description: 'Failed Payment',
|
|
191
|
+
disputed: false,
|
|
192
|
+
disputes: [],
|
|
193
|
+
error_code: 'card_declined',
|
|
194
|
+
error_description: 'Your card has insufficient funds.',
|
|
195
|
+
fee_amount: 25,
|
|
196
|
+
id: 'py_6eZAJjYBFZU6LLNzxUDgx9',
|
|
197
|
+
is_test: true,
|
|
198
|
+
metadata: null,
|
|
199
|
+
payment_intent_id: null,
|
|
200
|
+
payment_method: {
|
|
201
|
+
card: {
|
|
202
|
+
acct_last_four: '8774',
|
|
203
|
+
brand: 'diners_club',
|
|
204
|
+
created_at: '2022-01-18T15:07:15.975Z',
|
|
205
|
+
id: 'pm_5uyevnE6o1yl55nRgPWXXL',
|
|
206
|
+
name: 'Minnie Bernhard',
|
|
207
|
+
token: 'fake-token',
|
|
208
|
+
updated_at: '2022-01-18T15:07:15.975Z'
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
refunded: false,
|
|
212
|
+
status: PaymentStatuses.failed,
|
|
213
|
+
updated_at: '2022-01-18T12:54:44.822Z'
|
|
214
|
+
})
|
|
215
|
+
];
|
|
216
|
+
export default mockPayments;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"entries": [
|
|
3
|
+
"./components/card-form/card-form.js",
|
|
4
|
+
"./components/payments-list/payments-list.js"
|
|
5
|
+
],
|
|
6
|
+
"compiler": {
|
|
7
|
+
"name": "@stencil/core",
|
|
8
|
+
"version": "2.19.3",
|
|
9
|
+
"typescriptVersion": "4.7.4"
|
|
10
|
+
},
|
|
11
|
+
"collections": [],
|
|
12
|
+
"bundles": []
|
|
13
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { Host, h } from '@stencil/core';
|
|
2
|
+
var DispatchedEventTypes;
|
|
3
|
+
(function (DispatchedEventTypes) {
|
|
4
|
+
DispatchedEventTypes["blur"] = "blur";
|
|
5
|
+
DispatchedEventTypes["change"] = "change";
|
|
6
|
+
DispatchedEventTypes["ready"] = "ready";
|
|
7
|
+
DispatchedEventTypes["tokenize"] = "tokenize";
|
|
8
|
+
})(DispatchedEventTypes || (DispatchedEventTypes = {}));
|
|
9
|
+
export class CardForm {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.iframeOrigin = undefined;
|
|
12
|
+
}
|
|
13
|
+
connectedCallback() {
|
|
14
|
+
window.addEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
15
|
+
}
|
|
16
|
+
disconnectedCallback() {
|
|
17
|
+
window.removeEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
18
|
+
}
|
|
19
|
+
dispatchMessageEvent(messageEvent) {
|
|
20
|
+
const messagePayload = messageEvent.data;
|
|
21
|
+
const messageType = messagePayload.eventType;
|
|
22
|
+
const messageData = messagePayload.data;
|
|
23
|
+
switch (messageType) {
|
|
24
|
+
case DispatchedEventTypes.ready:
|
|
25
|
+
this.cardFormReady.emit(messageData);
|
|
26
|
+
break;
|
|
27
|
+
case DispatchedEventTypes.change:
|
|
28
|
+
this.cardFormChange.emit(messageData);
|
|
29
|
+
break;
|
|
30
|
+
case DispatchedEventTypes.blur:
|
|
31
|
+
this.cardFormBlur.emit(messageData);
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
triggerTokenization(clientKey, account, paymentMethodMetadata) {
|
|
38
|
+
if (this.iframeElement && this.iframeElement.contentWindow) {
|
|
39
|
+
this.iframeElement.contentWindow.postMessage({
|
|
40
|
+
eventType: DispatchedEventTypes.tokenize,
|
|
41
|
+
clientKey: clientKey,
|
|
42
|
+
paymentMethodMetadata: paymentMethodMetadata,
|
|
43
|
+
account: account
|
|
44
|
+
}, '*');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async tokenize(clientKey, account, paymentMethodMetadata) {
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
const tokenizeEventListener = (event) => {
|
|
50
|
+
if (event.data.eventType !== DispatchedEventTypes.tokenize)
|
|
51
|
+
return;
|
|
52
|
+
window.removeEventListener('message', tokenizeEventListener);
|
|
53
|
+
resolve(event.data.data);
|
|
54
|
+
};
|
|
55
|
+
window.addEventListener('message', tokenizeEventListener);
|
|
56
|
+
this.triggerTokenization(clientKey, account, paymentMethodMetadata);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
;
|
|
60
|
+
render() {
|
|
61
|
+
return (h(Host, null, h("iframe", { id: "justifi-card-form", src: this.iframeOrigin || 'https://js.justifi.ai', ref: (el) => this.iframeElement = el })));
|
|
62
|
+
}
|
|
63
|
+
static get is() { return "justifi-card-form"; }
|
|
64
|
+
static get encapsulation() { return "shadow"; }
|
|
65
|
+
static get originalStyleUrls() {
|
|
66
|
+
return {
|
|
67
|
+
"$": ["card-form.css"]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
static get styleUrls() {
|
|
71
|
+
return {
|
|
72
|
+
"$": ["card-form.css"]
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
static get properties() {
|
|
76
|
+
return {
|
|
77
|
+
"iframeOrigin": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"mutable": false,
|
|
80
|
+
"complexType": {
|
|
81
|
+
"original": "string",
|
|
82
|
+
"resolved": "string",
|
|
83
|
+
"references": {}
|
|
84
|
+
},
|
|
85
|
+
"required": false,
|
|
86
|
+
"optional": false,
|
|
87
|
+
"docs": {
|
|
88
|
+
"tags": [],
|
|
89
|
+
"text": ""
|
|
90
|
+
},
|
|
91
|
+
"attribute": "iframe-origin",
|
|
92
|
+
"reflect": false
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
static get events() {
|
|
97
|
+
return [{
|
|
98
|
+
"method": "cardFormReady",
|
|
99
|
+
"name": "cardFormReady",
|
|
100
|
+
"bubbles": true,
|
|
101
|
+
"cancelable": true,
|
|
102
|
+
"composed": true,
|
|
103
|
+
"docs": {
|
|
104
|
+
"tags": [],
|
|
105
|
+
"text": ""
|
|
106
|
+
},
|
|
107
|
+
"complexType": {
|
|
108
|
+
"original": "any",
|
|
109
|
+
"resolved": "any",
|
|
110
|
+
"references": {}
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
"method": "cardFormChange",
|
|
114
|
+
"name": "cardFormChange",
|
|
115
|
+
"bubbles": true,
|
|
116
|
+
"cancelable": true,
|
|
117
|
+
"composed": true,
|
|
118
|
+
"docs": {
|
|
119
|
+
"tags": [],
|
|
120
|
+
"text": ""
|
|
121
|
+
},
|
|
122
|
+
"complexType": {
|
|
123
|
+
"original": "any",
|
|
124
|
+
"resolved": "any",
|
|
125
|
+
"references": {}
|
|
126
|
+
}
|
|
127
|
+
}, {
|
|
128
|
+
"method": "cardFormBlur",
|
|
129
|
+
"name": "cardFormBlur",
|
|
130
|
+
"bubbles": true,
|
|
131
|
+
"cancelable": true,
|
|
132
|
+
"composed": true,
|
|
133
|
+
"docs": {
|
|
134
|
+
"tags": [],
|
|
135
|
+
"text": ""
|
|
136
|
+
},
|
|
137
|
+
"complexType": {
|
|
138
|
+
"original": "any",
|
|
139
|
+
"resolved": "any",
|
|
140
|
+
"references": {}
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
"method": "cardFormTokenize",
|
|
144
|
+
"name": "cardFormTokenize",
|
|
145
|
+
"bubbles": true,
|
|
146
|
+
"cancelable": true,
|
|
147
|
+
"composed": true,
|
|
148
|
+
"docs": {
|
|
149
|
+
"tags": [],
|
|
150
|
+
"text": ""
|
|
151
|
+
},
|
|
152
|
+
"complexType": {
|
|
153
|
+
"original": "{ data: any }",
|
|
154
|
+
"resolved": "{ data: any; }",
|
|
155
|
+
"references": {}
|
|
156
|
+
}
|
|
157
|
+
}];
|
|
158
|
+
}
|
|
159
|
+
static get methods() {
|
|
160
|
+
return {
|
|
161
|
+
"tokenize": {
|
|
162
|
+
"complexType": {
|
|
163
|
+
"signature": "(clientKey: string, account: string, paymentMethodMetadata: any) => Promise<unknown>",
|
|
164
|
+
"parameters": [{
|
|
165
|
+
"tags": [],
|
|
166
|
+
"text": ""
|
|
167
|
+
}, {
|
|
168
|
+
"tags": [],
|
|
169
|
+
"text": ""
|
|
170
|
+
}, {
|
|
171
|
+
"tags": [],
|
|
172
|
+
"text": ""
|
|
173
|
+
}],
|
|
174
|
+
"references": {
|
|
175
|
+
"Promise": {
|
|
176
|
+
"location": "global"
|
|
177
|
+
},
|
|
178
|
+
"MessageEvent": {
|
|
179
|
+
"location": "global"
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
"return": "Promise<unknown>"
|
|
183
|
+
},
|
|
184
|
+
"docs": {
|
|
185
|
+
"text": "",
|
|
186
|
+
"tags": []
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|