> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slm.m1amdocs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AutoBill.makePayment

The `makePayment` method allows you to record a payment against an outstanding invoice. This method may be used to enter check or cash payments, payment of goods in trade, or payments made with active Payment Methods.

Using the `makePayment` method on the `AutoBill` object will cause Subscribe to allocate the payment directly to the selected `AutoBill`. To apply a payment against the oldest outstanding Invoice, use `Account.makePayment` instead.

Whether you use a standard `PaymentMethod`, or a `MerchantAcceptedPayment`, the `makePayment` method generates a `Transaction`, and processes the `Transaction` through the `auth /capture` cycle appropriate to the input Payment Method. Credit Card, ECP, PayPal, and other standard Payment Methods are routed through the appropriate Payment Processor. The `MerchantAcceptedPayment` Payment Method is routed through Vindicia’s internal transaction process. Both Payment Method types appear as a `Transaction` in the Account’s history.

**Note:** When using a `MerchantAcceptedPayment`, you must create a new `PaymentMethod` object for each `makePayment` call.

## Input

*srd*: sparse response description, a SOAP string (which must be a JSON object), in which you specify the elements you want returned.This parameter enables the calling system to constrain a `method` call to return only components you specify. This gives you greater control over returned content, and improves response time within the Vindicia platform by reducing the processing needed for the call.

Some fields are required, either practically or in the WSDL, and will be returned regardless of the *srd*. A null *srd* returns the complete response.

*autobill*: the `AutoBill` to which this payment applies.

*paymentMethod*: the `PaymentMethod` to be used for this payment. This `paymentMethod` can be of type `MerchantAcceptedPayment`, credit card, or PayPal. If you use PayPal, the PayPal payment method must be already populated with a Billing Agreement ID (BAID), acquired either from an earlier AutoBill creation or from a one-time transaction conducted for the customer's account, in which a PayPal reference ID was requested. You can not use an PayPal payment method that requires customer approval at the PayPal site in this call

**Note:**

* Assign a unique ID for every `Account.makePayment` call that uses the `MerchantAcceptedPayment` Payment Method, for tracking purposes.
* `PaymentMethods` may not be duplicated for an `Account`. Passing in an existing credit card number and expiration date in an attempt to create a new `PaymentMethods` for an `Account` will return the pre-existing `PaymentMethods` instead.

*amount*: the amount of the payment being made.

*currency*: the ISO 4217 currency code for `amount`. This must match the currency used for charges on the current invoice. (If not specified, the AutoBill/Invoice currency will be used.)

*invoiceId*: the ID of the Invoice against which the payment is to be made. If not specified, the oldest unpaid invoice for this AutoBill will be selected for payment. To make a payment against an invoice in `Open` status, an ID must be specified—Subscribe will not direct overage against such a future invoice.

*overageDisposition*: an object of type *PaymentOverageDisposition*, defines how to allocate payments in excess of a required AutoBill payment amount. Enumerated values include:

* `applyToOldestInvoice` (the default)
* `applyToThisAutoBill`
* `applyToCredit`

*note*: an optional memo regarding the payment made.

**Note:** Do not change the established currency type.

## Output

*return*: an object of type `Return` that indicates the success or failure of the call.

*transaction*: the `Transaction` object generated by the payment attempt. This `Transaction` must be inspected to assess the details of the payment attempt.

*summary*: an object of type `TransactionAttemptSummary`, which describes the payment attempt: `Success`, `Failure`, or `Pending`.

## Returns

In addition to those listed in [The Return Object](The_Return_Object), this call returns:

| Return Code | Return String |
| - | - |
| *400* | One of the following: - `Account not found.` - `Failed to translate payment method: *error-description*.` - `Failed to make payment: *error-description*.` - `Transaction not returned from payment attempt.` - `This Credit Card already exists—Policy Violation" (eradicate the newly created but failed one or ensure it is set INACTIVE).` You receive this error message when you have the Credit\_Card\_Constraints merchant option enabled on your site. This message means that someone is attempting to use a credit card that is already being used as the payment method on an existing account. This is not allowed. |

## Example

```

$autobill = new AutoBill();
$autobill->set($abID); // for some $abID

$paymentMethod = new PaymentMethod();
$paymentMethod->setMerchantPaymentMethodId($pmId); // for some $pmId

$response = $autobill->makePayment(
   $paymentMethod,
   4.50,
   'USD',
   'inv-bac',
   null,
   '$4.50 for Scrabble'
);
// check $response
```

**Parent topic:**[AutoBill Methods](../topics/AutoBill_Methods)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.