@justifi/webcomponents 6.7.1 → 6.7.2
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/{check-pkg-version-cLAIX_H6.js → check-pkg-version-BG-Rfkh5.js} +1 -1
- package/dist/cjs/hidden-input_2.cjs.entry.js +1 -1
- package/dist/cjs/internal-tokenize-payment-method_7.cjs.entry.js +9 -7
- package/dist/cjs/justifi-apple-pay_8.cjs.entry.js +5 -4
- package/dist/cjs/justifi-business-details.cjs.entry.js +2 -2
- package/dist/cjs/justifi-business-form.cjs.entry.js +2 -2
- package/dist/cjs/justifi-checkout.cjs.entry.js +2 -2
- package/dist/cjs/justifi-checkouts-list.cjs.entry.js +2 -2
- package/dist/cjs/justifi-dispute-management.cjs.entry.js +2 -2
- package/dist/cjs/justifi-dispute-notification_3.cjs.entry.js +2 -2
- package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +2 -2
- package/dist/cjs/justifi-order-terminals.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payment-details.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payment-transactions-list.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payments-list.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payout-details.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payout-transactions-list.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payouts-list.cjs.entry.js +2 -2
- package/dist/cjs/justifi-refund-payment.cjs.entry.js +98 -6
- package/dist/cjs/justifi-season-interruption-insurance.cjs.entry.js +2 -2
- package/dist/cjs/justifi-terminal-orders-list.cjs.entry.js +2 -2
- package/dist/cjs/justifi-terminals-list.cjs.entry.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{package-C9E_BIbT.js → package-Df5lTFe6.js} +1 -1
- package/dist/cjs/webcomponents.cjs.js +1 -1
- package/dist/collection/actions/void/void-actions.js +31 -0
- package/dist/collection/api/services/void.service.js +9 -0
- package/dist/collection/components/modular-checkout/modular-checkout.js +3 -2
- package/dist/collection/components/modular-checkout/sub-components/bank-account.js +6 -3
- package/dist/collection/components/modular-checkout/sub-components/card-form.js +6 -3
- package/dist/collection/components/refund-payment/refund-payment.js +66 -10
- package/dist/docs.json +15 -10
- package/dist/esm/{check-pkg-version-o2X_8wJ4.js → check-pkg-version-c_8fDHCB.js} +1 -1
- package/dist/esm/hidden-input_2.entry.js +1 -1
- package/dist/esm/internal-tokenize-payment-method_7.entry.js +9 -7
- package/dist/esm/justifi-apple-pay_8.entry.js +5 -4
- package/dist/esm/justifi-business-details.entry.js +2 -2
- package/dist/esm/justifi-business-form.entry.js +2 -2
- package/dist/esm/justifi-checkout.entry.js +2 -2
- package/dist/esm/justifi-checkouts-list.entry.js +2 -2
- package/dist/esm/justifi-dispute-management.entry.js +2 -2
- package/dist/esm/justifi-dispute-notification_3.entry.js +2 -2
- package/dist/esm/justifi-gross-payment-chart.entry.js +2 -2
- package/dist/esm/justifi-order-terminals.entry.js +2 -2
- package/dist/esm/justifi-payment-details.entry.js +2 -2
- package/dist/esm/justifi-payment-provisioning.entry.js +2 -2
- package/dist/esm/justifi-payment-transactions-list.entry.js +2 -2
- package/dist/esm/justifi-payments-list.entry.js +2 -2
- package/dist/esm/justifi-payout-details.entry.js +2 -2
- package/dist/esm/justifi-payout-transactions-list.entry.js +2 -2
- package/dist/esm/justifi-payouts-list.entry.js +2 -2
- package/dist/esm/justifi-refund-payment.entry.js +98 -6
- package/dist/esm/justifi-season-interruption-insurance.entry.js +2 -2
- package/dist/esm/justifi-terminal-orders-list.entry.js +2 -2
- package/dist/esm/justifi-terminals-list.entry.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{package-Dr8Z8wfP.js → package-BzT9OxlN.js} +1 -1
- package/dist/esm/webcomponents.js +1 -1
- package/dist/module/bank-account-form.js +1 -1
- package/dist/module/bank-account.js +5 -2
- package/dist/module/card-form.js +1 -1
- package/dist/module/card-form2.js +5 -2
- package/dist/module/justifi-checkouts-list-filters.js +1 -1
- package/dist/module/justifi-payment-transactions-list.js +1 -1
- package/dist/module/justifi-payments-list-filters.js +1 -1
- package/dist/module/justifi-payout-transactions-list.js +1 -1
- package/dist/module/justifi-payouts-list-filters.js +1 -1
- package/dist/module/justifi-refund-payment.js +97 -4
- package/dist/module/justifi-terminal-orders-list-filters.js +1 -1
- package/dist/module/modular-checkout.js +3 -2
- package/dist/module/package.js +1 -1
- package/dist/module/payments-list-core2.js +1 -1
- package/dist/module/payout-details-core2.js +1 -1
- package/dist/module/payouts-list-core2.js +1 -1
- package/dist/module/terminal-orders-list-core2.js +1 -1
- package/dist/module/utils2.js +1 -1
- package/dist/types/actions/void/void-actions.d.ts +10 -0
- package/dist/types/api/services/void.service.d.ts +7 -0
- package/dist/types/components/modular-checkout/sub-components/bank-account.d.ts +1 -0
- package/dist/types/components/modular-checkout/sub-components/card-form.d.ts +1 -0
- package/dist/types/components/refund-payment/refund-payment.d.ts +6 -2
- package/dist/types/components.d.ts +3 -3
- package/dist/webcomponents/{p-4dc358aa.entry.js → p-035a4adc.entry.js} +1 -1
- package/dist/webcomponents/{p-e2d33311.entry.js → p-0935600b.entry.js} +1 -1
- package/dist/webcomponents/{p-c8a5a2a9.entry.js → p-0ab9a3ae.entry.js} +1 -1
- package/dist/webcomponents/{p-BEu9YFnf.js → p-11wdbrqX.js} +1 -1
- package/dist/webcomponents/{p-cbd52897.entry.js → p-138ada4a.entry.js} +1 -1
- package/dist/webcomponents/{p-d5765545.entry.js → p-148d3327.entry.js} +1 -1
- package/dist/webcomponents/p-2cb9edad.entry.js +1 -0
- package/dist/webcomponents/{p-ad3a73af.entry.js → p-2d4a2d26.entry.js} +1 -1
- package/dist/webcomponents/p-3f14d0c4.entry.js +1 -0
- package/dist/webcomponents/{p-cc2a1c7c.entry.js → p-5c6727ae.entry.js} +1 -1
- package/dist/webcomponents/{p-3fbe8ac3.entry.js → p-622af881.entry.js} +1 -1
- package/dist/webcomponents/{p-062fcfd5.entry.js → p-64ebff16.entry.js} +1 -1
- package/dist/webcomponents/p-71577fa1.entry.js +1 -0
- package/dist/webcomponents/{p-3fb1cf2b.entry.js → p-7ec4838f.entry.js} +1 -1
- package/dist/webcomponents/p-BzT9OxlN.js +1 -0
- package/dist/webcomponents/{p-5a7207c0.entry.js → p-af7c219d.entry.js} +1 -1
- package/dist/webcomponents/{p-5e6f2128.entry.js → p-b752c5bc.entry.js} +1 -1
- package/dist/webcomponents/{p-8884e000.entry.js → p-bbff6196.entry.js} +1 -1
- package/dist/webcomponents/p-c0c36187.entry.js +1 -0
- package/dist/webcomponents/{p-262e4b23.entry.js → p-d077569e.entry.js} +1 -1
- package/dist/webcomponents/{p-abcb4945.entry.js → p-d7b1b7b5.entry.js} +1 -1
- package/dist/webcomponents/{p-7bb7aaca.entry.js → p-dc6c9c79.entry.js} +1 -1
- package/dist/webcomponents/p-ecbc83bf.entry.js +1 -0
- package/dist/webcomponents/{p-cf644e46.entry.js → p-f56d7b4c.entry.js} +1 -1
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/docs/.eslintrc.cjs +17 -0
- package/docs/changelog/index.mdx +17 -0
- package/docs/entities/businessdetails/index.mdx +143 -0
- package/docs/entities/businessform/index.mdx +241 -0
- package/docs/entities/index.mdx +19 -0
- package/docs/entities/payment-provisioning/index.mdx +128 -0
- package/docs/frameworks/angular/index.mdx +112 -0
- package/docs/frameworks/index.mdx +18 -0
- package/docs/frameworks/react/index.mdx +125 -0
- package/docs/frameworks/vue/index.mdx +102 -0
- package/docs/helpers/PartsTable.js +50 -0
- package/docs/helpers/PropsTable.js +56 -0
- package/docs/helpers/index.ts +3 -0
- package/docs/helpers/version.js +32 -0
- package/docs/introduction/index.mdx +125 -0
- package/docs/merchant-tools/checkouts-list/index.mdx +97 -0
- package/docs/merchant-tools/gross-payments-chart/index.mdx +83 -0
- package/docs/merchant-tools/index.mdx +25 -0
- package/docs/merchant-tools/order-terminals/index.mdx +84 -0
- package/docs/merchant-tools/payment-details/index.mdx +132 -0
- package/docs/merchant-tools/payment-transactions-list/index.mdx +85 -0
- package/docs/merchant-tools/payments-list/index.mdx +109 -0
- package/docs/merchant-tools/payout-details/index.mdx +84 -0
- package/docs/merchant-tools/payout-transactions-list/index.mdx +84 -0
- package/docs/merchant-tools/payouts-list/index.mdx +92 -0
- package/docs/merchant-tools/terminal-orders-list/index.mdx +85 -0
- package/docs/merchant-tools/terminals-list/index.mdx +93 -0
- package/docs/modular-checkout/complete-examples/index.mdx +20 -0
- package/docs/modular-checkout/index.mdx +20 -0
- package/docs/modular-checkout/introduction/index.mdx +102 -0
- package/docs/modular-checkout/sub-components/apple-pay.mdx +106 -0
- package/docs/modular-checkout/sub-components/bank-account-form.mdx +167 -0
- package/docs/modular-checkout/sub-components/card-form.mdx +178 -0
- package/docs/modular-checkout/sub-components/index.mdx +23 -0
- package/docs/modular-checkout/sub-components/payment-method-options.mdx +87 -0
- package/docs/modular-checkout/sub-components/plaid-payment-method.mdx +158 -0
- package/docs/modular-checkout/sub-components/saved-payment-methods.mdx +183 -0
- package/docs/modular-checkout/sub-components/season-interruption-insurance.mdx +221 -0
- package/docs/modular-checkout/sub-components/sezzle-payment-method.mdx +183 -0
- package/docs/modular-checkout/sub-components/summary.mdx +111 -0
- package/docs/payment-facilitation/dispute-management/index.mdx +99 -0
- package/docs/payment-facilitation/index.mdx +21 -0
- package/docs/payment-facilitation/refund-payment/index.mdx +241 -0
- package/docs/payment-facilitation/tokenize-payment-method/index.mdx +350 -0
- package/docs/payment-facilitation/unified-fintech-checkout/342/204/242/index.mdx +150 -0
- package/package.json +21 -6
- package/dist/webcomponents/p-1df660a9.entry.js +0 -1
- package/dist/webcomponents/p-296bd0b6.entry.js +0 -1
- package/dist/webcomponents/p-Dr8Z8wfP.js +0 -1
- package/dist/webcomponents/p-ca0d1c6c.entry.js +0 -1
- package/dist/webcomponents/p-cc0c722c.entry.js +0 -1
- package/dist/webcomponents/p-def84700.entry.js +0 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: entities/payment-provisioning/index
|
|
3
|
+
title: Payment Provisioning
|
|
4
|
+
description: Embed-ready workflow for collecting payout bank info and provisioning merchants for funding.
|
|
5
|
+
sidebar_position: 12
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
import { PropsTable, PartsTable } from '@justifi/webcomponents/docs/helpers';
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Component to render a business onboarding form, segmented into multiple steps. You will need to first create a business via [Business API](https://docs.justifi.tech/api-spec#tag/Business) to get the business-id required for this component.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
<pre>
|
|
17
|
+
<code className="language-html">{`<justifi-payment-provisioning
|
|
18
|
+
account-id="acc_123"
|
|
19
|
+
auth-token="wct_provisioning"
|
|
20
|
+
business-id="biz_456"
|
|
21
|
+
on-success-text="Payout method saved"
|
|
22
|
+
/>`}</code>
|
|
23
|
+
</pre>
|
|
24
|
+
|
|
25
|
+
## Props, Events & Methods
|
|
26
|
+
|
|
27
|
+
<div
|
|
28
|
+
dangerouslySetInnerHTML={{
|
|
29
|
+
__html: PropsTable([
|
|
30
|
+
{
|
|
31
|
+
name: 'account-id',
|
|
32
|
+
type: 'string',
|
|
33
|
+
required: true,
|
|
34
|
+
description:
|
|
35
|
+
'Platform account or sub-account context for provisioning.',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'auth-token',
|
|
39
|
+
type: 'string',
|
|
40
|
+
required: true,
|
|
41
|
+
description:
|
|
42
|
+
'Token with `write:provisioning` scope to securely store payout details.',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'business-id',
|
|
46
|
+
type: 'string',
|
|
47
|
+
required: true,
|
|
48
|
+
description: 'Business whose payout method is being added.',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'on-success-text',
|
|
52
|
+
type: 'string',
|
|
53
|
+
description:
|
|
54
|
+
'Overrides the confirmation copy once the payout account is linked.',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'disable-ach',
|
|
58
|
+
type: 'boolean',
|
|
59
|
+
defaultValue: 'false',
|
|
60
|
+
description:
|
|
61
|
+
'Hide ACH specific fields when you only support push-to-card or other rails.',
|
|
62
|
+
},
|
|
63
|
+
]),
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
|
|
67
|
+
### Events
|
|
68
|
+
|
|
69
|
+
- `submitted`: Fires when payout information is collected and saved; payload includes the provisioning status.
|
|
70
|
+
- `error-event`: Provides `code`/`message` details when token scopes or API calls fail.
|
|
71
|
+
|
|
72
|
+
### Public methods
|
|
73
|
+
|
|
74
|
+
1. `submit()` – Trigger provisioning if you render external controls.
|
|
75
|
+
2. `focus()` – Move focus to the first interactive element (helpful after displaying a banner).
|
|
76
|
+
|
|
77
|
+
## Theming & Layout
|
|
78
|
+
|
|
79
|
+
<div
|
|
80
|
+
dangerouslySetInnerHTML={{
|
|
81
|
+
__html: PartsTable([
|
|
82
|
+
{
|
|
83
|
+
name: 'font-family',
|
|
84
|
+
description: 'Controls the font family for the component.',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'color',
|
|
88
|
+
description: 'Controls the text color.',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'background-color',
|
|
92
|
+
description: 'Controls the background color.',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'input',
|
|
96
|
+
description: 'Input field styles.',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'input-focused',
|
|
100
|
+
description: 'Input styles when focused.',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'input-invalid',
|
|
104
|
+
description: 'Input styles when invalid.',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'input-invalid-and-focused',
|
|
108
|
+
description: 'Input styles when invalid and focused.',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'button',
|
|
112
|
+
description: 'Button styles.',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'button-primary',
|
|
116
|
+
description: 'Primary button styles.',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'button-disabled',
|
|
120
|
+
description: 'Disabled button styles.',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'tooltip-inner',
|
|
124
|
+
description: 'Tooltip inner content styles.',
|
|
125
|
+
},
|
|
126
|
+
]),
|
|
127
|
+
}}
|
|
128
|
+
/>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: frameworks/angular/index
|
|
3
|
+
title: Angular
|
|
4
|
+
description: Registering and using JustiFi web components inside Angular projects.
|
|
5
|
+
sidebar_position: 2
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
import { getWebcomponentsVersion } from '@justifi/webcomponents/docs/helpers';
|
|
9
|
+
|
|
10
|
+
Angular can render the JustiFi custom elements once you load the library and allow custom schemas.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
### Load the bundle
|
|
15
|
+
|
|
16
|
+
<pre><code className="language-html">{`<head>
|
|
17
|
+
<script
|
|
18
|
+
type="module"
|
|
19
|
+
src="https://cdn.jsdelivr.net/npm/@justifi/webcomponents@${getWebcomponentsVersion()}/dist/webcomponents/webcomponents.esm.js"
|
|
20
|
+
></script>
|
|
21
|
+
|
|
22
|
+
</head>`}</code></pre>
|
|
23
|
+
|
|
24
|
+
Or install locally:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install --save @justifi/webcomponents
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Import specific elements where needed:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import '@justifi/webcomponents/dist/module/justifi-checkout.js';
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Allow custom elements
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
40
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
41
|
+
import { AppComponent } from './app.component';
|
|
42
|
+
|
|
43
|
+
@NgModule({
|
|
44
|
+
declarations: [AppComponent],
|
|
45
|
+
imports: [BrowserModule],
|
|
46
|
+
providers: [],
|
|
47
|
+
bootstrap: [AppComponent],
|
|
48
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
49
|
+
})
|
|
50
|
+
export class AppModule {}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Props and event handling
|
|
54
|
+
|
|
55
|
+
Use Angular bindings for attributes and `(event)` syntax for emitted events.
|
|
56
|
+
|
|
57
|
+
```html
|
|
58
|
+
<justifi-checkout
|
|
59
|
+
[auth-token]="authToken"
|
|
60
|
+
[checkout-id]="checkoutId"
|
|
61
|
+
[disable-bank-account]="true"
|
|
62
|
+
(submit-event)="handleSubmit($event)"
|
|
63
|
+
(error-event)="handleError($event)"
|
|
64
|
+
></justifi-checkout>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Calling methods
|
|
68
|
+
|
|
69
|
+
Leverage `ViewChild` to call public methods on the web component.
|
|
70
|
+
|
|
71
|
+
```html
|
|
72
|
+
<!-- app.component.html -->
|
|
73
|
+
<justifi-checkout
|
|
74
|
+
#checkoutForm
|
|
75
|
+
[auth-token]="authToken"
|
|
76
|
+
[checkout-id]="checkoutId"
|
|
77
|
+
(submit-event)="handleSubmit($event)"
|
|
78
|
+
></justifi-checkout>
|
|
79
|
+
<button (click)="fillBillingForm()">Fill billing form</button>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
// app.component.ts
|
|
84
|
+
import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core';
|
|
85
|
+
|
|
86
|
+
@Component({
|
|
87
|
+
selector: 'app-root',
|
|
88
|
+
templateUrl: './app.component.html',
|
|
89
|
+
})
|
|
90
|
+
export class AppComponent implements AfterViewInit {
|
|
91
|
+
@ViewChild('checkoutForm')
|
|
92
|
+
checkoutForm!: ElementRef<HTMLJustifiCheckoutElement>;
|
|
93
|
+
|
|
94
|
+
ngAfterViewInit() {
|
|
95
|
+
// Safe place to call component methods
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
fillBillingForm() {
|
|
99
|
+
const billing = {
|
|
100
|
+
name: 'John Doe',
|
|
101
|
+
address_line1: 'Main St',
|
|
102
|
+
address_city: 'Beverly Hills',
|
|
103
|
+
address_state: 'CA',
|
|
104
|
+
address_postal_code: '90210',
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
this.checkoutForm.nativeElement.fillBillingForm(billing);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
> `HTMLJustifiCheckoutElement` is available from `@justifi/webcomponents/dist/components` if you want stronger typing.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: frameworks/index
|
|
3
|
+
title: Frameworks
|
|
4
|
+
description: Entry point for Angular, React, and Vue 3 integration guides.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Pick the framework-specific guide that matches your host app. Each page covers
|
|
8
|
+
bundle registration, component typing, and ergonomics for that stack.
|
|
9
|
+
|
|
10
|
+
1. [Angular](./angular/index) – schemas, module setup, and DI-friendly helpers.
|
|
11
|
+
2. [React](./react/index) – rendering custom elements from JSX plus refs/events.
|
|
12
|
+
3. [Vue 3](./vue/index) – registering components globally or per-view with full
|
|
13
|
+
TypeScript support.
|
|
14
|
+
|
|
15
|
+
> Need another framework? Duplicate `templates/guide-template.mdx`, follow the
|
|
16
|
+
> checklist inside, and add it to this directory so it picks up the same
|
|
17
|
+
> navigation pattern.
|
|
18
|
+
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: frameworks/react/index
|
|
3
|
+
title: React
|
|
4
|
+
description: How to consume JustiFi web components inside React applications.
|
|
5
|
+
sidebar_position: 1
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
import { getWebcomponentsVersion } from '@justifi/webcomponents/docs/helpers';
|
|
9
|
+
|
|
10
|
+
React treats JustiFi web components like any other custom element. Load the bundle, optionally declare types, and use refs for method calls or event wiring.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
### Load the components
|
|
15
|
+
|
|
16
|
+
<pre><code className="language-html">{`<head>
|
|
17
|
+
<script
|
|
18
|
+
async
|
|
19
|
+
type="module"
|
|
20
|
+
src="https://cdn.jsdelivr.net/npm/@justifi/webcomponents@${getWebcomponentsVersion()}/dist/webcomponents/webcomponents.esm.js"
|
|
21
|
+
></script>
|
|
22
|
+
</head>`}</code></pre>
|
|
23
|
+
|
|
24
|
+
Or install the package:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install --save @justifi/webcomponents
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Then import the module you need:
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
import '@justifi/webcomponents/dist/module/justifi-checkout.js';
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Render inside JSX
|
|
37
|
+
|
|
38
|
+
```jsx
|
|
39
|
+
export function CheckoutExample() {
|
|
40
|
+
return (
|
|
41
|
+
<justifi-checkout auth-token="token" checkout-id="chk_123" locale="en-US" />
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## TypeScript integration
|
|
47
|
+
|
|
48
|
+
Let TypeScript know about the generated intrinsic elements so JSX understands attributes and custom events.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
// register-web-components.ts
|
|
52
|
+
import { JSX as LocalJSX } from '@justifi/webcomponents/dist/loader';
|
|
53
|
+
import { HTMLAttributes } from 'react';
|
|
54
|
+
|
|
55
|
+
type StencilToReact<T> = {
|
|
56
|
+
[K in keyof T]?: T[K] &
|
|
57
|
+
Omit<HTMLAttributes<Element>, 'className'> & {
|
|
58
|
+
class?: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
declare global {
|
|
63
|
+
export namespace JSX {
|
|
64
|
+
interface IntrinsicElements extends StencilToReact<LocalJSX.IntrinsicElements> {}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Import that file once at the edge of your application (for example inside `src/main.tsx`) so the declarations register globally.
|
|
70
|
+
|
|
71
|
+
## Calling methods with refs
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import { useRef } from 'react';
|
|
75
|
+
|
|
76
|
+
export default function CheckoutWithRef() {
|
|
77
|
+
const checkoutRef = useRef<any>(null);
|
|
78
|
+
|
|
79
|
+
const fillBillingForm = () => {
|
|
80
|
+
checkoutRef.current?.fillBillingForm({
|
|
81
|
+
name: 'John Doe',
|
|
82
|
+
address_line1: '123 Main St',
|
|
83
|
+
address_city: 'Minneapolis',
|
|
84
|
+
address_state: 'MN',
|
|
85
|
+
address_postal_code: '55401',
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<>
|
|
91
|
+
<justifi-checkout ref={checkoutRef} auth-token="token" checkout-id="chk_123" />
|
|
92
|
+
<button onClick={fillBillingForm}>Prefill billing</button>
|
|
93
|
+
</>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Listening to events
|
|
99
|
+
|
|
100
|
+
Attach listeners with `addEventListener` inside `useEffect` or via inline handlers if you wrap the component.
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import { useEffect, useRef } from 'react';
|
|
104
|
+
|
|
105
|
+
export function CheckoutWithEvents() {
|
|
106
|
+
const checkoutRef = useRef<any>(null);
|
|
107
|
+
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
const element = checkoutRef.current;
|
|
110
|
+
if (!element) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const handleSubmit = (event: CustomEvent) => {
|
|
115
|
+
console.log('Submit payload', event.detail);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
element.addEventListener('submit-event', handleSubmit);
|
|
119
|
+
return () => element.removeEventListener('submit-event', handleSubmit);
|
|
120
|
+
}, []);
|
|
121
|
+
|
|
122
|
+
return <justifi-checkout ref={checkoutRef} auth-token="token" checkout-id="chk_123" />;
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: frameworks/vue/index
|
|
3
|
+
title: Vue 3
|
|
4
|
+
description: Consume the JustiFi web components inside modern Vue applications.
|
|
5
|
+
sidebar_position: 3
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
import { getWebcomponentsVersion } from '@justifi/webcomponents/docs/helpers';
|
|
9
|
+
|
|
10
|
+
Vue treats the JustiFi custom elements like native HTML tags. Load the script, import what you need, and wire up refs/events.
|
|
11
|
+
|
|
12
|
+
## Integration steps
|
|
13
|
+
|
|
14
|
+
### Load the components
|
|
15
|
+
|
|
16
|
+
<pre><code className="language-html">{`<head>
|
|
17
|
+
<script
|
|
18
|
+
type="module"
|
|
19
|
+
src="https://cdn.jsdelivr.net/npm/@justifi/webcomponents@${getWebcomponentsVersion()}/dist/webcomponents/webcomponents.esm.js"
|
|
20
|
+
></script>
|
|
21
|
+
</head>`}</code></pre>
|
|
22
|
+
|
|
23
|
+
Or install locally and import the desired module:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install --save @justifi/webcomponents
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import '@justifi/webcomponents/dist/module/justifi-checkout.js';
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Use inside templates
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<template>
|
|
37
|
+
<justifi-checkout
|
|
38
|
+
ref="checkoutFormRef"
|
|
39
|
+
:auth-token="authToken"
|
|
40
|
+
:checkout-id="checkoutId"
|
|
41
|
+
:disable-credit-card="true"
|
|
42
|
+
/>
|
|
43
|
+
</template>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Event handling
|
|
47
|
+
|
|
48
|
+
Leverage Vue's `@event-name` syntax for the custom events we emit.
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<template>
|
|
52
|
+
<justifi-checkout
|
|
53
|
+
ref="checkoutFormRef"
|
|
54
|
+
:auth-token="authToken"
|
|
55
|
+
:checkout-id="checkoutId"
|
|
56
|
+
@submit-event="onSubmit"
|
|
57
|
+
@error-event="onError"
|
|
58
|
+
/>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<script setup lang="ts">
|
|
62
|
+
const onSubmit = (event: CustomEvent) => {
|
|
63
|
+
console.log('Submit payload', event.detail);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const onError = (event: CustomEvent) => {
|
|
67
|
+
console.error('Error payload', event.detail);
|
|
68
|
+
};
|
|
69
|
+
</script>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Calling methods
|
|
73
|
+
|
|
74
|
+
Grab a ref to the element and call the public APIs directly.
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<template>
|
|
78
|
+
<justifi-checkout
|
|
79
|
+
ref="checkoutFormRef"
|
|
80
|
+
:auth-token="authToken"
|
|
81
|
+
:checkout-id="checkoutId"
|
|
82
|
+
/>
|
|
83
|
+
<button @click="fillBillingForm">Prefill billing</button>
|
|
84
|
+
</template>
|
|
85
|
+
|
|
86
|
+
<script setup lang="ts">
|
|
87
|
+
import { ref } from 'vue';
|
|
88
|
+
|
|
89
|
+
const checkoutFormRef = ref<any>(null);
|
|
90
|
+
|
|
91
|
+
const fillBillingForm = () => {
|
|
92
|
+
checkoutFormRef.value?.fillBillingForm({
|
|
93
|
+
name: 'John Doe',
|
|
94
|
+
address_line1: 'Main St',
|
|
95
|
+
address_city: 'Beverly Hills',
|
|
96
|
+
address_state: 'CA',
|
|
97
|
+
address_postal_code: '90210',
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
</script>
|
|
101
|
+
```
|
|
102
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function escapeHtml(text) {
|
|
2
|
+
const map = {
|
|
3
|
+
'&': '&',
|
|
4
|
+
'<': '<',
|
|
5
|
+
'>': '>',
|
|
6
|
+
'"': '"',
|
|
7
|
+
"'": ''',
|
|
8
|
+
};
|
|
9
|
+
return text.replace(/[&<>"']/g, (m) => map[m]);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function PartsTable(parts, caption) {
|
|
13
|
+
if (!parts?.length) {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let html = '<table class="docs-parts-table">';
|
|
18
|
+
|
|
19
|
+
if (caption) {
|
|
20
|
+
html += `<caption>${escapeHtml(caption)}</caption>`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
html += `
|
|
24
|
+
<thead>
|
|
25
|
+
<tr>
|
|
26
|
+
<th scope="col">Part</th>
|
|
27
|
+
<th scope="col">Description</th>
|
|
28
|
+
<th scope="col">DOM target</th>
|
|
29
|
+
</tr>
|
|
30
|
+
</thead>
|
|
31
|
+
<tbody>`;
|
|
32
|
+
|
|
33
|
+
for (const part of parts) {
|
|
34
|
+
html += `
|
|
35
|
+
<tr>
|
|
36
|
+
<td>
|
|
37
|
+
<code>::part(${escapeHtml(part.name)})</code>
|
|
38
|
+
</td>
|
|
39
|
+
<td>${escapeHtml(part.description)}</td>
|
|
40
|
+
<td>${part.target ? escapeHtml(part.target) : '—'}</td>
|
|
41
|
+
</tr>`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
html += `
|
|
45
|
+
</tbody>
|
|
46
|
+
</table>`;
|
|
47
|
+
|
|
48
|
+
return html;
|
|
49
|
+
}
|
|
50
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
function escapeHtml(text) {
|
|
2
|
+
const map = {
|
|
3
|
+
'&': '&',
|
|
4
|
+
'<': '<',
|
|
5
|
+
'>': '>',
|
|
6
|
+
'"': '"',
|
|
7
|
+
"'": ''',
|
|
8
|
+
};
|
|
9
|
+
return text.replace(/[&<>"']/g, (m) => map[m]);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function PropsTable(rows, caption) {
|
|
13
|
+
if (!rows?.length) {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let html = '<table class="docs-props-table">';
|
|
18
|
+
|
|
19
|
+
if (caption) {
|
|
20
|
+
html += `<caption>${escapeHtml(caption)}</caption>`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
html += `
|
|
24
|
+
<thead>
|
|
25
|
+
<tr>
|
|
26
|
+
<th scope="col">Name</th>
|
|
27
|
+
<th scope="col">Type</th>
|
|
28
|
+
<th scope="col">Required</th>
|
|
29
|
+
<th scope="col">Default</th>
|
|
30
|
+
<th scope="col">Description</th>
|
|
31
|
+
</tr>
|
|
32
|
+
</thead>
|
|
33
|
+
<tbody>`;
|
|
34
|
+
|
|
35
|
+
for (const row of rows) {
|
|
36
|
+
html += `
|
|
37
|
+
<tr>
|
|
38
|
+
<td>
|
|
39
|
+
<code>${escapeHtml(row.name)}</code>
|
|
40
|
+
</td>
|
|
41
|
+
<td>
|
|
42
|
+
<code>${escapeHtml(row.type)}</code>
|
|
43
|
+
</td>
|
|
44
|
+
<td>${row.required ? 'Yes' : 'No'}</td>
|
|
45
|
+
<td>${row.defaultValue ? `<code>${escapeHtml(row.defaultValue)}</code>` : '—'}</td>
|
|
46
|
+
<td>${escapeHtml(row.description)}</td>
|
|
47
|
+
</tr>`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
html += `
|
|
51
|
+
</tbody>
|
|
52
|
+
</table>`;
|
|
53
|
+
|
|
54
|
+
return html;
|
|
55
|
+
}
|
|
56
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
let cachedVersion = null;
|
|
2
|
+
|
|
3
|
+
export const getWebcomponentsVersion = () => {
|
|
4
|
+
if (cachedVersion) {
|
|
5
|
+
return cachedVersion;
|
|
6
|
+
}
|
|
7
|
+
try {
|
|
8
|
+
// Try to import from the package (works in both Storybook and consumer apps)
|
|
9
|
+
const packageJson = require('@justifi/webcomponents/package.json');
|
|
10
|
+
const version = packageJson.version;
|
|
11
|
+
cachedVersion = version;
|
|
12
|
+
return version;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
// Fallback: try to read from local package.json (for build-time)
|
|
15
|
+
try {
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const packageJsonPath = path.resolve(__dirname, '../../package.json');
|
|
19
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
20
|
+
const version = packageJson.version;
|
|
21
|
+
cachedVersion = version;
|
|
22
|
+
return version;
|
|
23
|
+
} catch (fallbackError) {
|
|
24
|
+
// Last resort: return 'latest' if we can't determine the version
|
|
25
|
+
console.warn(
|
|
26
|
+
'Could not determine @justifi/webcomponents version, using "latest"'
|
|
27
|
+
);
|
|
28
|
+
return 'latest';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|