@schematichq/schematic-components 2.18.0 → 2.20.0

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.
package/README.md CHANGED
@@ -59,6 +59,7 @@ const config = {
59
59
  payInAdvanceQuantities: { // pre-fill pay-in-advance quantities, keyed by feature id (optional)
60
60
  feat_cns2asuKAG2: 3, // "feat_cns2asuKAG2" is a feature id, 3 is the quantity
61
61
  },
62
+ promoCode: 'SUMMER20', // pre-apply a Stripe promotion code (optional)
62
63
  skipped: {
63
64
  planStage: true, // if true, skip Plan selection
64
65
  addOnStage: true, // if true, skip Add-on selection
@@ -76,9 +77,41 @@ pricing; entries for other (or unknown) features are ignored. Combine it with
76
77
  `skipped.usageStage` / `skipped.addOnUsageStage` to send the customer straight to
77
78
  the final checkout step with the quantities already set.
78
79
 
80
+ `promoCode` pre-applies a discount to the checkout. It expects a Stripe
81
+ [promotion code](https://docs.stripe.com/billing/subscriptions/coupons) — the
82
+ customer-facing code such as `SUMMER20`, not the underlying coupon id. The
83
+ discount is applied on load, so the previewed charges reflect it and it ships
84
+ with the final checkout request.
85
+
79
86
  The Plans and Add-ons available to the checkout flows must be live in your
80
87
  Schematic account [Catalog configuration](https://docs.schematichq.com/catalog/overview).
81
88
 
89
+ ## Programmatic Unsubscribe
90
+
91
+ We provide a function `requestUnsubscribe` for starting the unsubscribe flow
92
+ from your own UI, without using the built-in `UnsubscribeButton`. Like
93
+ `initializeWithPlan`, it's suitable for click handlers and must be extracted
94
+ from the library's embedded context.
95
+
96
+ ```ts
97
+ const { requestUnsubscribe } = useEmbed();
98
+ ```
99
+
100
+ This lets developers create their own button — for example, a custom
101
+ "are you sure?" retention flow — that hands off to the same unsubscribe
102
+ experience the built-in component uses.
103
+
104
+ ```ts
105
+ requestUnsubscribe();
106
+ ```
107
+
108
+ The function takes no arguments. If there is no active subscription to cancel,
109
+ the request is ignored and a warning is logged to the console.
110
+
111
+ The unsubscribe flow is rendered by the embed itself, so a Schematic embed (the
112
+ `Viewport` that hosts it) must be mounted on the page where you call
113
+ `requestUnsubscribe`. This is the same requirement as `initializeWithPlan`.
114
+
82
115
  ## License
83
116
 
84
117
  MIT