Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEXT-36303 - In-App Purchases #318

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
label: "In App Purchases"
position: 350
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 14 additions & 0 deletions packages/admin-sdk/src/iap/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { createSender } from '../channel';

/**
* Trigger the in-app purchase checkout modal.
*/
export const purchase = createSender('iapCheckout');

export type iapCheckout<T extends 'oneTime' | 'subscription' = 'oneTime' | 'subscription'> = {
responseType: unknown,

identifier: string,
rentType: T,
model: T extends 'subscription' ? 'yearly' | 'monthly' : undefined | null,
}
2 changes: 2 additions & 0 deletions packages/admin-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -47,6 +48,7 @@ export {
app,
data,
composables,
iap,
};

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/admin-sdk/src/message-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import type {
repositoryDelete,
repositoryCreate,
} from './data/repository';
import type { iapCheckout } from './iap';

/**
* Contains all shopware send types.
Expand Down Expand Up @@ -92,6 +93,7 @@ export interface ShopwareMessageTypes {
datasetSubscribeRegistration: datasetSubscribeRegistration,
datasetUpdate: datasetUpdate,
datasetGet: datasetGet,
iapCheckout: iapCheckout,
__function__: __function__,
__registerWindow__: __registerWindow__,
_multiply: _multiply,
Expand Down
Loading