Add/Update Payment


The following endpoint can be used to add or update a payment within the Hyfin application that were already processed.


Endpoint

The following endpoint can be used to add or update a payment. 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}/payment/addUpdate

Request
Field
Type
Description
id
String
The id of the payment. This field is auto generated by the system and is not required when creating a new payment, but it is required when updating an existing payment.
displayName
String
The secure friendly display name of the payment method. Example: `VISA **** 3421`.
amount
Number
The amount in cents that was paid.
paidOn
Date
The date and time of when the payment was made. Format = YYYY-MM-DDTHH:mm:ssZ
invoice
A reference to the invoice record.
status
String
The current status of the payment.
Default = `captured` | One of `declined`, `authorized`, `captured`, `voided`, `settled`, `returned`, `refundFailed`, `refunded`, `refundSettled`
site
String
The _id of the site
type
String
The type of payment method used to make the payment.
One of `payment_card`, `ach`, `cash`, `check`
subType
String
The sub type of the payment method used to make the payment.
One of `checking`, `savings`, `visa`, `mastercard`, `discover`, `amex`, `cash`, `other`
totals
The total amounts of the payment.
allocations
The allocations for the payment. This is an array of objects that specify how the payment was allocated to different orders or refunds.
deleted
Boolean
This flag represents whether the record is deleted and no longer available to be used.
Sample Request
			
{
  "_id": "61f32dc2f62bdc6a48945067",
  "gateway_transaction_id": "53912387124235234",
  "payment_type": "payment_card",
  "payment_sub_type": "visa",
  "display_name": "VISA **** 5123",
  "amount": 35.15,
  "paid_on": "2021-01-01T14:32:18Z",
  "status": "captured",
  "invoice": {
    "_id": "61f32dc2f62bdc6a48951255"
  }
}


		
Response
Field
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"
  ]
}