Subscription Management
Subscription Management
This section is related to operations related to subscription management such as getting the status of subscription or cancelling a subscription.
Get Subscription
To get user’s subscription, you need first to get a user access token using 1 of the following options. Note: Same way mentioned in ‘Prepare Purchase’ and ‘Login Flow’ sections
CURL example
curl --location --request POST 'https://gateway.mondiapay.com/v1/api/oauth/token?grant_type=authorization_code&client_id=12345&client_secret=12345&code=A12345&redirect_uri=https://www.google.com' \
--header 'Accept: application/json' \
--header 'Content-Type: application/x-www-form-urlencoded'
Response Example
{
" access_token ": " U12345 "
" token_type ": " bearer "
" expires_in ": " 43200 "
" refresh_token ": " R12345 "
}
You can also get the user access token from the UUID received with the notification:
CURL example
curl --location --request POST 'https://gateway.mondiapay.com/v1/api/oauth/token' \
--header 'accept: application/json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=user_credentials' \
--data-urlencode 'client_id=12345' \
--data-urlencode 'client_secret=12345' \
--data-urlencode 'uuid=12345' \
Response Example
{
" access_token ": " U12345 "
" token_type ": " bearer "
" expires_in ": " 43200 "
" refresh_token ": " R12345 "
}
After that, please pass the generated user access token in the following API to get the subscription details:
CURL example
curl --location --request GET 'https://gateway.mondiapay.com/v1/api/subscription?subscriptionTypeId=12345' \
--header 'Authorization: Bearer U12345'
Response Example
{
" typeId ": " 12345 "
" startDate ": " 2021-01-16T19:45:01Z "
" id ": " 12345 "
" created ": " 2021-01-16T19:45:01Z "
" lastModified ": " 2021-01-16T19:45:01Z "
" attributes ": " [] "
" state ": " ACTIVE "
" subState ": " NONE "
}
Cancel Subscription
To cancel user’s subscription
CURL example
curl --location --request DELETE 'https://gateway.mondiapay.com/v1/api/subscription/12345?immediately=true' \
--header 'Authorization: Bearer U12345'
Response Example
{
" Status ": " 204 NO CONTENT "
}