Subscriptions
Update Subscription
Changed onUpdates the configuration of an existing subscription.
Modifiable Parameters:
- Billing information (priceId, amount, interval, intervalCount, description, allowedPaymentMethods)
- Customer details (contact information, billing/shipping addresses)
- Subscription settings (cancelAtPeriodEnd, pauseAtPeriodEnd, skipIntervalCount)
- Metadata (for your internal tracking)
Update Effects:
- Amount changes apply to the next billing cycle
- Interval changes apply from the next period, leaving the current one to run out
- Setting prorate to true settles the price difference immediately instead, and an interval change then restarts the billing period from now
- nextPaymentAt moves the next charge date on its own, leaving the price alone. With prorate it also settles the time that moves: later charges for it, earlier refunds it
- Customer information updates take effect immediately
- Setting cancelAtPeriodEnd to true will end the subscription after the current period
- Setting pauseAtPeriodEnd to true will pause billing after the current period
- Setting skipIntervalCount skips billing for the specified number of intervals without changing subscription status
Switching price:
- A new priceId replaces amount, interval and intervalCount with the price's values. The price must be active and in the subscription's currency
- On a PENDING subscription the switch also replaces the trial with the price's trial
- The switch follows the same rules as a manual change: it applies from the next period, or settles at once with prorate
- Without priceId, changing amount, interval or intervalCount removes priceId and productId
Note: The currency cannot be changed once a subscription is created. To change it, cancel the subscription and create a new one.
put/subscriptions/{id}
Request
- Base URLhttps://api.monei.com/v1
- AuthAPI key in header Authorization
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Request body
Example request
{
"priceId": "3c5a1f8e-2b7d-4e9a-9c41-7d2e6b0f5a13",
"amount": 110,
"interval": "month",
"intervalCount": 1,
"allowedPaymentMethods": [
"card",
"bizum"
],
"description": "MoonMail Monthly Lite",
"customerId": "a4e1d1dd-e0c2-4f7a-a2b1-2b0f1f9b6b1e",
"customer": {
"email": "john.doe@example.com",
"name": "John Doe"
},
"billingDetails": {
"name": "John Doe",
"email": "john.doe@example.com",
"address": {
"country": "ES",
"city": "Málaga",
"line1": "Fake Street 123",
"zip": "1234",
"state": "Málaga"
}
},
"shippingDetails": {
"name": "John Doe",
"email": "john.doe@example.com",
"address": {
"country": "ES",
"city": "Málaga",
"line1": "Fake Street 123",
"zip": "1234",
"state": "Málaga"
}
},
"trialPeriodEnd": 1636366897,
"callbackUrl": "https://example.com/subscriptions/callback",
"paymentCallbackUrl": "https://example.com/payments/callback",
"pauseIntervalCount": 1,
"skipIntervalCount": 1,
"retrySchedule": [
{
"interval": "day",
"intervalCount": 1
},
{
"interval": "day",
"intervalCount": 3
},
{
"interval": "week",
"intervalCount": 1
}
],
"nextPaymentAt": 1636366897,
"metadata": {
"systemId": "12345"
}
}Response
A subscription object
Example response
{
"id": "575bcd84-09fc-4a6e-8c4c-f88b8eb90bfa",
"amount": 110,
"currency": "EUR",
"allowedPaymentMethods": [
"card",
"bizum"
],
"description": "MoonMail Monthly Lite",
"accountId": "aa9333ba-82de-400c-9ae7-087b9f8d2242",
"status": "PENDING",
"priceId": "3c5a1f8e-2b7d-4e9a-9c41-7d2e6b0f5a13",
"productId": "8f2c6d1a-4b3e-4f7a-9d2c-1e5b7a9c3f60",
"customerId": "a4e1d1dd-e0c2-4f7a-a2b1-2b0f1f9b6b1e",
"customer": {
"email": "john.doe@example.com",
"name": "John Doe"
},
"billingDetails": {
"name": "John Doe",
"email": "john.doe@example.com",
"address": {
"country": "ES",
"city": "Málaga",
"line1": "Fake Street 123",
"zip": "1234",
"state": "Málaga"
}
},
"shippingDetails": {
"name": "John Doe",
"email": "john.doe@example.com",
"address": {
"country": "ES",
"city": "Málaga",
"line1": "Fake Street 123",
"zip": "1234",
"state": "Málaga"
}
},
"interval": "month",
"intervalCount": 1,
"pauseIntervalCount": 1,
"skipIntervalCount": 1,
"lastOrderId": "14379133960355",
"lastPayment": {
"id": "af6029f80f5fc73a8ad2753eea0b1be0",
"status": "PENDING",
"statusCode": "E000",
"statusMessage": "Transaction approved"
},
"paymentMethod": {
"method": "card",
"card": {
"country": "ES",
"brand": "visa",
"type": "credit",
"threeDSecureVersion": "2.1.0",
"threeDSecureFlow": "CHALLENGE",
"expiration": 2048544000,
"last4": "0004",
"fingerprint": "7f2afde1566286c5fb126bb7e79bef549755cce6033dc429013c46d1365ff0e9",
"tokenizationMethod": "applePay",
"cardholderName": "John Doe",
"cardholderEmail": "email@example.com"
}
},
"currentPeriodStart": 1636366897,
"currentPeriodEnd": 1636366897,
"trialPeriodEnd": 1636366897,
"trialAmount": 100,
"trialIntervalCount": 3,
"nextPaymentAt": 1636366897,
"retryCount": 1,
"retrySchedule": [
{
"interval": "day",
"intervalCount": 1
},
{
"interval": "day",
"intervalCount": 3
},
{
"interval": "week",
"intervalCount": 1
}
],
"lastProrationAt": 1636366897,
"lastProration": {
"credit": 500,
"charge": 1200,
"net": 700,
"paymentId": "af6029f80f5fc73a8ad2753eea0b1be0"
},
"traceDetails": {
"ip": "100.100.200.100",
"countryCode": "ES",
"lang": "es",
"deviceType": "desktop",
"browser": "Chrome",
"browserVersion": "83.0.4103.116",
"os": "Mac OS",
"osVersion": "10.15.4",
"source": "MONEI/PHP",
"sourceVersion": "0.1.2",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) ...",
"browserAccept": "text/html,application/xhtml+xml,application/json",
"browserColorDepth": "24",
"browserScreenHeight": "1152",
"browserScreenWidth": "2048",
"browserTimezoneOffset": "-120",
"userEmail": "user@example.com"
},
"sequenceId": "62b23b9f3627cc38b08ff471ccd313ad",
"callbackUrl": "https://example.com/subscriptions/callback",
"paymentCallbackUrl": "https://example.com/payments/callback",
"metadata": {
"systemId": "12345"
},
"createdAt": 1636366897,
"updatedAt": 1636366897
}Changes
- info
added the new optional request property
- info
added the optional property
to the response with the status - info
added the optional property
to the response with the status
- info
- info
added the new optional request property
- info
added the optional property
to the response with the status - info
the
response's property pattern^[a-zA-Z0-9_@./#&+-]{1,40}$was added for the status
- info