Class: Airwallex::PaymentMethod

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

Overview

Represents a payment method (card, bank account, etc.) that can be reused

Payment methods allow you to store customer payment credentials securely and reuse them for future payments without collecting details again.

Examples:

Create a card payment method

pm = Airwallex::PaymentMethod.create(
  type: "card",
  card: {
    number: "4242424242424242",
    expiry_month: "12",
    expiry_year: "2025",
    cvc: "123"
  },
  billing: {
    first_name: "John",
    email: "[email protected]"
  }
)

Use saved payment method

payment_intent.confirm(payment_method_id: pm.id)

Update billing details

pm.update(billing: { address: { postal_code: "10001" } })

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::Update

included, save, update

Methods included from APIOperations::Delete

delete

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



38
39
40
# File 'lib/airwallex/resources/payment_method.rb', line 38

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

Instance Method Details

#detachPaymentMethod

Detach this payment method from its customer



45
46
47
48
49
# File 'lib/airwallex/resources/payment_method.rb', line 45

def detach
  response = Airwallex.client.post("#{self.class.resource_path}/#{id}/detach", {})
  refresh_from(response)
  self
end