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 )
const customer = await pl.Customer.get('acct_u7NDGPfjBc4uwChD')
const payment = await customer.charge({ amount: 100 })
var customer = await pl.Customer.GetAsync("acct_u7NDGPfjBc4uwChD");
await customer.ChargeAsync(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.
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
.
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.
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.
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.