diff --git a/docs/admin-sdk/docs/guide/2_api-reference/in-app-purchases/_category_.yml b/docs/admin-sdk/docs/guide/2_api-reference/in-app-purchases/_category_.yml new file mode 100644 index 000000000..8d3add522 --- /dev/null +++ b/docs/admin-sdk/docs/guide/2_api-reference/in-app-purchases/_category_.yml @@ -0,0 +1,2 @@ +label: "In App Purchases" +position: 350 diff --git a/docs/admin-sdk/docs/guide/2_api-reference/in-app-purchases/in-app-purchases.md b/docs/admin-sdk/docs/guide/2_api-reference/in-app-purchases/in-app-purchases.md new file mode 100644 index 000000000..f93458ac7 --- /dev/null +++ b/docs/admin-sdk/docs/guide/2_api-reference/in-app-purchases/in-app-purchases.md @@ -0,0 +1,17 @@ +# In-App Purchase Flow + +> Available since Shopware v6.6.7.0 +> +In-App purchases allow you to create different functionality based on purchases the user has made in your app. This guide will show you how to start the in-app purchase flow. + +### Opening modal with details of feature + +To open a modal with the details of the feature you want to purchase, you can use the following code: + +```ts +sw.iap.purchase({ + identifier: 'your-in-app-purchase-id', +}); +``` + +This will create a modal in admin which takes the user through the checkout flow in which the app will be purchased or subscribed to. diff --git a/packages/admin-sdk/src/iap/index.ts b/packages/admin-sdk/src/iap/index.ts new file mode 100644 index 000000000..074431267 --- /dev/null +++ b/packages/admin-sdk/src/iap/index.ts @@ -0,0 +1,14 @@ +import { createSender } from '../channel'; + +/** + * Trigger the in-app purchase checkout modal. + */ +export const purchase = createSender('iapCheckout'); + +export type iapCheckout = { + responseType: unknown, + + identifier: string, + rentType: T, + model: T extends 'subscription' ? 'yearly' | 'monthly' : undefined | null, +} diff --git a/packages/admin-sdk/src/index.ts b/packages/admin-sdk/src/index.ts index cd24a7b17..6177b4ec1 100644 --- a/packages/admin-sdk/src/index.ts +++ b/packages/admin-sdk/src/index.ts @@ -14,6 +14,7 @@ import * as modal from './ui/modal'; import * as actionButton from './ui/action-button'; import * as webhook from './app/action'; import * as data from './data'; +import * as iap from './iap'; import type EntityCollectionType from './_internals/data/EntityCollection'; import type { Entity as EntityType } from './_internals/data/Entity'; import composables from './data/composables'; @@ -47,6 +48,7 @@ export { app, data, composables, + iap, }; /** diff --git a/packages/admin-sdk/src/message-types.ts b/packages/admin-sdk/src/message-types.ts index 825ea1ee5..2c939538d 100644 --- a/packages/admin-sdk/src/message-types.ts +++ b/packages/admin-sdk/src/message-types.ts @@ -38,6 +38,7 @@ import type { repositoryDelete, repositoryCreate, } from './data/repository'; +import type { iapCheckout } from './iap'; /** * Contains all shopware send types. @@ -92,6 +93,7 @@ export interface ShopwareMessageTypes { datasetSubscribeRegistration: datasetSubscribeRegistration, datasetUpdate: datasetUpdate, datasetGet: datasetGet, + iapCheckout: iapCheckout, __function__: __function__, __registerWindow__: __registerWindow__, _multiply: _multiply,