Subscriptions: Create
Request
POST https://api.univapay.com/subscriptions
Parameters:
| Parameters | |
| transaction_token_id | string (UUID) [Required] Id of the Transaction Token use. Must be either a subscription or recurring type transaction token. |
| amount | number [Required] Amount to charge |
| currency | string (ISO-4217) [Required] Currency code in ISO-4217. |
| initial_amount | number Initial amount to charge, if different from the recurring amount |
| period | string Frequency at which the subscription is charged. One of daily, weekly, biweekly, monthly, quarterly, semiannually, annually. If this field is populated, cyclical_period cannot be populated |
| cyclical_period | string (ISO-8601 Duration) Frequency at which the subscription is charged, expressed as an ISO-8601 duration, with a minimum frequency of 1 day and a minimum interval of 1 day. If this field is populated, period cannot be populated |
| schedule_settings.start_on | string (ISO-8601) The date in which all subsequent payments should start on in Year-Month-Day format. Time is fixed to 9am of the timezone declared in zone_id |
| schedule_settings.zone_id | string (IANA Timezone) The timezone the subscription will be charged at |
| schedule_settings.preserve_end_of_month | boolean If the period is monthly and the start_on date provided is the last day of the month, this option allows the charge to follow the end of the month. E.g. If start_on is 2018-06-30, then the next charge is 2018-07-31 if true and 2018-07-30 if false |
| schedule_settings.termination_mode | string One of immediate, on_next_paymentDefault is immediate if unspecified.When the value is immediate, the subscription will suspend or terminate immediately, whereas for on_next_payment, it will only suspend or terminate right before the next payment. |
| installment_plan.plan_type | string One of revolving, fixed_cycles |
| installment_plan.fixed_cycles | number If installment_plan.plan_type is fixed_cycles, then this field is required. Specifies the number of cycles, in the installment |
| subscription_plan.plan_type | string One of fixed_cycles, fixed_cycle_amount |
| subscription_plan.fixed_cycles | number If subscription_plan.plan_type is fixed_cycles, then this field is required. Specifies the number of cycles, in the subscription plan |
| subscription_plan.fixed_cycle_amount | number If subscription_plan.plan_type is fixed_cycle_amount, then this field is required. Specifies the amount per cycle, in the subscription plan |
| schedule_settings.retry_interval | string (ISO-8601 Duration) Specifies the interval between retries when subscription payment fails. ex) P5D: Retry every 5 days after failure *Interval must be at least 1 day and must be shorter than the subscription cycle. |
| metadata | json Metadata associated with the subscription. |
| three_ds.redirect_endpoint | string (URL) The redirect endpoint when the client is returns from 3DS authentication. If not set, the user will be shown a generic completion page and asked to return manually to the originating website. Note: This only affects the first payment of the subscription |
| three_ds.mode | string The 3DS authentication mode for the charge. One of normal, required, force, skip. Note: This only affects the first payment of the subscription |
Headers:
Content-Type: application/jsonAuthorization: Bearer {secret}.{jwt}
Body:
curl --request POST \
--url https://api.univapay.com/subscriptions \
--header 'Authorization: Bearer {secret}.{jwt}' \
--header 'content-type: application/json' \
--data '{
"transaction_token_id": "a6025e32-18e3-11e7-8fc4-17c907a37445",
"amount": 1250,
"currency": "USD",
"period": "daily",
"metadata":{
"ServiceId": 78435694
}
}'
Response
Code: 201
Headers:
Content-Type: application/json
Body:
{
"id": "aaadee6a-18e3-11e7-a461-e3b078a7dc52",
"store_id": "37ff5664-18c6-11e7-8221-ff4914d76afc",
"amount": 1250,
"currency": "USD",
"amount_formatted": 12.5,
"period": "daily",
"status": "unverified",
"metadata": {
"ServiceId": 78435694
},
"mode": "test",
"created_on": 1491275175825
}