Add/Update Suscripción


The following endpoint can be used to add or update a Suscripción within the Hyfin application. When a Suscripción is added to Hyfin, a request will be automatically generated and the customer will be notified via text message, email or both based on the notification options set on the customer record. After submitting their payment method, the customer will automatically be charged based on the frequency of the recurring payment.

If the customer is viewing the Suscripción on their device and it gets updated, a message will display letting the customer know the Suscripción has been updated and the new version of the Suscripción will automatically be displayed on the customers device.


Punto Final

The following endpoint can be used to add or update a Suscripción. You must replace the {base_url} and {site_id} variable with the site id that was provided when the site was created.

POST
{base_url}/api/v3.1/site/{site_id}/subscription/addUpdate

Solicitud
Campo
Tipo
Descripción
external_id
String
El identificador de suscripción único del sistema/base de datos fuente. Si detectamos un registro con el mismo external_id, se actualizará; de lo contrario, se agregará.
description
String
Una breve descripción de los productos/servicios en la suscripción utilizada en la solicitud de pago mostrada al cliente.
amount
Number
El monto a cobrar por cada período de facturación. Format = 0.00
frequency
String
La frecuencia de facturación.
One of Daily, Weekly, Bi-Weekly, Semi-Monthly, Monthly, Quarterly, Semi-Annually, Yearly
frequency_units
Number
Número de unidades de frecuencia entre cuotas. Por ejemplo: frequency = Yearly y frequency_units = 2 significa cada 2 años.
customer
Una referencia al registro del cliente.
start_date
Date
La fecha de inicio de la suscripción. Si se deja en blanco, se establecerá cuando el cliente confirme su método de pago. Format = YYYY-MM-DD
number_of_payments
Number
El número de pagos a realizar. Si se deja en blanco, la suscripción continúa indefinidamente o hasta que se cierre manualmente.
active
Boolean
Si la suscripción está activa. Establecer en false cerrará de forma irreversible la suscripción si el cliente ya la ha aceptado.
Default = true
webhook_url
String
La URL a la que se enviará la publicación cuando se realicen ciertas acciones en la suscripción.
Sample Request
			
{
  "external_id": "439772921",
  "description": "Gold+ Plan",
  "amount": 34.99,
  "frequency": "Monthly",
  "frequency_units": 1,
  "customer": {
    "external_id": "39772634",
    "first_name": "John",
    "last_name": "Doe",
    "mobile_phone": "111-222-3333",
    "email": "johndoe@abc.com"
  },
  "webhook_url": "https://yourcompany.com/webhook"
}


		
Respuesta
Campo
Tipo
Descripción
success
Boolean
Whether the record was added or updated successfully.
action
String
Informs whether the record was added or updated. Will only be returned if success is true.
One of added, updated
_id
String
The auto generated id assigned to the record.
errors
String [ ]
A list of errors. Will only be returned if success is false.
Sample Response (Successful)
			
{
  "success": true,
  "action": "added",
  "_id": "60f720d248f143332af022e0"
}


		
Sample Response (Failed)
			
{
  "success": false,
  "errors": [
    "invalid field2",
    "missing field_name"
  ]
}