Add/Update Abonnement


The following endpoint can be used to add or update a Abonnement within the Hyfin application. When a Abonnement 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 Abonnement on their device and it gets updated, a message will display letting the customer know the Abonnement has been updated and the new version of the Abonnement will automatically be displayed on the customers device.


Point de terminaison

The following endpoint can be used to add or update a Abonnement. 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/v4/site/{site_id}/subscription/addUpdate

Demande
Champ
Type
Description
id
String
L'identifiant de l'abonnement. Ce champ est généré automatiquement par le système et n'est pas requis lors de la création d'un nouvel abonnement, mais il est requis lors de la mise à jour d'un abonnement existant.
frequency
String
La fréquence de facturation.
One of `Daily`, `Weekly`, `Bi-Weekly`, `Semi-Monthly`, `Monthly`, `Quarterly`, `Semi-Annually`, `Yearly`
frequencyUnits
Number
Number of frequency units between installments. Ex: `frequency = Yearly` and `frequency_units = 2` means every 2 years.
customer
Une référence au dossier du client.
startDate
Date
La date de début de l'abonnement. Si laissée vide, elle sera définie lorsque le client confirme son mode de paiement. Format = YYYY-MM-DD
numberOfPayments
Number
Le nombre de versements à effectuer. Si laissé vide, l'abonnement se poursuit indéfiniment ou jusqu'à ce qu'il soit fermé manuellement.
webhookUrl
String
L'URL où envoyer les données lorsque certaines actions sont effectuées sur l'abonnement.
attachmentRefs
Une liste de pièces jointes.
billToCustomer
Le client à facturer, si différent du client.
billTo
Options de remplacement facultatives pour la section Destinataire de la facture. Si bill_to_customer est fourni, cet objet sera fusionné avec les informations du client et pourra être utilisé pour remplacer des champs spécifiques. Si bill_to_customer n'est pas fourni, les champs de cet objet seront utilisés comme informations de Destinataire sur la facture.
soldTo
Options facultatives pour la section Expédié à / Client de la facture.
deleted
Boolean
Ce drapeau représente si l'enregistrement est supprimé et n'est plus disponible pour être utilisé.
Sample Request
			
{
  "_id": "61f32dc2f62bdc6a48945067",
  "description": "Gold+ Plan",
  "amount": 34.99,
  "frequency": "Monthly",
  "frequency_units": 1,
  "customer": {
    "_id": "61f32dc2f62bdc6a48951255",
    "first_name": "John",
    "last_name": "Doe",
    "mobile_phone": "111-222-3333",
    "email": "johndoe@abc.com"
  },
  "webhook_url": "https://yourcompany.com/webhook"
}


		
Réponse
Champ
Type
Description
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"
  ]
}