Class: Airwallex::Customer

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::Delete, APIOperations::List, APIOperations::Retrieve
Includes:
APIOperations::Update
Defined in:
lib/airwallex/resources/customer.rb

Overview

Represents a customer for organizing payment methods and transactions

Customers allow you to group payment methods and track payment history for individual users or accounts.

Examples:

Create a customer

# merchant_customer_id is required — your own reference id for this
# customer. request_id is optional (the gem's Idempotency middleware
# injects one automatically).
customer = Airwallex::Customer.create(
  merchant_customer_id: SecureRandom.uuid,
  email: "john@example.com",
  first_name: "John",
  last_name: "Doe",
  phone_number: "+1 1234567890"
)

List payment methods for a customer

methods = Airwallex::PaymentMethod.list(customer_id: customer.id)

Instance Attribute Summary

Attributes inherited from APIResource

#attributes, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::Retrieve

retrieve

Methods included from APIOperations::List

list

Methods included from APIOperations::Delete

delete

Methods included from APIOperations::Update

included, #save, #update

Methods inherited from APIResource

#changed_attributes, #dirty?, #initialize, #inspect, #method_missing, #refresh, #refresh_from, resource_name, #respond_to_missing?, #to_hash, #to_json, #to_s

Constructor Details

This class inherits a constructor from Airwallex::APIResource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Airwallex::APIResource

Class Method Details

.resource_pathString

Returns API resource path for customers.

Returns:

  • (String)

    API resource path for customers



31
32
33
# File 'lib/airwallex/resources/customer.rb', line 31

def self.resource_path
  "/api/v1/pa/customers"
end

Instance Method Details

#payment_methods(params = {}) ⇒ ListObject<PaymentMethod>

List payment methods for this customer

Parameters:

  • params (Hash) (defaults to: {})

    additional parameters

Returns:



39
40
41
# File 'lib/airwallex/resources/customer.rb', line 39

def payment_methods(params = {})
  PaymentMethod.list(params.merge(customer_id: id))
end