@@ -110,14 +110,18 @@ function App() {
110110```
111111
112112See [ Usage with the Storefront API] ( #usage-with-the-storefront-api ) below on how
113- to get a checkoutUrl to pass to the SDK.
113+ to get a checkout URL to pass to the kit.
114+
115+ <!-- prettier-ignore-start -->
114116
115117> [ !NOTE]
116118> The recommended usage of the library is through a
117119> ` ShopifyCheckoutSheetProvider ` Context provider, but see
118120> [ Programmatic usage] ( #programamatic-usage ) below for details on how to use the
119121> library without React context.
120122
123+ <!-- prettier-ignore-end -->
124+
121125### Programmatic Usage
122126
123127To use the library without React context, import the ` ShopifyCheckoutSheet `
@@ -264,11 +268,15 @@ function App() {
264268}
265269```
266270
271+ <!-- prettier-ignore-start -->
272+
267273> [!TIP]
268- > To help optimize and deliver the best experience the SDK also provides a
269- > [preloading API](#preloading) that can be used to initialize the checkout
274+ > To help optimize and deliver the best experience the SDK also provides
275+ > a [preloading API](#preloading) that can be used to initialize the checkout
270276> session in the background and ahead of time.
271277
278+ <!-- prettier-ignore-end -->
279+
272280### Configuration
273281
274282The SDK provides a way to customize the presented checkout experience through a
@@ -296,11 +304,11 @@ const config: Configuration = {
296304 colors : {
297305 ios: {
298306 backgroundColor: ' #f0f0e8' ,
299- spinnerColor : ' #2d2a38' ,
307+ tintColor : ' #2d2a38' ,
300308 },
301309 android: {
302310 backgroundColor: ' #f0f0e8' ,
303- spinnerColor : ' #2d2a38' ,
311+ progressIndicator : ' #2d2a38' ,
304312 headerBackgroundColor: ' #f0f0e8' ,
305313 headerTextColor: ' #2d2a38' ,
306314 },
@@ -344,11 +352,11 @@ const config: Configuration = {
344352 colors : {
345353 ios: {
346354 backgroundColor: ' #ffffff' ,
347- spinnerColor : ' #000000' ,
355+ tintColor : ' #000000' ,
348356 },
349357 android: {
350358 backgroundColor: ' #ffffff' ,
351- spinnerColor : ' #2d2a38' ,
359+ progressIndicator : ' #2d2a38' ,
352360 headerBackgroundColor: ' #ffffff' ,
353361 headerTextColor: ' #000000' ,
354362 },
@@ -374,13 +382,13 @@ const config: Configuration = {
374382 android: {
375383 light: {
376384 backgroundColor: ' #ffffff' ,
377- spinnerColor : ' #2d2a38' ,
385+ progressIndicator : ' #2d2a38' ,
378386 headerBackgroundColor: ' #ffffff' ,
379387 headerTextColor: ' #000000' ,
380388 },
381389 dark: {
382390 backgroundColor: ' #000000' ,
383- spinnerColor : ' #0087ff' ,
391+ progressIndicator : ' #0087ff' ,
384392 headerBackgroundColor: ' #000000' ,
385393 headerTextColor: ' #ffffff' ,
386394 },
@@ -397,6 +405,88 @@ function AppWithContext() {
397405}
398406```
399407
408+ ### Localization
409+
410+ #### Checkout Sheet title
411+
412+ There are several ways to change the title of the Checkout Sheet.
413+
414+ ##### iOS
415+
416+ On iOS, you can set a localized value on the `title` attribute of the
417+ configuration.
418+
419+ Alternatively, use a Localizable.xcstrings file in your app by doing the
420+ following:
421+
422+ 1. Create a `Localizable.xcstrings` file under "ios/{ YourApplicationName } "
423+ 2. Add an entry for the key `"shopify_checkout_sheet_title"`
424+
425+ ##### Android
426+
427+ On Android, you can add a string entry for the key `"checkout_web_view_title"`
428+ to the "android/app/src/res/values/strings.xml" file for your application.
429+
430+ ```diff
431+ <resources >
432+ <string name = " app_name" >Your App Name</string >
433+ + <string name = " checkout_web_view_title" >Checkout</string >
434+ </resources >
435+ ```
436+
437+ <!-- prettier-ignore-start -->
438+
439+ > [!IMPORTANT]
440+ > The `title` configuration attribute will only affect iOS. For Android you **must** use
441+ > `res/values/strings.xml`.
442+
443+ <!-- prettier-ignore-end -->
444+
445+ #### Currency
446+
447+ To set an appropriate currency for a given cart, the Storefront API offers an
448+ `@inContext(country)` directive which will ensure the correct currency is
449+ presented.
450+
451+ ```tsx
452+ const CREATE_CART_MUTATION = gql`
453+ mutation CreateCart($input: CartInput, $country: CountryCode = CA)
454+ @inContext(country: $country) {
455+ cartCreate (input : $input ) {
456+ cart {
457+ id
458+ checkoutUrl
459+ }
460+ }
461+ }
462+ `;
463+ ```
464+
465+ See [Storefront Directives](https://shopify.dev/docs/api/storefront#directives)
466+ for more information.
467+
468+ #### Language
469+
470+ Similarly to currency, you can use an `@inContext(language)` directive to set
471+ the language for your checkout.
472+
473+ ```tsx
474+ const CREATE_CART_MUTATION = gql`
475+ mutation CreateCart($input: CartInput, $language: Language = EN)
476+ @inContext(language: $language) {
477+ cartCreate (input : $input ) {
478+ cart {
479+ id
480+ checkoutUrl
481+ }
482+ }
483+ }
484+ `;
485+ ```
486+
487+ See [Storefront Directives](https://shopify.dev/docs/api/storefront#directives)
488+ for more information.
489+
400490### Preloading
401491
402492Initializing a checkout session requires communicating with Shopify servers,
@@ -444,12 +534,12 @@ There are currently 3 checkout events exposed through the Native Module. You can
444534subscribe to these events using `addEventListener` and `removeEventListeners`
445535methods - available on both the context provider as well as the class instance.
446536
447- | Name | Callback | Description |
448- | ----------- | ------------------------------------ | ------------------------------------------------------------ |
449- | `close` | `() => void` | Fired when the checkout has been closed. |
450- | `completed` | `() => void` | Fired when the checkout has been successfully completed. |
451- | `error` | `(error: { message : string } ) => void` | Fired when a checkout exception has been raised. |
452- | `pixel` | `(event: PixelEvent) => void` | Fired when a Web Pixel event has been relayed from checkout. |
537+ | Name | Callback | Description |
538+ | ----------- | ----------------------------------------- | ------------------------------------------------------------ |
539+ | `close` | `() => void` | Fired when the checkout has been closed. |
540+ | `completed` | `(event: CheckoutCompletedEvent ) => void` | Fired when the checkout has been successfully completed. |
541+ | `error` | `(error: { message : string } ) => void` | Fired when a checkout exception has been raised. |
542+ | `pixel` | `(event: PixelEvent) => void` | Fired when a Web Pixel event has been relayed from checkout. |
453543
454544#### `addEventListener(eventName, callback)`
455545
@@ -466,9 +556,13 @@ useEffect(() => {
466556 // Do something on checkout close
467557 });
468558
469- const completed = shopifyCheckout .addEventListener (' completed' , () => {
470- // Do something on checkout completion
471- });
559+ const completed = shopifyCheckout .addEventListener (
560+ ' completed' ,
561+ (event : CheckoutCompletedEvent ) => {
562+ // Lookup order on checkout completion
563+ const orderId = event .orderDetails .id ;
564+ },
565+ );
472566
473567 const error = shopifyCheckout .addEventListener (
474568 ' error' ,
@@ -565,10 +659,14 @@ external identity system and initialize a buyer-aware checkout session.
565659 `checkoutUrl`
5666602. Provide the Multipass URL to `present(checkoutUrl)`
567661
662+ <!-- prettier-ignore-start -->
663+
568664> [!IMPORTANT]
569- > The above JSON omits useful customer attributes that should be provided
570- > where possible and encryption and signing should be done server-side to ensure
571- > Multipass keys are kept secret._
665+ > The above JSON omits useful customer attributes that should be
666+ > provided where possible and encryption and signing should be done server-side
667+ > to ensure Multipass keys are kept secret.
668+
669+ <!-- prettier-ignore-end -->
572670
573671#### Shop Pay
574672
@@ -595,7 +693,8 @@ see [guidelines and instructions](.github/CONTRIBUTING.md). See
595693
596694#### Running the sample app
597695
598- To run the sample app in this repo, first clone the repo and run the following commands at the root of the project directory.
696+ To run the sample app in this repo, first clone the repo and run the following
697+ commands at the root of the project directory.
599698
600699#### Install NPM dependencies
601700
@@ -617,7 +716,8 @@ yarn module build
617716
618717#### Update the dotenv file
619718
620- Replace the details in the `sample/.env.example` file and rename it to `sample/.env`
719+ Replace the details in the `sample/.env.example` file and rename it to
720+ `sample/.env`
621721
622722```
623723# Storefront Details
0 commit comments