Create Payments

The Payment object holds all of the information about a payment, including the payment amount and to which billing documents the payment is applied.

The following code sample creates a payment to the invoice created for your customer account, Amy Lawrence (account_id=2c92c0f96abc17de016abd62bd0c5854), using the payment method (payment_method_id=8f64d4d7b1b989f6c571d931f84e0458) associated with this account.

cURLJavaNode
Copy
Copied
curl -X POST "https://rest.sandbox.na.zuora.com/v2/payments"
-H "Authorization: Bearer 6d151216ef504f65b8ff6e9e9e8356d3" 
-H "Content-Type: application/json" 
-d '{ 
	"account_id": "2c92c0f96abc17de016abd62bd0c5854",
    "billing_documents": [{
		"id": "8ad093f27f54fa8d017f6b191ff02543",
		"amount": 50,
		"type": "invoice"
    }],
    "amount": 50,
    "currency": "USD",
    "payment_date": "2022-03-08",
    "payment_method_id": "8f64d4d7b1b989f6c571d931f84e0458",
    "external": true
}'
Copy
Copied
LocalDate date = LocalDate.of(2022,3,8);

BillingDocumentApplicationRequest invoiceApplicationRequest = new BillingDocumentApplicationRequest()
    .amount(new BigDecimal(30))
    .type(BillingDocumentApplicationRequest.TypeEnum.INVOICE)
    .id("8ad093f27f54fa8d017f6b191ff02543");

PaymentCreateRequest paymentCreateRequest = new PaymentCreateRequest()
    .accountId("2c92c0f96abc17de016abd62bd0c5854")
    .amount(new BigDecimal(50))
    .paymentDate(date)
    .paymentMethodId("8f64d4d7b1b989f6c571d931f84e0458")
    .external(true)
    .currency("USD")
    .billingDocuments(Collections.singletonList(invoiceApplicationRequest));

Payment newPayment = zuoraClient.payments().createPayment(paymentCreateRequest);
Copy
Copied
const invoiceApplicationRequest = {
    amount: 30,
    type: 'invoice',
    id: '8ad093f27f54fa8d017f6b191ff02543',
};
 
const paymentCreateRequest = {
    account_id: '2c92c0f96abc17de016abd62bd0c5854',
    amount: 50,
    payment_date: '2022-03-08',
    payment_method_id: '8f64d4d7b1b989f6c571d931f84e0458',
    external: true,
    currency: 'USD',
    billing_documents: [invoiceApplicationRequest]
};
 
const newPayment = await zuoraClient.payments.createPayment(paymentCreateRequest);