Class: Airwallex::PaymentMethod

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List, APIOperations::Retrieve
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.

Note: raw card tokenization via .create requires PCI-scoped "Native API" account access, which isn't enabled by default — if your account isn't provisioned for it, collect cards via Airwallex's hosted checkout or Embedded Elements instead.

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: "john@example.com"
  }
)

Use saved payment method

payment_intent.confirm(payment_method_id: pm.id)

Update billing details

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

Disable a payment method

pm.disable

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 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 payment methods.

Returns:

  • (String)

    API resource path for payment methods



44
45
46
# File 'lib/airwallex/resources/payment_method.rb', line 44

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

Instance Method Details

#disable(params = {}) ⇒ PaymentMethod

Disable this payment method (Airwallex has no delete/detach endpoint; disabling is the real lifecycle operation and preserves history)

Parameters:

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

    additional params

Returns:



53
54
55
56
57
# File 'lib/airwallex/resources/payment_method.rb', line 53

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