@amos.com/react-amos-js 0.5.0 → 0.6.1

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.
Files changed (2) hide show
  1. package/README.md +12 -7
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Amos React SDK
2
2
 
3
- `@amos.com/react-amos-js` is the React SDK for embedding Amos payment methods (credit card, bank account, Google Pay) into your React app via secure iframes.
3
+ `@amos.com/react-amos-js` is the React SDK for embedding Amos payment methods (credit card, bank account, Google Pay, Apple Pay) into your React app via secure iframes.
4
4
 
5
5
  It is a thin wrapper around [`@amos.com/amos-js`](../amos-js) that adapts the framework-agnostic iframe controller to idiomatic React components and hooks.
6
6
 
@@ -14,7 +14,7 @@ npm install @amos.com/react-amos-js
14
14
 
15
15
  - React components for the iframe payment method forms: `AmosCreditCardPaymentMethodForm`, `AmosBankAccountPaymentMethodForm`, `AmosGooglePayButton`, `AmosApplePayButton`.
16
16
  - React-flavoured iframe message helpers that accept a React `ref`: `validateForm({ iframeRef })`, `confirmPaymentIntent({ iframeRef, token })`, `confirmSetupIntent({ iframeRef, token })`.
17
- - Re-exports of the `@amos.com/amos-js` helpers and types that come up in client code: `createMessage`, `decodeJwt`, `getEmbedOrigin`, `formatGooglePayPaymentData`, `FormattedGooglePayPaymentData`, `Appearance`, `Message`, etc.
17
+ - Re-exports of the `@amos.com/amos-js` helpers and types that come up in client code: `createMessage`, `decodeJwt`, `getEmbedOrigin`, `hasNativeApplePaySession`, `formatGooglePayPaymentData`, `FormattedGooglePayPaymentData`, `Appearance`, `Message`, etc.
18
18
 
19
19
  > **Note:** A server-side SDK (for example `@amos.com/node`) must be used alongside `@amos.com/react-amos-js` for end-to-end payment processing. `@amos.com/react-amos-js` is the client-side half.
20
20
 
@@ -44,7 +44,7 @@ The following flow is for credit card and bank account payment method types only
44
44
  6. **Confirm the payment intent from the client**: call `confirmPaymentIntent({ iframeRef, token })` to continue the payment flow.
45
45
  7. **Handle UX**: show the user a "processing" state when the "Pay now" button is clicked, and show a success or error message via `onPaymentIntentConfirmationSucceeded` and `onConfirmationFailed`.
46
46
 
47
- ### Google Pay
47
+ ### Google Pay & Apple Pay
48
48
 
49
49
  Google Pay and Apple Pay are forms of express checkout. Their buttons are alternatives to the "Pay now" button in your payment forms. Users can make a payment with either flow.
50
50
 
@@ -74,7 +74,7 @@ Why this matters:
74
74
  - Raw payment details are submitted from the iframe directly to Amos-controlled infrastructure.
75
75
  - Your backend only creates payment intents (or setup intents) and returns a short-lived token used to continue the iframe flow.
76
76
  - `confirmPaymentIntent` / `confirmSetupIntent` sends the token back to the iframe to complete confirmation; it does not pass full payment method payloads through your app server.
77
- - In express flows (e.g. Google Pay), the iframe component handles payment data exchange and only asks your server to create a payment intent token.
77
+ - In express flows (Google Pay / Apple Pay), the iframe component handles payment data exchange and only asks your server to create a payment intent token.
78
78
 
79
79
  In short, your app orchestrates the payment flow, while sensitive payment data stays within Amos-controlled components and APIs.
80
80
 
@@ -262,6 +262,8 @@ function CheckoutGooglePay() {
262
262
  }
263
263
  ```
264
264
 
265
+ `AmosApplePayButton` uses the same props and express-checkout callbacks. Drop it in the same place (or alongside Google Pay) with the same `amount`, `merchantName`, and `onInitiatePaymentIntentRequest` wiring. On mount, the SDK tells the iframe whether the host has a native `ApplePaySession` (Safari); when it does not, the SDK may temporarily expand the iframe full-viewport for Chrome's QR handoff UI.
266
+
265
267
  ### Saving a payment method with setup intent (credit card)
266
268
 
267
269
  ```tsx
@@ -420,6 +422,8 @@ Renders the secure Google Pay iframe button (express checkout flow).
420
422
 
421
423
  Renders the secure Apple Pay iframe button (express checkout flow). Same props and callbacks as `AmosGooglePayButton`.
422
424
 
425
+ Only Amos domains need Apple merchant registration. During the `IFRAME_READY` handshake, the SDK sends `UPDATE_NATIVE_APPLE_PAY_SESSION` with `hasNativeApplePaySession` (whether the host page exposes a native `ApplePaySession`, typically Safari). When that is `false`, non-Safari browsers load Apple's SDK inside the embed iframe and may send `EXPAND_IFRAME` so Chrome's in-iframe QR handoff UI is not clipped; `COLLAPSE_IFRAME` restores the button-sized layout. Merchants do not need to call `hasNativeApplePaySession` / `updateNativeApplePaySession` or handle expand/collapse themselves — `AmosApplePayButton` does this automatically via the re-exported `@amos.com/amos-js` protocol.
426
+
423
427
  ### `formatGooglePayPaymentData({ paymentData })`
424
428
 
425
429
  Transforms Google Pay payment data into an Amos-compatible `paymentMethod` payload. Use this when integrating with the raw Google Pay API (e.g. `@google-pay/button-react`) instead of `AmosGooglePayButton` — `AmosGooglePayButton` handles payment data internally and does not require this helper.
@@ -430,9 +434,9 @@ Transforms Google Pay payment data into an Amos-compatible `paymentMethod` paylo
430
434
 
431
435
  **Returns:** `FormattedGooglePayPaymentData` — the `paymentMethod` field is typed for embed confirm endpoints, so no extra type assertions are needed at call sites.
432
436
 
433
- ### `createMessage(message)` / `decodeJwt(token)` / `getEmbedOrigin(renderToken)`
437
+ ### `createMessage(message)` / `decodeJwt(token)` / `getEmbedOrigin(renderToken)` / `hasNativeApplePaySession()`
434
438
 
435
- Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most integrators do not need to call these directly.
439
+ Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most integrators do not need to call these directly. `hasNativeApplePaySession` reports whether the host page has a native `ApplePaySession` (Safari); `AmosApplePayButton` already uses it during the iframe handshake.
436
440
 
437
441
  ### Exported types
438
442
 
@@ -442,7 +446,8 @@ Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most int
442
446
 
443
447
  - **`ref` / `iframeRef`**: for card and bank forms, pass `ref={iframeRef}` to the form component. The same `iframeRef` must be used when calling `validateForm`, `confirmPaymentIntent`, or `confirmSetupIntent`. The component forwards the ref to the inner iframe.
444
448
  - **Same components for payment vs setup intents**: `AmosCreditCardPaymentMethodForm` and `AmosBankAccountPaymentMethodForm` support both payment intents and setup intents. The flow differs only by which server call you make and which confirmation function you use (`confirmPaymentIntent` vs `confirmSetupIntent`). You may optionally provide `onPaymentIntentConfirmationSucceeded` and/or `onSetupIntentConfirmationSucceeded`; the appropriate one is invoked based on the flow.
445
- - **Amount format**: for `AmosGooglePayButton`, `amount` is a string (e.g. `"5000"` for $50.00). For `components["schemas"]["CreatePaymentIntentInput"]` on the server, `amount` is a number in cents (e.g. `5000`).
449
+ - **Amount format**: for `AmosGooglePayButton` and `AmosApplePayButton`, `amount` is a string (e.g. `"5000"` for $50.00). For `components["schemas"]["CreatePaymentIntentInput"]` on the server, `amount` is a number in cents (e.g. `5000`).
450
+ - **Apple Pay iframe overlay**: on browsers without a native `ApplePaySession` (e.g. Chrome), the SDK may expand the Apple Pay iframe to a full-viewport overlay for QR handoff. Do not clip the iframe in an overflow-hidden container that would prevent that expand, and avoid competing fixed overlays at a higher z-index. During expand, the SDK sets the iframe to `position: fixed` covering the viewport and hides `document.body` overflow.
446
451
  - **Going framework-free**: if you need to use Amos outside of React (vanilla JS, another framework, etc.), use [`@amos.com/amos-js`](../amos-js) directly.
447
452
 
448
453
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amos.com/react-amos-js",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,14 +40,14 @@
40
40
  "@changesets/cli": "2.31.1",
41
41
  "@types/node": "26.1.1",
42
42
  "@types/react": "19.2.17",
43
- "typescript": "7.0.2",
44
43
  "@typescript/typescript6": "6.0.2",
44
+ "typescript": "7.0.2",
45
45
  "vite": "8.1.5",
46
46
  "vite-plugin-dts": "5.0.3"
47
47
  },
48
48
  "dependencies": {
49
- "@amos.com/amos-js": "0.5.0",
50
- "@amos.com/node": "0.1.31",
49
+ "@amos.com/amos-js": "0.6.1",
50
+ "@amos.com/node": "0.1.32",
51
51
  "@types/googlepay": "0.7.11"
52
52
  },
53
53
  "peerDependencies": {