@justifi/webcomponents 4.7.6 → 4.8.0
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/dist/cjs/Business-540a6feb.js +67 -0
- package/dist/cjs/BusinessFormEventTypes-863f48e9.js +42 -0
- package/dist/cjs/{Payout-7821eb61.js → Payout-44b49b2d.js} +2 -1
- package/dist/cjs/additional-questions-details_5.cjs.entry.js +4 -4
- package/dist/cjs/{business-form-schema-a2b87e77.js → business-form-schema-37e5381d.js} +17 -17
- package/dist/cjs/{form-control-datepart_2.cjs.entry.js → form-control-datepart_3.cjs.entry.js} +45 -2
- package/dist/cjs/{form-control-number_3.cjs.entry.js → form-control-select_2.cjs.entry.js} +0 -43
- package/dist/cjs/form-input-masks-e3bf2614.js +9 -0
- package/dist/cjs/{index.esm-c08c2adc.js → index.esm-d25bd7bf.js} +0 -259
- package/dist/cjs/{justifi-additional-questions_6.cjs.entry.js → justifi-additional-questions_5.cjs.entry.js} +9 -279
- package/dist/cjs/justifi-billing-form_2.cjs.entry.js +1 -1
- package/dist/cjs/justifi-business-details.cjs.entry.js +5 -5
- package/dist/cjs/justifi-business-form-stepped.cjs.entry.js +46 -52
- package/dist/cjs/justifi-business-form.cjs.entry.js +31 -35
- package/dist/cjs/justifi-business-list.cjs.entry.js +3 -50
- package/dist/cjs/justifi-business-owners.cjs.entry.js +78 -0
- package/dist/cjs/justifi-details.cjs.entry.js +1 -1
- package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payment-balance-transactions.cjs.entry.js +1 -1
- package/dist/cjs/justifi-payment-details.cjs.entry.js +43 -42
- package/dist/cjs/justifi-payment-form.cjs.entry.js +1 -1
- package/dist/cjs/justifi-payment-method-form.cjs.entry.js +6 -4
- package/dist/cjs/justifi-payments-list.cjs.entry.js +46 -90
- package/dist/cjs/justifi-payout-details.cjs.entry.js +47 -45
- package/dist/cjs/justifi-payouts-list.cjs.entry.js +46 -112
- package/dist/cjs/justifi-proceeds-list.cjs.entry.js +1 -1
- package/dist/cjs/justifi-refund-form.cjs.entry.js +2 -2
- package/dist/cjs/justifi-subaccount-details.cjs.entry.js +2 -2
- package/dist/cjs/justifi-subaccounts-list.cjs.entry.js +1 -1
- package/dist/cjs/justifi-table_2.cjs.entry.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/payment-details-core.cjs.entry.js +52 -0
- package/dist/cjs/payment.service-605896dc.js +20 -0
- package/dist/cjs/payments-list-core.cjs.entry.js +98 -0
- package/dist/cjs/payout-details-core.cjs.entry.js +52 -0
- package/dist/cjs/payout.service-b39f2739.js +21 -0
- package/dist/cjs/payouts-list-core.cjs.entry.js +121 -0
- package/dist/cjs/subaccount-account-details_4.cjs.entry.js +1 -1
- package/dist/cjs/subaccount-bank-details.cjs.entry.js +1 -1
- package/dist/cjs/subaccount-terms-details.cjs.entry.js +1 -1
- package/dist/cjs/{utils-99c086ee.js → utils-d126d17c.js} +4 -4
- package/dist/cjs/utils-f5d82f21.js +10 -0
- package/dist/cjs/webcomponents.cjs.js +1 -1
- package/dist/collection/api/Business.js +18 -3
- package/dist/collection/api/Payment.js +2 -1
- package/dist/collection/api/mockData/MockPayments.js +25 -0
- package/dist/collection/api/services/payment.service.js +13 -0
- package/dist/collection/api/services/payout.service.js +14 -0
- package/dist/collection/api/services/utils.js +6 -0
- package/dist/collection/collection-manifest.json +4 -0
- package/dist/collection/components/business-details/additional-questions-details/additional-questions-details.js +8 -8
- package/dist/collection/components/business-details/business-details.js +3 -3
- package/dist/collection/components/business-form/BusinessFormEventTypes.js +6 -0
- package/dist/collection/components/business-form/business-address/business-address-form-schema.js +1 -1
- package/dist/collection/components/business-form/business-form-schema.js +16 -16
- package/dist/collection/components/business-form/business-form-stepped.js +77 -50
- package/dist/collection/components/business-form/business-form.js +62 -33
- package/dist/collection/components/business-form/business-generic-info/business-generic-info.js +7 -3
- package/dist/collection/components/business-form/business-owners/business-owners.js +6 -21
- package/dist/collection/components/business-form/business-representative/business-representative.js +1 -1
- package/dist/collection/components/business-form/helpers.js +21 -20
- package/dist/collection/components/business-form/legal-address-form/legal-address-form-schema.js +1 -1
- package/dist/collection/components/business-form/legal-address-form/legal-address-form.js +1 -2
- package/dist/collection/components/business-form/test/business-form.spec.js +5 -14
- package/dist/collection/components/details/utils.js +2 -2
- package/dist/collection/components/pagination-menu/test/pagination-menu.spec.js +87 -0
- package/dist/collection/components/payment-details/get-payment-details.js +17 -0
- package/dist/collection/components/payment-details/payment-details-core.js +86 -0
- package/dist/collection/components/payment-details/payment-details.js +27 -52
- package/dist/collection/components/payment-details/test/get-payment-details.spec.js +64 -0
- package/dist/collection/components/payment-details/test/payment-details-core.spec.js +47 -0
- package/dist/collection/components/payment-details/test/payment-details.spec.js +31 -0
- package/dist/collection/components/payments-list/get-payments.js +20 -0
- package/dist/collection/components/payments-list/payments-list-core.js +158 -0
- package/dist/collection/components/payments-list/payments-list.js +27 -127
- package/dist/collection/components/payments-list/test/get-payments.spec.js +70 -0
- package/dist/collection/components/payments-list/test/payments-list-core.spec.js +100 -0
- package/dist/collection/components/payments-list/test/payments-list.spec.js +17 -21
- package/dist/collection/components/payout-details/get-payout-details.js +20 -0
- package/dist/collection/components/payout-details/payout-details-core.js +86 -0
- package/dist/collection/components/payout-details/payout-details.js +27 -78
- package/dist/collection/components/payout-details/test/get-payout-details.spec.js +55 -0
- package/dist/collection/components/payout-details/test/payout-details-core.spec.js +72 -0
- package/dist/collection/components/payout-details/test/payout-details.spec.js +13 -0
- package/dist/collection/components/payouts-list/get-payouts.js +20 -0
- package/dist/collection/components/payouts-list/payouts-list-core.js +181 -0
- package/dist/collection/components/payouts-list/payouts-list.js +26 -148
- package/dist/collection/components/payouts-list/test/get-payouts.spec.js +64 -0
- package/dist/collection/components/payouts-list/test/payouts-list-core.spec.js +105 -0
- package/dist/collection/components/payouts-list/test/payouts-list.spec.js +29 -0
- package/dist/collection/components/table/table.js +1 -1
- package/dist/collection/components/table/test/table.spec.js +18 -0
- package/dist/collection/components/table/utils.js +1 -1
- package/dist/collection/utils/{phone-masks.js → form-input-masks.js} +1 -0
- package/dist/docs.json +390 -226
- package/dist/esm/Business-1f5e9f6b.js +64 -0
- package/dist/esm/BusinessFormEventTypes-989960ba.js +39 -0
- package/dist/esm/{Payout-c42e3877.js → Payout-dc5f009c.js} +2 -1
- package/dist/esm/{SubAccount-b3ce8720.js → SubAccount-bd59f646.js} +1 -1
- package/dist/esm/additional-questions-details_5.entry.js +5 -5
- package/dist/esm/{business-form-schema-997c585c.js → business-form-schema-f8f554d1.js} +17 -17
- package/dist/esm/{form-control-datepart_2.entry.js → form-control-datepart_3.entry.js} +46 -4
- package/dist/esm/{form-control-number_3.entry.js → form-control-select_2.entry.js} +1 -43
- package/dist/esm/form-input-masks-a8187c77.js +6 -0
- package/dist/esm/{index.esm-8ae36d07.js → index.esm-22b47398.js} +1 -258
- package/dist/esm/{justifi-additional-questions_6.entry.js → justifi-additional-questions_5.entry.js} +9 -278
- package/dist/esm/justifi-billing-form_2.entry.js +1 -1
- package/dist/esm/justifi-business-details.entry.js +5 -5
- package/dist/esm/justifi-business-form-stepped.entry.js +47 -53
- package/dist/esm/justifi-business-form.entry.js +32 -36
- package/dist/esm/justifi-business-list.entry.js +3 -50
- package/dist/{module/business-owners.js → esm/justifi-business-owners.entry.js} +13 -55
- package/dist/esm/justifi-details.entry.js +1 -1
- package/dist/esm/justifi-gross-payment-chart.entry.js +3 -3
- package/dist/esm/justifi-payment-balance-transactions.entry.js +2 -2
- package/dist/esm/justifi-payment-details.entry.js +44 -43
- package/dist/esm/justifi-payment-form.entry.js +2 -2
- package/dist/esm/justifi-payment-method-form.entry.js +6 -4
- package/dist/esm/justifi-payments-list.entry.js +47 -91
- package/dist/esm/justifi-payout-details.entry.js +48 -46
- package/dist/esm/justifi-payouts-list.entry.js +47 -113
- package/dist/esm/justifi-proceeds-list.entry.js +2 -2
- package/dist/esm/justifi-refund-form.entry.js +2 -2
- package/dist/esm/justifi-subaccount-details.entry.js +4 -4
- package/dist/esm/justifi-subaccounts-list.entry.js +3 -3
- package/dist/esm/justifi-table_2.entry.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/payment-details-core.entry.js +48 -0
- package/dist/esm/payment.service-bea02ccf.js +18 -0
- package/dist/esm/payments-list-core.entry.js +94 -0
- package/dist/{webcomponents/p-34c30022.entry.js → esm/payout-details-core.entry.js} +48 -1
- package/dist/esm/payout.service-92e56814.js +19 -0
- package/dist/esm/payouts-list-core.entry.js +117 -0
- package/dist/esm/subaccount-account-details_4.entry.js +2 -2
- package/dist/esm/subaccount-bank-details.entry.js +1 -1
- package/dist/esm/subaccount-terms-details.entry.js +1 -1
- package/dist/esm/utils-546ca6aa.js +8 -0
- package/dist/esm/{utils-f33f7e3c.js → utils-576874df.js} +4 -4
- package/dist/esm/{utils-26c7dd12.js → utils-dd428dba.js} +1 -1
- package/dist/esm/webcomponents.js +1 -1
- package/dist/module/Business.js +64 -0
- package/dist/module/BusinessFormEventTypes.js +39 -0
- package/dist/module/Payout.js +2 -1
- package/dist/module/additional-questions-details2.js +4 -4
- package/dist/module/business-generic-info.js +25 -27
- package/dist/module/business-representative.js +1 -1
- package/dist/module/form-input-masks.js +6 -0
- package/dist/module/index.esm.js +1 -258
- package/dist/module/justifi-business-details.js +3 -3
- package/dist/module/justifi-business-form-stepped.js +62 -74
- package/dist/module/justifi-business-form.js +47 -57
- package/dist/module/justifi-business-list.js +1 -48
- package/dist/module/justifi-business-owners.js +115 -1
- package/dist/module/justifi-payment-details.js +52 -48
- package/dist/module/justifi-payments-list.js +58 -102
- package/dist/module/justifi-payout-details.js +57 -52
- package/dist/module/justifi-payouts-list.js +59 -125
- package/dist/module/justifi-refund-form.js +1 -1
- package/dist/module/legal-address-form.js +1 -202
- package/dist/module/payment-details-core.d.ts +11 -0
- package/dist/module/payment-details-core.js +6 -0
- package/dist/module/payment-details-core2.js +76 -0
- package/dist/module/payment-method-form.js +6 -4
- package/dist/module/payment.service.js +18 -0
- package/dist/module/payments-list-core.d.ts +11 -0
- package/dist/module/payments-list-core.js +6 -0
- package/dist/module/payments-list-core2.js +131 -0
- package/dist/module/payout-details-core.d.ts +11 -0
- package/dist/module/payout-details-core.js +6 -0
- package/dist/module/payout-details-core2.js +76 -0
- package/dist/module/payout.service.js +19 -0
- package/dist/module/payouts-list-core.d.ts +11 -0
- package/dist/module/payouts-list-core.js +6 -0
- package/dist/module/payouts-list-core2.js +153 -0
- package/dist/module/table.js +2 -2
- package/dist/module/utils.js +4 -4
- package/dist/module/utils3.js +6 -29
- package/dist/types/api/Business.d.ts +60 -37
- package/dist/types/api/Payment.d.ts +33 -1
- package/dist/types/api/services/payment.service.d.ts +9 -0
- package/dist/types/api/services/payout.service.d.ts +9 -0
- package/dist/types/api/services/utils.d.ts +1 -0
- package/dist/types/components/business-details/additional-questions-details/additional-questions-details.d.ts +2 -2
- package/dist/types/components/business-details/business-details.d.ts +2 -2
- package/dist/types/components/business-form/BusinessFormEventTypes.d.ts +5 -0
- package/dist/types/components/business-form/business-form-schema.d.ts +1 -19
- package/dist/types/components/business-form/business-form-stepped.d.ts +19 -5
- package/dist/types/components/business-form/business-form.d.ts +11 -2
- package/dist/types/components/business-form/business-generic-info/business-generic-info.d.ts +2 -0
- package/dist/types/components/business-form/business-owners/business-owners.d.ts +1 -1
- package/dist/types/components/business-form/helpers.d.ts +1 -1
- package/dist/types/components/details/utils.d.ts +4 -3
- package/dist/types/components/payment-details/get-payment-details.d.ts +8 -0
- package/dist/types/components/payment-details/payment-details-core.d.ts +11 -0
- package/dist/types/components/payment-details/payment-details.d.ts +6 -6
- package/dist/types/components/payment-method-form/payment-method-responses.d.ts +10 -2
- package/dist/types/components/payments-list/get-payments.d.ts +9 -0
- package/dist/types/components/payments-list/payments-list-core.d.ts +17 -0
- package/dist/types/components/payments-list/payments-list.d.ts +4 -12
- package/dist/types/components/payout-details/get-payout-details.d.ts +8 -0
- package/dist/types/components/payout-details/payout-details-core.d.ts +11 -0
- package/dist/types/components/payout-details/payout-details.d.ts +5 -31
- package/dist/types/components/payouts-list/get-payouts.d.ts +9 -0
- package/dist/types/components/payouts-list/payouts-list-core.d.ts +18 -0
- package/dist/types/components/payouts-list/payouts-list.d.ts +4 -13
- package/dist/types/components.d.ts +134 -136
- package/dist/types/utils/form-input-masks.d.ts +6 -0
- package/dist/webcomponents/p-081cf5f6.entry.js +1 -0
- package/dist/webcomponents/p-0b9146cd.entry.js +1 -0
- package/dist/webcomponents/p-112acd3c.entry.js +1 -0
- package/dist/webcomponents/p-1555e6b1.js +1 -0
- package/dist/webcomponents/{p-ac8be2a8.entry.js → p-16f41fd0.entry.js} +1 -1
- package/dist/webcomponents/p-17715325.js +1 -0
- package/dist/webcomponents/p-19c5ddf1.entry.js +1 -0
- package/dist/webcomponents/p-1b6ff0d3.entry.js +1 -0
- package/dist/webcomponents/p-1cb65d15.entry.js +1 -0
- package/dist/webcomponents/{p-2b2f8162.entry.js → p-2e318b6a.entry.js} +1 -1
- package/dist/webcomponents/p-34de1c5d.entry.js +1 -0
- package/dist/webcomponents/p-36618b59.entry.js +1 -0
- package/dist/webcomponents/p-3a4d4869.entry.js +1 -0
- package/dist/webcomponents/p-3cb0b96d.js +1 -0
- package/dist/webcomponents/p-4ba2c711.entry.js +1 -0
- package/dist/webcomponents/p-4c01df65.entry.js +1 -0
- package/dist/webcomponents/p-4fa27a28.entry.js +1 -0
- package/dist/webcomponents/{p-3bef762a.js → p-50730e69.js} +1 -1
- package/dist/webcomponents/p-57e592ac.entry.js +1 -0
- package/dist/webcomponents/p-5e142186.entry.js +1 -0
- package/dist/webcomponents/{p-85ddbe82.entry.js → p-5f8b9f64.entry.js} +1 -1
- package/dist/webcomponents/p-663bfe87.js +1 -0
- package/dist/webcomponents/p-6ab67031.entry.js +1 -0
- package/dist/webcomponents/p-6ed680e9.js +1 -0
- package/dist/webcomponents/{p-d8835e7a.entry.js → p-731cb109.entry.js} +1 -1
- package/dist/webcomponents/{p-525adabf.entry.js → p-7c0f91fa.entry.js} +1 -1
- package/dist/webcomponents/{p-40fb25c6.entry.js → p-7dd83492.entry.js} +1 -1
- package/dist/webcomponents/p-810b72b5.js +1 -0
- package/dist/webcomponents/p-876c7257.entry.js +1 -0
- package/dist/webcomponents/p-88027949.js +1 -0
- package/dist/webcomponents/{p-64a5126c.entry.js → p-896a9ddb.entry.js} +1 -1
- package/dist/webcomponents/{p-9ba0be02.entry.js → p-8a90b976.entry.js} +1 -1
- package/dist/webcomponents/p-9b99370e.js +1 -0
- package/dist/webcomponents/p-9cb3ff78.entry.js +1 -0
- package/dist/webcomponents/p-ade12f56.js +1 -0
- package/dist/webcomponents/{p-45d2761d.entry.js → p-b5aba473.entry.js} +1 -1
- package/dist/webcomponents/p-b8a8b551.js +1 -0
- package/dist/webcomponents/{p-c950901c.entry.js → p-c0f882ce.entry.js} +1 -1
- package/dist/webcomponents/p-d66a6057.entry.js +1 -0
- package/dist/webcomponents/{p-9cec4a27.entry.js → p-d71ce1cd.entry.js} +1 -1
- package/dist/webcomponents/{p-c43e29ac.entry.js → p-ec4f27e7.entry.js} +1 -1
- package/dist/webcomponents/{p-9a6e4749.js → p-f0c535ed.js} +1 -1
- package/dist/webcomponents/{p-c63a98f6.entry.js → p-f7a3fd12.entry.js} +1 -1
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/package.json +6 -4
- package/dist/cjs/utils-931f4879.js +0 -34
- package/dist/esm/utils-8cc130a9.js +0 -31
- package/dist/module/phone-masks.js +0 -5
- package/dist/types/utils/phone-masks.d.ts +0 -3
- package/dist/webcomponents/p-0a1347cf.entry.js +0 -1
- package/dist/webcomponents/p-0f3e9483.js +0 -1
- package/dist/webcomponents/p-0fa49c38.entry.js +0 -1
- package/dist/webcomponents/p-1e2a98bf.js +0 -1
- package/dist/webcomponents/p-5a502ceb.entry.js +0 -1
- package/dist/webcomponents/p-5bf0ac1a.entry.js +0 -1
- package/dist/webcomponents/p-6e80f063.entry.js +0 -1
- package/dist/webcomponents/p-71679a41.js +0 -1
- package/dist/webcomponents/p-78baff54.js +0 -1
- package/dist/webcomponents/p-8bbb1b10.entry.js +0 -1
- package/dist/webcomponents/p-90926321.js +0 -1
- package/dist/webcomponents/p-9e0d2179.entry.js +0 -1
- package/dist/webcomponents/p-c4826a33.entry.js +0 -1
- package/dist/webcomponents/p-d4755024.entry.js +0 -1
- package/dist/webcomponents/p-e8e109bd.entry.js +0 -1
- package/dist/webcomponents/p-ead8cfc2.entry.js +0 -1
- package/dist/webcomponents/p-f74899b9.entry.js +0 -1
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
// These props should not be sent to the server
|
|
2
|
-
export const parseForPatching = (
|
|
3
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
4
|
-
delete
|
|
5
|
-
delete
|
|
6
|
-
delete
|
|
7
|
-
delete
|
|
8
|
-
delete
|
|
9
|
-
delete
|
|
10
|
-
(_a =
|
|
11
|
-
(_b =
|
|
12
|
-
(_c =
|
|
13
|
-
(_d =
|
|
14
|
-
(_e =
|
|
15
|
-
(_f =
|
|
16
|
-
(_g =
|
|
17
|
-
(_h =
|
|
18
|
-
(_j =
|
|
19
|
-
(_k =
|
|
20
|
-
delete
|
|
21
|
-
|
|
2
|
+
export const parseForPatching = (values, initialValues) => {
|
|
3
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
4
|
+
delete values.id;
|
|
5
|
+
delete values.documents;
|
|
6
|
+
delete values.bank_accounts;
|
|
7
|
+
delete values.product_categories;
|
|
8
|
+
delete values.created_at;
|
|
9
|
+
delete values.updated_at;
|
|
10
|
+
(_a = values.legal_address) === null || _a === void 0 ? true : delete _a.id;
|
|
11
|
+
(_b = values.legal_address) === null || _b === void 0 ? true : delete _b.created_at;
|
|
12
|
+
(_c = values.legal_address) === null || _c === void 0 ? true : delete _c.updated_at;
|
|
13
|
+
(_d = values.representative) === null || _d === void 0 ? true : delete _d.id;
|
|
14
|
+
(_e = values.representative) === null || _e === void 0 ? true : delete _e.documents;
|
|
15
|
+
(_f = values.representative) === null || _f === void 0 ? true : delete _f.created_at;
|
|
16
|
+
(_g = values.representative) === null || _g === void 0 ? true : delete _g.updated_at;
|
|
17
|
+
(_h = values.representative) === null || _h === void 0 ? true : delete _h.address.id;
|
|
18
|
+
(_j = values.representative) === null || _j === void 0 ? true : delete _j.address.created_at;
|
|
19
|
+
(_k = values.representative) === null || _k === void 0 ? true : delete _k.address.updated_at;
|
|
20
|
+
(_l = values.representative) === null || _l === void 0 ? true : delete _l.business_id;
|
|
21
|
+
((_m = initialValues.owners) === null || _m === void 0 ? void 0 : _m.length) && delete values.owners;
|
|
22
|
+
return values;
|
|
22
23
|
};
|
package/dist/collection/components/business-form/legal-address-form/legal-address-form-schema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Yup from "yup";
|
|
2
2
|
const legalAddressSchema = Yup.object({
|
|
3
3
|
line1: Yup.string().required('Enter street address'),
|
|
4
|
-
line2: Yup.string(),
|
|
4
|
+
line2: Yup.string().nullable(),
|
|
5
5
|
city: Yup.string().required('Enter city'),
|
|
6
6
|
state: Yup.string().required('Select state'),
|
|
7
7
|
postal_code: Yup.string().required('Enter postal code'),
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
|
-
import countryOptions from "../../../utils/country-options";
|
|
3
2
|
/**
|
|
4
3
|
* @exportedPart label: Label for inputs
|
|
5
4
|
* @exportedPart input: The input fields
|
|
@@ -22,7 +21,7 @@ export class LegalAddressForm {
|
|
|
22
21
|
render() {
|
|
23
22
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
24
23
|
const legalAddressDefaultValue = this.formController.getInitialValues().legal_address;
|
|
25
|
-
return (h(Host, { exportparts: "label,input,input-invalid" }, h("fieldset", null, h("legend", null, "Business Legal Address"), h("hr", null), h("div", { class: "row gx-2 gy-2" }, h("div", { class: "col-12" }, h("form-control-text", { name: "line1", label: "Legal Address", inputHandler: this.inputHandler, defaultValue: legalAddressDefaultValue === null || legalAddressDefaultValue === void 0 ? void 0 : legalAddressDefaultValue.line1, error: (_b = (_a = this.errors) === null || _a === void 0 ? void 0 : _a.legal_address) === null || _b === void 0 ? void 0 : _b.line1 })), h("div", { class: "col-12" }, h("form-control-text", { name: "line2", label: "Address Line 2", inputHandler: (name, value) => this.inputHandler(name, value), defaultValue: legalAddressDefaultValue === null || legalAddressDefaultValue === void 0 ? void 0 : legalAddressDefaultValue.line2 })), h("div", { class: "col-12" }, h("form-control-text", { name: "city", label: "City", inputHandler: this.inputHandler, defaultValue: legalAddressDefaultValue === null || legalAddressDefaultValue === void 0 ? void 0 : legalAddressDefaultValue.city, error: (_d = (_c = this.errors) === null || _c === void 0 ? void 0 : _c.legal_address) === null || _d === void 0 ? void 0 : _d.city })), h("div", { class: "col-12" }, h("form-control-text", { name: "state", label: "State", inputHandler: this.inputHandler, defaultValue: legalAddressDefaultValue === null || legalAddressDefaultValue === void 0 ? void 0 : legalAddressDefaultValue.state, error: (_f = (_e = this.errors) === null || _e === void 0 ? void 0 : _e.legal_address) === null || _f === void 0 ? void 0 : _f.state })), h("div", { class: "col-12" }, h("form-control-number", { name: "postal_code", label: "Postal Code", inputHandler: this.inputHandler, defaultValue: legalAddressDefaultValue === null || legalAddressDefaultValue === void 0 ? void 0 : legalAddressDefaultValue.postal_code, error: (_h = (_g = this.errors) === null || _g === void 0 ? void 0 : _g.legal_address) === null || _h === void 0 ? void 0 : _h.postal_code })), h("div", { class: "col-12" }, h("form-control-select", { name: "country", label: "Country", options:
|
|
24
|
+
return (h(Host, { exportparts: "label,input,input-invalid" }, h("fieldset", null, h("legend", null, "Business Legal Address"), h("hr", null), h("div", { class: "row gx-2 gy-2" }, h("div", { class: "col-12" }, h("form-control-text", { name: "line1", label: "Legal Address", inputHandler: this.inputHandler, defaultValue: legalAddressDefaultValue === null || legalAddressDefaultValue === void 0 ? void 0 : legalAddressDefaultValue.line1, error: (_b = (_a = this.errors) === null || _a === void 0 ? void 0 : _a.legal_address) === null || _b === void 0 ? void 0 : _b.line1 })), h("div", { class: "col-12" }, h("form-control-text", { name: "line2", label: "Address Line 2", inputHandler: (name, value) => this.inputHandler(name, value), defaultValue: legalAddressDefaultValue === null || legalAddressDefaultValue === void 0 ? void 0 : legalAddressDefaultValue.line2 })), h("div", { class: "col-12" }, h("form-control-text", { name: "city", label: "City", inputHandler: this.inputHandler, defaultValue: legalAddressDefaultValue === null || legalAddressDefaultValue === void 0 ? void 0 : legalAddressDefaultValue.city, error: (_d = (_c = this.errors) === null || _c === void 0 ? void 0 : _c.legal_address) === null || _d === void 0 ? void 0 : _d.city })), h("div", { class: "col-12" }, h("form-control-text", { name: "state", label: "State", inputHandler: this.inputHandler, defaultValue: legalAddressDefaultValue === null || legalAddressDefaultValue === void 0 ? void 0 : legalAddressDefaultValue.state, error: (_f = (_e = this.errors) === null || _e === void 0 ? void 0 : _e.legal_address) === null || _f === void 0 ? void 0 : _f.state })), h("div", { class: "col-12" }, h("form-control-number", { name: "postal_code", label: "Postal Code", inputHandler: this.inputHandler, defaultValue: legalAddressDefaultValue === null || legalAddressDefaultValue === void 0 ? void 0 : legalAddressDefaultValue.postal_code, error: (_h = (_g = this.errors) === null || _g === void 0 ? void 0 : _g.legal_address) === null || _h === void 0 ? void 0 : _h.postal_code })), h("div", { class: "col-12" }, h("form-control-select", { name: "country", label: "Country", options: [{ label: 'United States', value: 'USA' }], inputHandler: this.inputHandler, defaultValue: legalAddressDefaultValue === null || legalAddressDefaultValue === void 0 ? void 0 : legalAddressDefaultValue.country, error: (_k = (_j = this.errors) === null || _j === void 0 ? void 0 : _j.legal_address) === null || _k === void 0 ? void 0 : _k.country,
|
|
26
25
|
// just for now so we skip handling country specificities
|
|
27
26
|
disabled: true }))))));
|
|
28
27
|
}
|
|
@@ -4,7 +4,7 @@ describe('justifi-business-form', () => {
|
|
|
4
4
|
let consoleSpy;
|
|
5
5
|
// Initialize the spy in the beforeEach
|
|
6
6
|
beforeEach(() => {
|
|
7
|
-
consoleSpy = jest.spyOn(console, '
|
|
7
|
+
consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => { });
|
|
8
8
|
});
|
|
9
9
|
// Restore the original function in the afterEach
|
|
10
10
|
afterEach(() => {
|
|
@@ -17,26 +17,17 @@ describe('justifi-business-form', () => {
|
|
|
17
17
|
});
|
|
18
18
|
expect(consoleSpy).toHaveBeenCalledWith('Warning: Missing auth-token. The form will not be functional without it.');
|
|
19
19
|
});
|
|
20
|
-
it('should
|
|
21
|
-
|
|
20
|
+
it('should log a warning if no businessId is provided', async () => {
|
|
21
|
+
await newSpecPage({
|
|
22
22
|
components: [BusinessForm],
|
|
23
23
|
html: `<justifi-business-form></justifi-business-form>`,
|
|
24
24
|
});
|
|
25
|
-
|
|
26
|
-
expect(submitButton).toHaveAttribute('disabled');
|
|
27
|
-
});
|
|
28
|
-
it('should not disable the submit button if an authToken is provided', async () => {
|
|
29
|
-
const { root } = await newSpecPage({
|
|
30
|
-
components: [BusinessForm],
|
|
31
|
-
html: `<justifi-business-form auth-token="auth-token"></justifi-business-form>`,
|
|
32
|
-
});
|
|
33
|
-
const submitButton = root.querySelector('.jfi-submit-button');
|
|
34
|
-
expect(submitButton).not.toHaveAttribute('disabled');
|
|
25
|
+
expect(consoleSpy).toHaveBeenCalledWith('Warning: Missing business-id. The form requires an existing business-id to function.');
|
|
35
26
|
});
|
|
36
27
|
it('should not log a warning if an authToken is provided', async () => {
|
|
37
28
|
await newSpecPage({
|
|
38
29
|
components: [BusinessForm],
|
|
39
|
-
html: `<justifi-business-form auth-token="some-token"></justifi-business-form>`,
|
|
30
|
+
html: `<justifi-business-form business-id="biz_123" auth-token="some-token"></justifi-business-form>`,
|
|
40
31
|
});
|
|
41
32
|
expect(consoleSpy).not.toHaveBeenCalled();
|
|
42
33
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
|
-
export const LoadingState = (h("main", { part: "detail-loading-state", class: "p-4 d-flex justify-content-center text-center", style: { fontSize: '1.2rem' } }, h("div", { part: "detail-loading-spinner", class: "spinner-border spinner-border-sm", role: "status" }, h("span", { class: "visually-hidden" }, "Loading..."))));
|
|
2
|
+
export const LoadingState = () => (h("main", { part: "detail-loading-state", class: "p-4 d-flex justify-content-center text-center", style: { fontSize: '1.2rem' } }, h("div", { part: "detail-loading-spinner", class: "spinner-border spinner-border-sm", role: "status" }, h("span", { class: "visually-hidden" }, "Loading..."))));
|
|
3
3
|
export const ErrorState = (errorMessage) => (h("main", { part: "detail-empty-state", class: "p-4 d-flex justify-content-center text-center", style: { fontSize: '1.2rem' } }, h("div", null, errorMessage)));
|
|
4
|
-
export const DetailSection = (
|
|
4
|
+
export const DetailSection = (props, children) => (h("div", { part: "detail-section", class: "mt-4" }, h("h5", { part: "detail-section-title" }, props.sectionTitle), h("hr", null), h("div", { class: "d-table gap-2 w-100" }, ...children)));
|
|
5
5
|
export const DetailItem = ({ title, value, }) => title && value ? (h("div", { class: "d-table-row gap-2" }, h("span", { part: "detail-section-item-title", class: "fw-bold d-table-cell px-2" }, title), h("span", { part: "detail-section-item-data", class: "flex-1 d-table-cell px-2 text-wrap", innerHTML: value }))) : null;
|
|
6
6
|
export const EntityHeadInfoItem = ({ title, value, classes, }) => (h("div", { part: "detail-head-info-item", class: `d-flex flex-column ${classes}` }, h("span", { part: "detail-head-info-item-title", class: "fw-bold border-1 border-bottom ps-2 pe-2" }, title), h("span", { part: "detail-head-info-item-data", class: "pt-2 ps-2 pe-2" }, value)));
|
|
7
7
|
export const EntityHeadInfo = ({ title, slot, badge }, children) => (h("div", { slot: slot, part: "detail-head", class: "p-2" }, h("div", { class: "d-flex flex-row align-items-center gap-2 mb-2" }, h("h1", { class: "m-0", part: "detail-title" }, title), badge), h("div", { part: "detail-head-info", class: "d-flex flex-row align-items-top" }, children)));
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { newSpecPage } from "@stencil/core/testing";
|
|
2
|
+
import { PaginationMenu } from "../pagination-menu";
|
|
3
|
+
import { ExtendedPagingDefaults } from "../../../api";
|
|
4
|
+
const mockExtendedPagingInfo = {
|
|
5
|
+
has_previous: false,
|
|
6
|
+
has_next: true,
|
|
7
|
+
start_cursor: '',
|
|
8
|
+
end_cursor: '',
|
|
9
|
+
handleClickNext: jest.fn((after_cursor) => {
|
|
10
|
+
// Implementation for the mock; could just be empty for basic tests
|
|
11
|
+
console.log(`Mock handleClickNext called with after_cursor: ${after_cursor}`);
|
|
12
|
+
}),
|
|
13
|
+
handleClickPrevious: jest.fn((before_cursor) => {
|
|
14
|
+
console.log(`Mock handleClickPrevious called with before_cursor: ${before_cursor}`);
|
|
15
|
+
}),
|
|
16
|
+
amount: 0
|
|
17
|
+
};
|
|
18
|
+
describe('pagination-menu', () => {
|
|
19
|
+
it('initializes with default property values', async () => {
|
|
20
|
+
const page = await newSpecPage({
|
|
21
|
+
components: [PaginationMenu],
|
|
22
|
+
html: `<pagination-menu></pagination-menu>`,
|
|
23
|
+
});
|
|
24
|
+
expect(page.rootInstance.paging).toEqual(ExtendedPagingDefaults);
|
|
25
|
+
expect(page.rootInstance.params).toEqual({});
|
|
26
|
+
});
|
|
27
|
+
it('sets appropriate aria-labels for accessibility', async () => {
|
|
28
|
+
const page = await newSpecPage({
|
|
29
|
+
components: [PaginationMenu],
|
|
30
|
+
html: `<pagination-menu></pagination-menu>`,
|
|
31
|
+
});
|
|
32
|
+
expect(page.root.shadowRoot.querySelector('nav').getAttribute('aria-label')).toBe('Table pagination');
|
|
33
|
+
});
|
|
34
|
+
it('reflects passed properties', async () => {
|
|
35
|
+
const mockPagingInfo = mockExtendedPagingInfo;
|
|
36
|
+
const page = await newSpecPage({
|
|
37
|
+
components: [PaginationMenu],
|
|
38
|
+
html: `<pagination-menu></pagination-menu>`,
|
|
39
|
+
});
|
|
40
|
+
page.root.paging = mockPagingInfo;
|
|
41
|
+
await page.waitForChanges();
|
|
42
|
+
expect(page.rootInstance.paging).toBe(mockPagingInfo);
|
|
43
|
+
});
|
|
44
|
+
it('disables/enables buttons based on paging info', async () => {
|
|
45
|
+
const page = await newSpecPage({
|
|
46
|
+
components: [PaginationMenu],
|
|
47
|
+
html: `<pagination-menu></pagination-menu>`,
|
|
48
|
+
});
|
|
49
|
+
page.root.paging = {
|
|
50
|
+
has_previous: false,
|
|
51
|
+
has_next: true,
|
|
52
|
+
start_cursor: '',
|
|
53
|
+
end_cursor: '',
|
|
54
|
+
handleClickNext: jest.fn(),
|
|
55
|
+
handleClickPrevious: jest.fn(),
|
|
56
|
+
amount: 0
|
|
57
|
+
};
|
|
58
|
+
await page.waitForChanges();
|
|
59
|
+
const previousButton = page.root.shadowRoot.querySelector('.page-item:first-child');
|
|
60
|
+
const nextButton = page.root.shadowRoot.querySelector('.page-item:last-child');
|
|
61
|
+
// Convert classList to a string for the assertion
|
|
62
|
+
const previousButtonClasses = previousButton.className;
|
|
63
|
+
const nextButtonClasses = nextButton.className;
|
|
64
|
+
expect(previousButtonClasses).toContain('disabled');
|
|
65
|
+
expect(nextButtonClasses).not.toContain('disabled');
|
|
66
|
+
});
|
|
67
|
+
it('emits events on button clicks', async () => {
|
|
68
|
+
const mockPagingInfo = {
|
|
69
|
+
has_previous: true,
|
|
70
|
+
has_next: true,
|
|
71
|
+
handleClickPrevious: jest.fn(),
|
|
72
|
+
handleClickNext: jest.fn(),
|
|
73
|
+
};
|
|
74
|
+
const page = await newSpecPage({
|
|
75
|
+
components: [PaginationMenu],
|
|
76
|
+
html: `<pagination-menu></pagination-menu>`,
|
|
77
|
+
});
|
|
78
|
+
page.root.paging = mockPagingInfo;
|
|
79
|
+
await page.waitForChanges();
|
|
80
|
+
const previousButton = page.root.shadowRoot.querySelector('.page-item:first-child .page-link');
|
|
81
|
+
const nextButton = page.root.shadowRoot.querySelector('.page-item:last-child .page-link');
|
|
82
|
+
previousButton.click();
|
|
83
|
+
expect(mockPagingInfo.handleClickPrevious).toHaveBeenCalled();
|
|
84
|
+
nextButton.click();
|
|
85
|
+
expect(mockPagingInfo.handleClickNext).toHaveBeenCalled();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Payment } from "../../api";
|
|
2
|
+
import { getErrorMessage } from "../../api/services/utils";
|
|
3
|
+
export const makeGetPaymentDetails = ({ id, authToken, service }) => async ({ onSuccess, onError }) => {
|
|
4
|
+
try {
|
|
5
|
+
const response = await service.fetchPayment(id, authToken);
|
|
6
|
+
if (!response.error) {
|
|
7
|
+
onSuccess({ payment: new Payment(response.data) });
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
const responseError = getErrorMessage(response.error);
|
|
11
|
+
onError(`Error trying to fetch data : ${responseError}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
onError(`Error trying to fetch data : ${error}`);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
import { MapPaymentStatusToBadge, formatCurrency, formatDate, formatTime, snakeCaseToHumanReadable } from "../../utils/utils";
|
|
3
|
+
import { CodeBlock, DetailItem, DetailSection, EntityHeadInfo, EntityHeadInfoItem, ErrorState, LoadingState } from "../details/utils";
|
|
4
|
+
export class PaymentDetailsCore {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.getPaymentDetails = undefined;
|
|
7
|
+
this.payment = undefined;
|
|
8
|
+
this.loading = true;
|
|
9
|
+
this.errorMessage = undefined;
|
|
10
|
+
}
|
|
11
|
+
componentWillLoad() {
|
|
12
|
+
if (this.getPaymentDetails) {
|
|
13
|
+
this.fetchData();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
updateOnPropChange() {
|
|
17
|
+
this.fetchData();
|
|
18
|
+
}
|
|
19
|
+
fetchData() {
|
|
20
|
+
this.loading = true;
|
|
21
|
+
this.getPaymentDetails({
|
|
22
|
+
onSuccess: ({ payment }) => {
|
|
23
|
+
this.payment = payment;
|
|
24
|
+
this.loading = false;
|
|
25
|
+
this.errorMessage = null;
|
|
26
|
+
},
|
|
27
|
+
onError: (error) => {
|
|
28
|
+
this.errorMessage = error;
|
|
29
|
+
this.loading = false;
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
var _a;
|
|
35
|
+
return (h(Host, null, this.loading && LoadingState(), !this.loading && this.errorMessage && ErrorState(this.errorMessage), !this.loading && !this.errorMessage &&
|
|
36
|
+
this.payment && (h("justifi-details", { "error-message": this.errorMessage }, h(EntityHeadInfo, { slot: "head-info", badge: h("span", { slot: 'badge', innerHTML: MapPaymentStatusToBadge(this.payment.status) }), title: `${formatCurrency(this.payment.amount)} ${(_a = this.payment) === null || _a === void 0 ? void 0 : _a.currency.toUpperCase()}` }, h(EntityHeadInfoItem, { classes: "border-1 border-end", title: "Updated At", value: `${formatDate(this.payment.updated_at)} ${formatTime(this.payment.updated_at)}` }), h(EntityHeadInfoItem, { classes: "border-1 border-end", title: "Created At", value: `${formatDate(this.payment.created_at)} ${formatTime(this.payment.created_at)}` }), h(EntityHeadInfoItem, { title: "ID", value: this.payment.id })), h("div", { slot: 'detail-sections' }, h(DetailSection, { sectionTitle: "Details" }, h(DetailItem, { title: "Amount", value: formatCurrency(this.payment.amount) }), h(DetailItem, { title: "Fees", value: formatCurrency(this.payment.fee_amount) }), h(DetailItem, { title: "Refunded", value: formatCurrency(this.payment.amount_refunded) }), h(DetailItem, { title: "Net", value: formatCurrency(this.payment.balance) }), h(DetailItem, { title: "Status", value: MapPaymentStatusToBadge(this.payment.status) }), h(DetailItem, { title: "Payment ID", value: this.payment.id }), h(DetailItem, { title: "Processing Fees", value: formatCurrency(this.payment.fee_amount) }), h(DetailItem, { title: "Statement Descriptor", value: this.payment.statement_descriptor }), h(DetailItem, { title: "Description", value: this.payment.description })), this.payment.payment_method.card && (h(DetailSection, { sectionTitle: "Payment Method" }, h(DetailItem, { title: "ID", value: this.payment.payment_method.card.id }), h(DetailItem, { title: "Payment Type", value: "Card" }), h(DetailItem, { title: "Last 4 Numbers", value: this.payment.payment_method.lastFourDigits }), h(DetailItem, { title: "Brand", value: snakeCaseToHumanReadable(this.payment.payment_method.card.brand) }), h(DetailItem, { title: "Cardholder", value: this.payment.payment_method.payersName }))), this.payment.payment_method.bank_account && (h(DetailSection, { sectionTitle: "Payment Method" }, h(DetailItem, { title: "ID", value: this.payment.payment_method.bank_account.id }), h(DetailItem, { title: "Last 4 Numbers", value: this.payment.payment_method.lastFourDigits }), h(DetailItem, { title: "Bank Name", value: this.payment.payment_method.bank_account.brand }), h(DetailItem, { title: "Account Owner", value: this.payment.payment_method.payersName }))), h(DetailSection, { sectionTitle: 'Metadata' }, h(CodeBlock, { metadata: this.payment.metadata })))))));
|
|
37
|
+
}
|
|
38
|
+
static get is() { return "payment-details-core"; }
|
|
39
|
+
static get originalStyleUrls() {
|
|
40
|
+
return {
|
|
41
|
+
"$": ["payment-details.scss"]
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
static get styleUrls() {
|
|
45
|
+
return {
|
|
46
|
+
"$": ["payment-details.css"]
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
static get properties() {
|
|
50
|
+
return {
|
|
51
|
+
"getPaymentDetails": {
|
|
52
|
+
"type": "unknown",
|
|
53
|
+
"mutable": false,
|
|
54
|
+
"complexType": {
|
|
55
|
+
"original": "Function",
|
|
56
|
+
"resolved": "Function",
|
|
57
|
+
"references": {
|
|
58
|
+
"Function": {
|
|
59
|
+
"location": "global",
|
|
60
|
+
"id": "global::Function"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": false,
|
|
65
|
+
"optional": false,
|
|
66
|
+
"docs": {
|
|
67
|
+
"tags": [],
|
|
68
|
+
"text": ""
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
static get states() {
|
|
74
|
+
return {
|
|
75
|
+
"payment": {},
|
|
76
|
+
"loading": {},
|
|
77
|
+
"errorMessage": {}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
static get watchers() {
|
|
81
|
+
return [{
|
|
82
|
+
"propName": "getPaymentDetails",
|
|
83
|
+
"methodName": "updateOnPropChange"
|
|
84
|
+
}];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { config } from "../../../config";
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { PaymentService } from "../../api/services/payment.service";
|
|
3
|
+
import { makeGetPaymentDetails } from "./get-payment-details";
|
|
4
|
+
import { ErrorState } from "../details/utils";
|
|
6
5
|
/**
|
|
7
6
|
* @exportedPart detail-loading-spinner
|
|
8
7
|
* @exportedPart detail-loading-state
|
|
@@ -29,61 +28,38 @@ import { config } from "../../../config";
|
|
|
29
28
|
*/
|
|
30
29
|
export class PaymentDetails {
|
|
31
30
|
constructor() {
|
|
31
|
+
this.paymentService = new PaymentService();
|
|
32
32
|
this.paymentId = undefined;
|
|
33
33
|
this.authToken = undefined;
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
this.errorMessage = undefined;
|
|
34
|
+
this.getPaymentDetails = undefined;
|
|
35
|
+
this.errorMessage = null;
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
this.
|
|
37
|
+
componentWillLoad() {
|
|
38
|
+
this.initializeGetPaymentDetails();
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
this.
|
|
40
|
+
propChanged() {
|
|
41
|
+
this.initializeGetPaymentDetails();
|
|
43
42
|
}
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
this.
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
initializeGetPaymentDetails() {
|
|
44
|
+
if (this.paymentId && this.authToken) {
|
|
45
|
+
this.getPaymentDetails = makeGetPaymentDetails({
|
|
46
|
+
id: this.paymentId,
|
|
47
|
+
authToken: this.authToken,
|
|
48
|
+
service: new PaymentService(),
|
|
49
|
+
});
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const endpoint = `payments/${this.paymentId}`;
|
|
53
|
-
const response = await Api(this.authToken, config.proxyApiOrigin).get(endpoint);
|
|
54
|
-
if (!response.error) {
|
|
55
|
-
this.payment = new Payment(response.data);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
const responseError = typeof response.error === 'string' ? response.error : response.error.message;
|
|
59
|
-
this.errorMessage = `Error trying to fetch data : ${responseError}`;
|
|
60
|
-
console.error(this.errorMessage);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
this.errorMessage = `Error trying to fetch data : ${error}`;
|
|
65
|
-
console.error(this.errorMessage);
|
|
66
|
-
}
|
|
67
|
-
finally {
|
|
68
|
-
this.loading = false;
|
|
51
|
+
else {
|
|
52
|
+
this.errorMessage = 'Payment ID and Auth Token are required';
|
|
69
53
|
}
|
|
70
54
|
}
|
|
71
55
|
render() {
|
|
72
|
-
|
|
73
|
-
|
|
56
|
+
if (this.errorMessage) {
|
|
57
|
+
return ErrorState(this.errorMessage);
|
|
58
|
+
}
|
|
59
|
+
return (h("payment-details-core", { getPaymentDetails: this.getPaymentDetails }));
|
|
74
60
|
}
|
|
75
61
|
static get is() { return "justifi-payment-details"; }
|
|
76
62
|
static get encapsulation() { return "shadow"; }
|
|
77
|
-
static get originalStyleUrls() {
|
|
78
|
-
return {
|
|
79
|
-
"$": ["payment-details.scss"]
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
static get styleUrls() {
|
|
83
|
-
return {
|
|
84
|
-
"$": ["payment-details.css"]
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
63
|
static get properties() {
|
|
88
64
|
return {
|
|
89
65
|
"paymentId": {
|
|
@@ -124,18 +100,17 @@ export class PaymentDetails {
|
|
|
124
100
|
}
|
|
125
101
|
static get states() {
|
|
126
102
|
return {
|
|
127
|
-
"
|
|
128
|
-
"loading": {},
|
|
103
|
+
"getPaymentDetails": {},
|
|
129
104
|
"errorMessage": {}
|
|
130
105
|
};
|
|
131
106
|
}
|
|
132
107
|
static get watchers() {
|
|
133
108
|
return [{
|
|
134
109
|
"propName": "paymentId",
|
|
135
|
-
"methodName": "
|
|
110
|
+
"methodName": "propChanged"
|
|
136
111
|
}, {
|
|
137
112
|
"propName": "authToken",
|
|
138
|
-
"methodName": "
|
|
113
|
+
"methodName": "propChanged"
|
|
139
114
|
}];
|
|
140
115
|
}
|
|
141
116
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Payment } from "../../../api";
|
|
2
|
+
import { PaymentService } from "../../../api/services/payment.service";
|
|
3
|
+
import { makeGetPaymentDetails } from "../get-payment-details";
|
|
4
|
+
import mockResponse from "../../../api/mockData/mockPaymentDetailSuccess.json";
|
|
5
|
+
// Mock the PaymentService class
|
|
6
|
+
jest.mock('../../../api/services/payment.service');
|
|
7
|
+
describe('getPaymentDetails', () => {
|
|
8
|
+
const paymentId = '123';
|
|
9
|
+
const authToken = '123';
|
|
10
|
+
let mockServiceInstance;
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
jest.clearAllMocks();
|
|
13
|
+
// Create a new instance of the mocked PaymentService
|
|
14
|
+
mockServiceInstance = new PaymentService();
|
|
15
|
+
// Explicitly mock fetchPayment as a jest mock function
|
|
16
|
+
mockServiceInstance.fetchPayment = jest.fn();
|
|
17
|
+
});
|
|
18
|
+
it('should call onSuccess with payment on successful fetch', async () => {
|
|
19
|
+
const onSuccess = jest.fn();
|
|
20
|
+
const onError = jest.fn();
|
|
21
|
+
// Mock fetchPayment to resolve with mockResponse
|
|
22
|
+
mockServiceInstance.fetchPayment.mockResolvedValue(mockResponse);
|
|
23
|
+
const getPaymentDetails = makeGetPaymentDetails({
|
|
24
|
+
id: paymentId,
|
|
25
|
+
authToken: authToken,
|
|
26
|
+
service: mockServiceInstance,
|
|
27
|
+
});
|
|
28
|
+
await getPaymentDetails({ onSuccess, onError });
|
|
29
|
+
expect(onSuccess).toHaveBeenCalledWith({
|
|
30
|
+
payment: expect.any(Payment),
|
|
31
|
+
});
|
|
32
|
+
expect(onError).not.toHaveBeenCalled();
|
|
33
|
+
});
|
|
34
|
+
it('should call onError with an error message on API failure', async () => {
|
|
35
|
+
const mockError = new Error('Error fetching payment');
|
|
36
|
+
const onSuccess = jest.fn();
|
|
37
|
+
const onError = jest.fn();
|
|
38
|
+
// Mock fetchPayment to reject with mockError
|
|
39
|
+
mockServiceInstance.fetchPayment.mockRejectedValue(mockError);
|
|
40
|
+
const getPaymentDetails = makeGetPaymentDetails({
|
|
41
|
+
id: paymentId,
|
|
42
|
+
authToken: authToken,
|
|
43
|
+
service: mockServiceInstance,
|
|
44
|
+
});
|
|
45
|
+
await getPaymentDetails({ onSuccess, onError });
|
|
46
|
+
expect(onSuccess).not.toHaveBeenCalled();
|
|
47
|
+
expect(onError).toHaveBeenCalledWith(`Error trying to fetch data : ${mockError}`);
|
|
48
|
+
});
|
|
49
|
+
it('should call onError with an error message on API failure', async () => {
|
|
50
|
+
const mockError = new Error('Error fetching payment');
|
|
51
|
+
const onSuccess = jest.fn();
|
|
52
|
+
const onError = jest.fn();
|
|
53
|
+
// Mock fetchPayment to reject with mockError
|
|
54
|
+
mockServiceInstance.fetchPayment.mockRejectedValue(mockError);
|
|
55
|
+
const getPaymentDetails = makeGetPaymentDetails({
|
|
56
|
+
id: paymentId,
|
|
57
|
+
authToken: authToken,
|
|
58
|
+
service: mockServiceInstance,
|
|
59
|
+
});
|
|
60
|
+
await getPaymentDetails({ onSuccess, onError });
|
|
61
|
+
expect(onSuccess).not.toHaveBeenCalled();
|
|
62
|
+
expect(onError).toHaveBeenCalledWith(`Error trying to fetch data : ${mockError}`);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { newSpecPage } from "@stencil/core/testing";
|
|
2
|
+
import mockPaymentDetailsResponse from "../../../api/mockData/mockPaymentDetailSuccess.json";
|
|
3
|
+
import { PaymentDetailsCore } from "../payment-details-core";
|
|
4
|
+
import { Details } from "../../details/details";
|
|
5
|
+
import { makeGetPaymentDetails } from "../get-payment-details";
|
|
6
|
+
describe('payment-details-core', () => {
|
|
7
|
+
const components = [PaymentDetailsCore, Details];
|
|
8
|
+
it('it renders properly with fetched data', async () => {
|
|
9
|
+
const mockPaymentService = {
|
|
10
|
+
fetchPayment: jest.fn().mockResolvedValue(mockPaymentDetailsResponse),
|
|
11
|
+
};
|
|
12
|
+
const page = await newSpecPage({
|
|
13
|
+
components,
|
|
14
|
+
html: `<payment-details-core></payment-details-core>`,
|
|
15
|
+
});
|
|
16
|
+
page.rootInstance.componentWillLoad = () => { };
|
|
17
|
+
page.rootInstance.getPaymentDetails = makeGetPaymentDetails({
|
|
18
|
+
id: '123',
|
|
19
|
+
authToken: '123',
|
|
20
|
+
service: mockPaymentService
|
|
21
|
+
});
|
|
22
|
+
page.rootInstance.fetchData();
|
|
23
|
+
await page.waitForChanges();
|
|
24
|
+
expect(page.rootInstance.payment).toEqual(expect.objectContaining({ id: mockPaymentDetailsResponse.data.id }));
|
|
25
|
+
expect(mockPaymentService.fetchPayment).toHaveBeenCalled();
|
|
26
|
+
expect(page.root).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
it('displays an error state on failed data fetch', async () => {
|
|
29
|
+
const mockService = {
|
|
30
|
+
fetchPayment: jest.fn().mockRejectedValue(new Error('Fetch error'))
|
|
31
|
+
};
|
|
32
|
+
const getPaymentDetails = makeGetPaymentDetails({
|
|
33
|
+
id: 'some-id',
|
|
34
|
+
authToken: 'some-auth-token',
|
|
35
|
+
service: mockService
|
|
36
|
+
});
|
|
37
|
+
const page = await newSpecPage({
|
|
38
|
+
components,
|
|
39
|
+
html: '<payment-details-core></payment-details-core>',
|
|
40
|
+
});
|
|
41
|
+
page.rootInstance.componentWillLoad = () => { };
|
|
42
|
+
page.rootInstance.getPaymentDetails = getPaymentDetails;
|
|
43
|
+
page.rootInstance.fetchData();
|
|
44
|
+
await page.waitForChanges();
|
|
45
|
+
expect(page.root).toMatchSnapshot();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { newSpecPage } from "@stencil/core/testing";
|
|
2
|
+
import { PaymentDetails } from "../payment-details";
|
|
3
|
+
import { PaymentDetailsCore } from "../payment-details-core";
|
|
4
|
+
import { Details } from "../../details/details";
|
|
5
|
+
describe('payment-details', () => {
|
|
6
|
+
const components = [PaymentDetails, PaymentDetailsCore, Details];
|
|
7
|
+
it('renders an error message when paymentId and authToken are not provided', async () => {
|
|
8
|
+
const page = await newSpecPage({
|
|
9
|
+
components,
|
|
10
|
+
html: '<justifi-payment-details></justifi-payment-details>',
|
|
11
|
+
});
|
|
12
|
+
await page.waitForChanges();
|
|
13
|
+
expect(page.root).toMatchSnapshot();
|
|
14
|
+
});
|
|
15
|
+
it('renders an error message when paymentId is not provided', async () => {
|
|
16
|
+
const page = await newSpecPage({
|
|
17
|
+
components,
|
|
18
|
+
html: '<justifi-payment-details auth-token="abc"></justifi-payment-details>',
|
|
19
|
+
});
|
|
20
|
+
await page.waitForChanges();
|
|
21
|
+
expect(page.root).toMatchSnapshot();
|
|
22
|
+
});
|
|
23
|
+
it('renders an error message when authToken is not provided', async () => {
|
|
24
|
+
const page = await newSpecPage({
|
|
25
|
+
components,
|
|
26
|
+
html: '<justifi-payment-details payment-id="abc"></justifi-payment-details>',
|
|
27
|
+
});
|
|
28
|
+
await page.waitForChanges();
|
|
29
|
+
expect(page.root).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Payment } from "../../api";
|
|
2
|
+
import { getErrorMessage } from "../../api/services/utils";
|
|
3
|
+
export const makeGetPayments = ({ id, authToken, service }) => async ({ params, onSuccess, onError }) => {
|
|
4
|
+
var _a;
|
|
5
|
+
try {
|
|
6
|
+
const response = await service.fetchPayments(id, authToken, params);
|
|
7
|
+
if (!response.error) {
|
|
8
|
+
const pagingInfo = Object.assign({}, response.page_info);
|
|
9
|
+
const payments = ((_a = response.data) === null || _a === void 0 ? void 0 : _a.map((dataItem) => new Payment(dataItem))) || [];
|
|
10
|
+
onSuccess({ payments, pagingInfo });
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
const responseError = getErrorMessage(response.error);
|
|
14
|
+
return onError(responseError);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
return onError(error.message || error);
|
|
19
|
+
}
|
|
20
|
+
};
|