Skip to main content
Version: 0.8

Customers

Customer management is an optional capability: providers implement CustomerProvider only when their API supports it. PayPal does not (its Orders API has no customer object), so those calls return payment.ErrUnsupported for PayPal. See Stripe, PayPal, and Razorpay for the full picture.

customer, err := client.CreateCustomer(ctx, payment.NewCustomerRequest("jane@example.com").
WithName("Jane Doe").
WithPhone("+1-555-0100").
WithMetadata("account_id", "acct_42"))

CustomerRequest.Validate() requires a non-empty Email.

Retrieving, updating, and deleting

customer, err := client.GetCustomer(ctx, customerID)

customer, err = client.UpdateCustomer(ctx, customerID, payment.NewCustomerRequest("jane@example.com").
WithName("Jane D."))

err = client.DeleteCustomer(ctx, customerID)

An empty ID returns payment.ErrNotFound without a network call.

Customer fields

ID, Email, Name, Phone, Description, DefaultPaymentMethodID, Metadata, CreatedAt, Provider, and Raw (the unmodified provider response, for anything not normalized).

Next steps