Adds a payment to the invoice and reports the payment to the payment provider.
The addPayment()
function returns a Promise that resolves
when the specified payment is added to the invoice with the specified ID.
function addPayment(id: IdAndVersion, payment: Payment): Promise<Response>;
ID and version of the invoice.
The payment that should be added to the invoice.
import { Permissions, webMethod } from "wix-web-module";
import { invoices } from "wix-billing-backend";
export const addPayment = webMethod(
Permissions.Anyone,
(id, version, type, amount) => {
const idAndVersion = {
id: id,
version: version,
};
const payment = {
type: type,
amount: amount,
date: Date.now(),
};
return invoices.addPayment(idAndVersion, payment);
},
);
/* Promise resolves to:
* {
* {
* "id": {
* "id": "1ed3a515-24f9-4039-8937-2e69b6a2f33a",
* "version": 31
* }
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.