Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1203 from Shopify/liz/update-line-item-billing-flag
Browse files Browse the repository at this point in the history
Update line item billing flag to v10
  • Loading branch information
lizkenyon authored Feb 8, 2024
2 parents bbb4ab2 + 3c4844f commit fb28aed
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 22 deletions.
13 changes: 13 additions & 0 deletions .changeset/gorgeous-kids-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@shopify/shopify-api": minor
---

Update lineItemBilling future flag to v10. Current users of `unstable_lineItemBilling` will need to update to `v10_lineItemBilling` to continue using this feature.

```ts
const shopify = shopifyApi({
// ...
future: {
v10_lineItemBilling: true,
});
```
10 changes: 5 additions & 5 deletions packages/shopify-api/docs/guides/billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ To trigger the billing behaviour, you'll need to set the `billing` value when ca

## Configuring LineItem billing

With the future flag `unstable_lineItemBilling`, the billing configuration can now specify the the `AppSubscriptionLineItems`. This will allow you to create app subscription plans with both recurring and usage based charges.
With the future flag `v10_lineItemBilling`, the billing configuration can now specify the the `AppSubscriptionLineItems`. This will allow you to create app subscription plans with both recurring and usage based charges.

Subscription plans can have 1 or 2 line items. There can be a maximum of 1 of each type of plan Usage and Recurring. Usage line items can only be used in conjunction with recurring line items when the recurring line item interval is `BillingInterval.Every30Days`.

Expand Down Expand Up @@ -47,7 +47,7 @@ const shopify = shopifyApi({
},
}
future: {
unstable_lineItemBilling: true,
v10_lineItemBilling: true,
});
```
Expand Down Expand Up @@ -89,7 +89,7 @@ const shopify = shopifyApi({
},
},
future: {
unstable_lineItemBilling: true,
v10_lineItemBilling: true,
});
```
Expand All @@ -113,7 +113,7 @@ const shopify = shopifyApi({
},
}
future: {
unstable_lineItemBilling: true,
v10_lineItemBilling: true,
});
```
Expand Down Expand Up @@ -158,7 +158,7 @@ future: {
## Configuring Billing
Prior to the future flag `unstable_lineItemBilling` and when the flag is set to false you will configure billing as follows. For example, the following configuration will allow you to charge merchants $30 every 30 days. The first three charges will be discounted by $10, so merchants would be charged $20.
Prior to the future flag `v10_lineItemBilling` and when the flag is set to false you will configure billing as follows. For example, the following configuration will allow you to charge merchants $30 every 30 days. The first three charges will be discounted by $10, so merchants would be charged $20.
```ts
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/shopify-api/future/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface FutureFlags {
/**
* Enable line item billing, to make billing configuration more similar to the GraphQL API.
*/
unstable_lineItemBilling?: boolean;
v10_lineItemBilling?: boolean;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/shopify-api/lib/__tests__/test-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type TestConfig<Overrides extends TestOverridesOption<Future>, Future> = Modify<
* old behaviour.
*/
const TEST_FUTURE_FLAGS: Required<{[key in keyof FutureFlags]: true}> = {
unstable_lineItemBilling: true,
v10_lineItemBilling: true,
unstable_tokenExchange: true,
} as const;

Expand Down
24 changes: 11 additions & 13 deletions packages/shopify-api/lib/billing/__tests__/legacy-request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ const GRAPHQL_BASE_REQUEST = {

interface TestConfigInterface {
name: string;
billingConfig:
| BillingConfig
| BillingConfig<{unstable_lineItemBilling: false}>;
billingConfig: BillingConfig | BillingConfig<{v10_lineItemBilling: false}>;
paymentResponse: string;
responseObject: any;
errorResponse: string;
Expand Down Expand Up @@ -197,7 +195,7 @@ describe('shopify.billing.request', () => {
testConfig({
billing: undefined,
future: {
unstable_lineItemBilling: false,
v10_lineItemBilling: false,
},
}),
);
Expand All @@ -224,7 +222,7 @@ describe('shopify.billing.request', () => {
testConfig({
billing: config.billingConfig,
future: {
unstable_lineItemBilling: false,
v10_lineItemBilling: false,
},
}),
);
Expand Down Expand Up @@ -261,7 +259,7 @@ describe('shopify.billing.request', () => {
testConfig({
billing: config.billingConfig,
future: {
unstable_lineItemBilling: false,
v10_lineItemBilling: false,
},
}),
);
Expand Down Expand Up @@ -298,7 +296,7 @@ describe('shopify.billing.request', () => {
testConfig({
billing: config.billingConfig,
future: {
unstable_lineItemBilling: false,
v10_lineItemBilling: false,
},
}),
);
Expand Down Expand Up @@ -330,7 +328,7 @@ describe('shopify.billing.request', () => {
testConfig({
billing: config.billingConfig,
future: {
unstable_lineItemBilling: false,
v10_lineItemBilling: false,
},
}),
);
Expand Down Expand Up @@ -388,7 +386,7 @@ describe('shopify.billing.request', () => {
testConfig({
billing: config.billingConfig,
future: {
unstable_lineItemBilling: false,
v10_lineItemBilling: false,
},
}),
);
Expand Down Expand Up @@ -419,7 +417,7 @@ describe('shopify.billing.request', () => {
testConfig({
billing: config.billingConfig,
future: {
unstable_lineItemBilling: false,
v10_lineItemBilling: false,
},
}),
);
Expand Down Expand Up @@ -499,7 +497,7 @@ describe('shopify.billing.request', () => {
},
},
future: {
unstable_lineItemBilling: false,
v10_lineItemBilling: false,
},
}),
);
Expand Down Expand Up @@ -532,7 +530,7 @@ describe('shopify.billing.request', () => {
},
},
future: {
unstable_lineItemBilling: false,
v10_lineItemBilling: false,
},
}),
);
Expand Down Expand Up @@ -570,7 +568,7 @@ describe('shopify.billing.request', () => {
},
},
future: {
unstable_lineItemBilling: false,
v10_lineItemBilling: false,
},
}),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/shopify-api/lib/billing/__tests__/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const GRAPHQL_BASE_REQUEST = {

interface TestConfigInterface {
name: string;
billingConfig: BillingConfig<{unstable_lineItemBilling: true}>;
billingConfig: BillingConfig<{v10_lineItemBilling: true}>;
paymentResponse: string;
responseObject: any;
errorResponse: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/shopify-api/lib/billing/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export type BillingConfigLegacyItem =

export type BillingConfigItem<
Future extends FutureFlagOptions = FutureFlagOptions,
> = FeatureEnabled<Future, 'unstable_lineItemBilling'> extends true
> = FeatureEnabled<Future, 'v10_lineItemBilling'> extends true
? BillingConfigOneTimePlan | BillingConfigSubscriptionLineItemPlan
: BillingConfigLegacyItem;

Expand Down

0 comments on commit fb28aed

Please sign in to comment.