Push JS SDK Reference
The SDK must be loaded as a script tag on your website — it cannot be statically bundled via package management.Widget
new window.PushCash.Widget(options)
Creates and renders the Push User Widget into your page to receive card details from a user.
Options (WidgetOptions)
| Field | Type | Required | Description |
|---|---|---|---|
selector | string | ✅ | CSS selector for the container element to render into. |
url | string | ✅ | Widget URL returned from create-widget-url. |
onValid | () => void | ❌ | Called once the widget has received valid card details. Use to enable the submit button. |
background | string | ❌ | Widget background (CSS color value). |
fontSize | string | ❌ | Base font size (CSS value, e.g. 14px). |
borderRadius | string | ❌ | Corner radius (CSS value, e.g. 12px). |
padding | string | ❌ | Inner padding (CSS value, e.g. 16px). |
color | string | ❌ | Text color (CSS color value). |
Returns
AWidget instance.
Example
widget.tokenize()
Generates a token from the user’s card details which can be used to authorize a transaction on the user’s card by calling authorize-payment. If the tokenize function is called before the user has provided valid card details, will throw an error.
Signature
widget.destroy()
Unmounts the widget and cleans up resources.
Signature
Apple Pay Launcher
new window.PushCash.ApplePay(config)
Creates an Apple Pay launcher instance.
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
token | string | ✅ | Apple Pay token returned from create-token with type: "apple_pay". Must be newly created per page load. |
Example
launcher.display(args)
Launches the Apple Pay payment sheet and runs the Apple Pay flow.
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
amount | number | ✅ | Payment amount in cents (must be > 0). |
direction | 'cash_in' | ✅ | Only cash_in is supported. |
currency | 'USD' | ✅ | Only "USD" is supported. |
onStart | () => Promise<void> | ✅ | Called during the presentation of the payment sheet to the user. Use this to create a payment intent with type: "apple_pay" and the apple pay token. |
onComplete | () => void | Promise<void> | ❌ | Called when the Apple Pay session completes. |