Payments
Payments are used to represent a customer payment. Payments encompass payments processed through Invoiced, cash receipts (like wire transfers and check), application of credit note and spending credit balances.
It is not required for payments to be associated with a customer or be fully applied, although the goal is to eventually apply the payment in full. The balance on payments represents the amount that is unapplied. Payments can only be associated with a single customer at a time. A payment without an associated customer means that the payment came from a data source where the customer that originated the payment is not yet known.
Payment Object
Attributes
{
"ach_sender_id": null,
"amount": 39,
"balance": 39,
"charge": null,
"created_at": 1586880432,
"currency": "usd",
"customer": null,
"date": 1586880431,
"id": 61,
"matched": true,
"method": "other",
"notes": null,
"object": "payment",
"pdf_url": "https://dundermifflin.invoiced.com/payments/59FHO96idoXFeiBDu1y5Zggg/pdf",
"reference": null,
"source": "bank_feed",
"updated_at": 1607152637,
"voided": false
}
Parameter | Type | Description |
---|---|---|
id | integer | The payment's unique ID |
object | string | Object type, payment |
customer | integer | Associated Customer, if any |
date | timestamp | Payment date |
currency | string | 3-letter ISO code |
amount | number | Payment amount |
balance | number | Unapplied amount remaining |
matched | boolean | When true there is a CashMatch suggestion |
voided | boolean | Indicates that the payment was voided |
method | string | Payment instrument used |
ach_sender_id | string | ACH PPD ID |
reference | string | Reference number, i.e. check # |
source | string | Source of the payment |
notes | string | Internal notes |
charge | object | Charge object included for processed payments |
applied_to | array | List of Payment Applications |
pdf_url | string | URL where receipt PDF can be downloaded |
created_at | timestamp | Timestamp when created |
updated_at | timestamp | Timestamp when updated |
Payment Application
A payment application describes how a payment is applied. Payments can have multiple applications as long as the applied amounts do not exceed the payment amount.
These types of payment applications are supported:
- Invoice (
type=invoice
) - Estimate deposit (
type=estimate
) - Credit note (
type=credit_note
) - Convenience fee (
type=convenience_fee
) - Add to credit balance (
type=credit
) - Apply credit balance (
type=applied_credit
)
Parameter | Type | Description |
---|---|---|
amount | number | Amount to apply |
type | string | One of applied_credit , convenience_fee , credit , credit_note , estimate , or invoice |
invoice | integer | Invoice ID, required when type=invoice |
estimate | integer | Estimate ID, required when type=estimate |
credit_note | integer | Credit Note ID, required when type=credit_note |
document_type | string | One of estimate or invoice , used with type=credit_note or type=applied_credit |
Payment Methods
These are commonly used payment methods for the method
attribute. You should use the payment method ID when dealing with the API.
ID | Description |
---|---|
ach |
ACH |
cash |
Cash |
check |
Check |
credit_card |
Credit Card |
eft |
EFT |
direct_debit |
Direct Debit |
other |
Other |
paypal |
PayPal |
wire_transfer |
Wire Transfer |
Create a payment
curl "https://api.invoiced.com/payments" \
-u {API_KEY}: \
-d amount=800 \
-d method="check" \
-d reference="1450" \
-d applied_to[0][type]="invoice" \
-d applied_to[0][amount]=800 \
-d applied_to[0][invoice]=44648
invoiced.Payment.create(
:amount => 800,
:method => "check",
:reference => "1450",
:applied_to => [{
:type => "invoice",
:invoice => 44648,
:amount => 800
}]
)
<?php
$invoiced->Payment->create([
'amount' => 800,
'method' => "check",
'reference' => "1450",
'applied_to' => [[
'type' => 'invoice',
'invoice' => 44648,
'amount' => 800,
]]
]);
client.Payment.create(
amount=800,
method="check",
reference="1450",
applied_to=[{
'type': 'invoice',
'invoice': 44648,
'amount': 800
}]
)
Payment payment = invoiced.newPayment();
payment.amount = 800D;
payment.method = "check";
payment.reference = "1450";
paymentItem = new PaymentItem();
paymentItem.type = "invoice";
paymentItem.invoice = 44648L;
paymentItem.amount = 800D;
payment.appliedTo = PaymentItem{paymentItem};
payment.create();
var payment = invoiced.NewPayment();
payment.Amount = 800;
payment.Method = "check";
payment.Reference = "1450";
payment.Invoice = 44648;
payment.Create();
payment, err := client.Payment.Create(&invoiced.PaymentRequest{
Amount: invoiced.Float64(800),
Method: invoiced.String("check"),
Reference: invoiced.String("1450"),
AppliedTo: []*invoiced.PaymentItemRequest{
{
Type: invoiced.String("invoice"),
Amount: invoiced.Float64(800),
Invoice: invoiced.Int64(44648),
},
},
})
The above command returns JSON structured like this:
{
"ach_sender_id": null,
"amount": 39,
"balance": 39,
"charge": null,
"created_at": 1586880432,
"currency": "usd",
"customer": null,
"date": 1586880431,
"id": 61,
"matched": true,
"method": "other",
"notes": null,
"object": "payment",
"pdf_url": "https://dundermifflin.invoiced.com/payments/59FHO96idoXFeiBDu1y5Zggg/pdf",
"reference": null,
"source": "bank_feed",
"updated_at": 1607152637,
"voided": false
}
Create a new payment with this endpoint.
HTTP Request
POST /payments
Attributes
Parameter | Type | Description |
---|---|---|
customer | integer | Customer ID, optional |
date | timestamp | Payment date, defaults to current timestamp |
method | string | Payment instrument used, defaults to other |
currency | string | 3-letter ISO code |
amount | number | Payment amount |
reference | string | Reference number, i.e. check # |
ach_sender_id | string | Originator ID (ACH payments) |
source | string | Source of the payment, defualts to keyed |
notes | string | Internal notes |
applied_to | array | List of Payment Applications |
Retrieve a payment
curl "https://api.invoiced.com/payments/:id" \
-u {API_KEY}:
payment = invoiced.Payment.retrieve("{PAYMENT_ID}")
<?php
$payment = $invoiced->Payment->retrieve("{PAYMENT_ID}");
payment = client.Payment.retrieve("{PAYMENT_ID}")
Payment payment = invoiced.newPayment().retrieve({PAYMENT_ID});
var payment = invoiced.NewPayment().Retrieve({PAYMENT_ID});
payment, err := client.Payment.Retrieve({PAYMENT_ID})
The above command returns JSON structured like this:
{
"ach_sender_id": null,
"amount": 39,
"balance": 39,
"charge": null,
"created_at": 1586880432,
"currency": "usd",
"customer": null,
"date": 1586880431,
"id": 61,
"matched": true,
"method": "other",
"notes": null,
"object": "payment",
"pdf_url": "https://dundermifflin.invoiced.com/payments/59FHO96idoXFeiBDu1y5Zggg/pdf",
"reference": null,
"source": "bank_feed",
"updated_at": 1607152637,
"voided": false
}
This endpoint retrieves a specific payment. If you want to see how the payment is applied then you must add ?include=applied_to
to the request.
HTTP Request
GET /payments/:id
If you set the Accept
header to application/pdf
then the receipt PDF will be returned.
Update a payment
curl "https://api.invoiced.com/payments/:id" \
-u {API_KEY}: \
-d notes="Check was received by Jan" \
-X PATCH
payment.notes = "Check was received by Jan"
payment.save
<?php
$payment->notes = "Check was received by Jan";
$payment->save();
payment.notes = "Check was received by Jan"
payment.save()
payment.notes = "Check was received by Jan";
payment.save();
payment.Notes = "Check was received by Jan";
payment.SaveAll();
payment, err := client.Payment.Update(&invoiced.PaymentRequest{
Notes: invoiced.String("Check was received by Jan"),
})
The above command returns JSON structured like this:
{
"ach_sender_id": null,
"amount": 39,
"balance": 39,
"charge": null,
"created_at": 1586880432,
"currency": "usd",
"customer": null,
"date": 1586880431,
"id": 20939,
"matched": true,
"method": "check",
"notes": "Check was received by Jan",
"object": "payment",
"pdf_url": "https://dundermifflin.invoiced.com/payments/59FHO96idoXFeiBDu1y5Zggg/pdf",
"reference": "1234",
"source": "keyed",
"updated_at": 1607152637,
"voided": false
}
Use this endpoint to update a payment.
HTTP Request
PATCH /payments/:id
Request Parameters
Parameter | Type | Description |
---|---|---|
customer | integer | Customer ID, optional |
date | timestamp | Payment date, defaults to current timestamp |
method | string | Payment instrument used, defaults to other |
currency | string | 3-letter ISO code |
amount | number | Payment amount |
reference | string | Reference number, i.e. check # |
ach_sender_id | string | Originator ID (ACH payments) |
source | string | Source of the payment, defualts to keyed |
notes | string | Internal notes |
applied_to | array | Payment application |
Send a receipt
curl "https://api.invoiced.com/payments/:id/emails" \
-u {API_KEY}: \
-X POST
emails = payment.send
<?php
$emails = $payment->send();
emails = payment.send()
EmailRequest emailRequest = new EmailRequest();
EmailRecipient[] emailRecipients = new EmailRecipient[1];
emailRecipients[0] = new EmailRecipient();
emailRecipients[0].name = "Client";
emailRecipients[0].email = "client@example.com";
emailRequest.to = emailRecipients;
emailRequest.subject = "Receipt for your recent payment to Dunder Mifflin, Inc.";
emailRequest.message = "Dear Client, we have attached a receipt for your most recent payment. Thank you!";
Email[] emails = payment.send(emailRequest);
var emailRequest = new EmailRequest();
var emailRecipients = new EmailRecipient[1];
emailRecipients[0] = new EmailRecipient();
emailRecipients[0].Name = "Client";
emailRecipients[0].Email = "client@example.com";
emailRequest.To = emailRecipients;
emailRequest.Subject = "Receipt for your recent payment to Dunder Mifflin, Inc.";
emailRequest.Message = "Dear Client, we have attached a receipt for your most recent payment. Thank you!";
var emails = payment.SendEmail(emailRequest);
err := client.Payment.SendReceipt({PAYMENT_ID}, &invoiced.SendEmailRequest{
To: []*invoiced.EmailRecipient{
Name: invoiced.String("Client"),
Email: "client@example.com",
},
Subject: invoiced.String("Receipt for your recent payment to Dunder Mifflin, Inc."),
Message: invoiced.String("Dear Client, we have attached a receipt for your most recent payment. Thank you!"),
})
The above command returns JSON structured like this:
[
{
"created_at": 1436890047,
"email": "client@example.com",
"id": "f45382c6fbc44d44aa7f9a55eb2ce731",
"message": "Dear Client, we have attached a receipt for your most recent payment. Thank you!",
"object": "email",
"opens": 0,
"opens_detail": [],
"reject_reason": null,
"state": "sent",
"subject": "Receipt for your recent payment to Dunder Mifflin, Inc.",
"template": "payment_receipt_email",
"updated_at": 1436890047
}
]
This endpoint sends a PDF receipt to the customer.
HTTP Request
POST /payments/:id/emails
Request Parameters
Parameter | Type | Description |
---|---|---|
to | array | Optional array of recipients like:[{"name": "Client", "email": "client@example.com"}] |
bcc | string | Optional comma-separated list of email addresses to be blind carbon copied |
template | string | Optional email template ID, otherwise a standard email template is selected |
subject | string | Optional subject to override the template |
message | string | Optional message body to override the template |
Void a payment
curl "https://api.invoiced.com/payments/:id" \
-u {API_KEY}: \
-X DELETE
payment.delete
<?php
$payment->delete();
payment.delete()
payment.voidPayment();
payment.Delete();
err := client.Payment.Delete({PAYMENT_ID})
The above command returns JSON structured like this:
{
"ach_sender_id": null,
"amount": 39,
"balance": 39,
"charge": null,
"created_at": 1586880432,
"currency": "usd",
"customer": null,
"date": 1586880431,
"id": 61,
"matched": true,
"method": "other",
"notes": null,
"object": "payment",
"pdf_url": "https://dundermifflin.invoiced.com/payments/59FHO96idoXFeiBDu1y5Zggg/pdf",
"reference": null,
"source": "bank_feed",
"updated_at": 1607152637,
"voided": true
}
This endpoint voids a specific payment.
HTTP Request
DELETE /payments/:id
List all payments
curl "https://api.invoiced.com/payments" \
-u {API_KEY}:
payments, metadata = invoiced.Payment.list(:per_page => 3)
<?php
list($payments, $metadata) = $invoiced->Payment->all(['per_page' => 3]);
payments, metadata = client.Payment.list(per_page=3)
EntityList<Payment> payments = invoiced.newPayment().listAll();
var payments = invoiced.NewPayment().ListAll();
payments, err := client.Payment.ListAll(nil, nil)
The above command returns JSON structured like this:
[
{
"ach_sender_id": null,
"amount": 39,
"balance": 39,
"charge": null,
"created_at": 1586880432,
"currency": "usd",
"customer": null,
"date": 1586880431,
"id": 61,
"matched": true,
"method": "other",
"notes": null,
"object": "payment",
"pdf_url": "https://dundermifflin.invoiced.com/payments/59FHO96idoXFeiBDu1y5Zggg/pdf",
"reference": null,
"source": "bank_feed",
"updated_at": 1607152637,
"voided": false
}
]
This endpoint retrieves all payments.
HTTP Request
GET /payments
Query Parameters
Parameter | Description |
---|---|
sort string | Column to sort by, i.e. name asc |
filter object | Filter object |
start_date timestamp | Restricts the results to payments on or after the given timestamp |
end_date timestamp | Restricts the results to payments on or before the given timestamp |
updated_after timestamp | Only gets records updated after the given timestamp |