Skip to main content

Create subscription

METHODURL
POST/subscriptions
EXAMPLEhttps://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 CODEDESCRIPTION
200The 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 CODEERROR CODEERROR MESSAGEDESCRIPTION
4000905Problem Parsing RequestThe request syntax is incorrect.
4000300Invalid RequestThe request body does not match the JSON schema.
4000301Missing or invalid field: %sMandatory or format field error.
4000313Invalid CountryThe provided country is not valid. The code has to comply with ISO 3166.
4000705Invalid Format ProvidedThe provided language is not valid. The code has to comply with ISO 639-1.
4000605Invalid IP AddressThe provided IP is not valid. The IP has to comply with the IPv4 protocol and be a public address.
4000203Duplicated SubscriptionThe provided purchase ID is already being used in another subscription or transaction with status pending or success.
5000900Internal Server ErrorThe server experienced an unexpected error.