-
Notifications
You must be signed in to change notification settings - Fork 49
Subscriptions
Kori Francis edited this page Dec 8, 2016
·
2 revisions
- Create/Update/Cancel/Delete
- Preview using
PreviewMigrateSubscriptionProduct
- Override using
SetSubscriptionOverride
- Delay and Cancel Delay using
CancelDelayedProductChange
The new SubscriptionCreateOptions
allows you to create subscriptions using every possibly input, rather than rely on an ever growing list of overrides that are hard to maintain.
// Most common example: new customer, new card
var options = new SubscriptionCreateOptions() {
CustomerAttributes = newCustomerAttributes,
CreditCardAttributes = paymentInfo,
ProductHandle = product.Handle
};
// Use an existing customer
var options = new SubscriptionCreateOptions() {
CustomerID = exampleCustomer.ChargifyID,
CreditCardAttributes = paymentInfo,
ProductHandle = product.Handle
};
// Complex, import with components
var options = new SubscriptionCreateOptions() {
CustomerAttributes = customerImportedAttributes,
PaymentProfileAttributes = paymentProfileImportAttributes,
ProductHandle = product.Handle,
Components = new List<ComponentDetails>{ new ComponentDetails { ComponentID = 123, Enabled = true }, new ComponentDetails { ComponentID = 234, AllocatedQuantity = 5}}
};
var newSubscription = client.CreateSubscription(options);
This is the original set of "subscription create" methods, they generally require input about the customer, product and payment though can also include some metadata, component allocations, coupons though a series of overloads on the methods CreateSubscription
and CreateSubscriptionUsingCoupon
. Internally, these will all be eventually converted to using SubscriptionCreateOptions
but are being kept as a convenience to existing usage.
var newSubscription = client.CreateSubscription(product.Handle, newCustomer, newPaymentInfo);