Create subscription
METHOD | URL |
---|---|
POST | /subscriptions |
EXAMPLE | https://test.api.macropay.com/v2/subscriptions |
The call to the subscriptions API call has a similar body, response and authentication as the create order.
These are the differences:
Body Differences
- money object: It does not have to be sent because it is defined in the plan
- currency: New field. Mandatory. This field allows multicurrency for a plan. Currency in which you want the recurrences to be charged.
- generateToken: It does not have to be sent because it will be always generated
- notificationUrl: It does not have to be sent because it is replaced by
eventSubscriptionUrl
- parentTransactionId: It does not have to be sent because Revup is going to generate the rebills
- paymentDetails object: It does not have to be sent because it is not necessary
- planId: New field. It must be sent. This is the ID from the previously created Plan in the BO. UUID format
- eventSubscriptionUrl: New field. It must be sent. This is the URL where Merchant will receive subscription events
- overwrite.initialAmount: New field. Optional. If present, the initial subscription amount will be overwritten by the specified amount.
Response Differences
- subscriptionId: New field. This is the ID from the new subscription created. UUID format
REQUEST BODY EXAMPLE - CREATE NEW SUBSCRIPTION
{
"planId": "4aa7c1e4-cf8c-4d1c-a6ad-451dd07411ee",
"currency": "EUR",
"eventSubscriptionUrl": "https://2ec7-54-73-197-22.ngrok-free.app/events",
"description": "New subscription from merchant",
"concept": "Order concept",
"redirectUrl": {
"success": "www.merchant-domain.es/success",
"fail": "www.merchant-domain.es/failed",
"threeDSChallengeResult": "www.merchant-domain/challenge"
},
"userInformation": {
"ip": "84.102.122.9",
"email": "user@test.com",
"country": "ES",
"language": "ES",
"customerId": "12345678901234567890",
"browserInformation": {
"userAgentHeader": "Mozilla/5.0",
"acceptHeader": "text/html",
"fingerprint": "4sd54dfsafgsadf5"
}
},
"overwrite": {
"initialAmount": 111.99
},
"domain": "https://www.merchant-domain.es"
}
SUCCESS RESPONSES - CREATE SUBSCRIPTION
HTTP CODE | DESCRIPTION |
---|---|
200 | The orderId and subscriptionId are provided in the body in JSON format. |
SUCCESS RESPONSE EXAMPLE - CREATE SUBSCRIPTION
{
"orderId": "2989ce95-4309-4f24-a81a-f8dc27c9f20d",
"subscriptionId": "0192b445-55a7-74af-a5d1-79ca6d2310f4"
}
ERROR RESPONSES - CREATE SUBSCRIPTION
HTTP CODE | ERROR CODE | ERROR MESSAGE | DESCRIPTION |
---|---|---|---|
400 | 0905 | Problem Parsing Request | The request syntax is incorrect. |
400 | 0300 | Invalid Request | The request body does not match the JSON schema. |
400 | 0301 | Missing or invalid field: %s | Mandatory or format field error. |
400 | 0313 | Invalid Country | The provided country is not valid. The code has to comply with ISO 3166. |
400 | 0705 | Invalid Format Provided | The provided language is not valid. The code has to comply with ISO 639-1. |
400 | 0605 | Invalid IP Address | The provided IP is not valid. The IP has to comply with the IPv4 protocol and be a public address. |
400 | 0203 | Duplicated Subscription | The provided purchase ID is already being used in another subscription or transaction with status pending or success. |
500 | 0900 | Internal Server Error | The server experienced an unexpected error. |