Class: Airwallex::PaymentSource

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

Overview

Represents a Billing Payment Source — the object a BillingSubscription's payment_source_id actually references. NOT the same object as PaymentConsent (/pa/payment_consents).

external_id is the id of a PaymentMethod (/pa/payment_methods), not a PaymentConsent's own id. The PaymentConsent is still part of the flow — it's what authorizes that PaymentMethod for merchant-initiated (unscheduled) charges — but the id PaymentSource wants is the underlying PaymentMethod's.

Examples:

Full flow: PaymentMethod -> PaymentConsent -> PaymentSource -> BillingSubscription

payment_method = Airwallex::PaymentMethod.create(
  customer_id: customer.id,
  type: "card",
  card: { ... } # a real test card in sandbox
)

consent = Airwallex::PaymentConsent.create(
  customer_id: customer.id,
  payment_method: { id: payment_method.id },
  next_triggered_by: "merchant",
  merchant_trigger_reason: "unscheduled"
)
consent.verify(...)

source = Airwallex::PaymentSource.create(
  billing_customer_id: billing_customer.id,
  external_id: payment_method.id,
  linked_payment_account_id: connected_account.id
)

Airwallex::BillingSubscription.create(
  billing_customer_id: billing_customer.id,
  legal_entity_id: connected_account.legal_entity_id,
  collection_method: "AUTO_CHARGE",
  payment_source_id: source.id,
  items: [{ price_id: price.id, quantity: 1 }]
)

Instance Attribute Summary

Attributes inherited from APIResource

#attributes, #id

Class Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::Retrieve

retrieve

Methods included from APIOperations::List

list

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 billing payment sources.

Returns:

  • (String)

    API resource path for billing payment sources



48
49
50
# File 'lib/airwallex/resources/payment_source.rb', line 48

def self.resource_path
  "/api/v1/billing/payment_sources"
end