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

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