Shell Python Node PHP C# Ruby

Charging a Customer

curl "https://api.payload.co/transactions" \
    -u secret_key_3bW9JMZtPVDOfFNzwRdfE: \
    -d "amount=100" \
    -d "type=payment" \
    -d "customer_id=acct_u7NDGPfjBc4uwChD"
customer = pl.Customer.get('acct_u7NDGPfjBc4uwChD')
customer.charge( amount=100 )
pl.Customer.get('acct_u7NDGPfjBc4uwChD')
    .then(function(customer) {
        return customer.charge({ amount: 100 })
    }).then(function(payment) {
    })

var customer = pl.Customer.get("acct_u7NDGPfjBc4uwChD");
customer.charge(new { amount=100 });
<?php
    $payment = Payload\Transaction::create(array(
        'amount'=>100.0,
        'type' => 'payment',
        'customer_id' => 'acct_u7NDGPfjBc4uwChD'
    ));
?>
payment = Payload::Payment.create(
    amount: 100.0,
    customer_id: 'acct_u7NDGPfjBc4uwChD'
)

Associating payments to a customer can be useful for managing payment options and tracking customer activity. A customer object can have a set default payment method along with an associated list of payment options that can be used when processing payments.

Setting a default payment method

To set a default payment method on a customer's account, add the default_payment_method flag when creating a payment method or update an existing method setting the default_payment_method flag set to true.

Charging a default payment method

To charge an existing customer using their default payment method, the API can accept a customer_id and amount without any payment method information. The API will attempt to run the payment using the customer's securely stored default payment details.

Charging a stored payment method

If there's no default payment method set for a customer, you can access their list of stored payment methods under the nested payment methods array (customer[payment_methods]) for a customer object and allow them to select their prefered method for the payment.

Paying with a new payment method

If the customer does not have a payment method stored or wishes to use a new payment method, by passing the customer's id to either the new payment method or transaction object in the API request, the new method will be associated with the customer.

Our UI Elements are integrated with the customer APIs, see below for more information:


For more information on managing customers, see the Customer Accounts section.