Search.../

addPayment( )

Adds a payment to the invoice and reports the payment to the payment provider.

Description

The addPayment() function returns a Promise that resolves when the specified payment is added to the invoice with the specified ID.

Syntax

function addPayment(id: IdAndVersion, payment: Payment): Promise<Response>

addPayment Parameters

NAME
TYPE
DESCRIPTION
id
IdAndVersion

ID and version of the invoice.

payment
Payment

The payment that should be added to the invoice.

Returns

Fulfilled - When the payment is added to the invoice.

Return Type:

Promise<Response>
NAME
TYPE
DESCRIPTION
id
IdAndVersion

ID and version information.

Was this helpful?

Add a payment to an invoice

Copy Code
1import {invoices} from 'wix-billing-backend';
2
3export function addPayment(id, version, type, amount) {
4 const idAndVersion = {
5 "id": id,
6 "version": version
7 };
8
9 const payment = {
10 "type": type,
11 "amount": amount,
12 "date": Date.now()
13 };
14
15 return invoices.addPayment(idAndVersion, payment);
16}
17
18/* Promise resolves to:
19 * {
20 * {
21 * "id": {
22 * "id": "1ed3a515-24f9-4039-8937-2e69b6a2f33a",
23 * "version": 31
24 * }
25 * }
26 * }
27*/
Get the invoice version and add a payment to an invoice

Copy Code
1import {invoices} from 'wix-billing-backend';
2
3export function addPayment(id, payment) {
4 return invoices.getInvoice(id)
5 .then( (result) => {
6 return invoices.addPayment(result.id, payment);
7 });
8}
9
10/* Promise resolves to:
11 * {
12 * {
13 * "id": {
14 * "id": "1ed3a515-24f9-4039-8937-2e69b6a2f33a",
15 * "version": 31
16 * }
17 * }
18 * }
19*/