Class: Airwallex::PaymentConsent

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

Overview

Represents a Payment Consent — a saved card/payment method authorized for future off-session charges without re-prompting the customer.

Does NOT attach directly to a BillingSubscription — a subscription's payment_source_id references a PaymentSource (see Airwallex::PaymentSource), a separate Billing object created FROM a verified, merchant-initiated PaymentConsent. See PaymentSource's docstring for the full chain.

Examples:

Create and verify a consent for merchant-initiated (unscheduled) charges

# next_triggered_by/merchant_trigger_reason are required for the
# consent to later be usable to create a PaymentSource.
consent = Airwallex::PaymentConsent.create(
  customer_id: customer.id,
  payment_method: { type: "card", card: { ... } },
  next_triggered_by: "merchant",
  merchant_trigger_reason: "unscheduled"
)
consent.verify(payment_method: { card: { cvc: "123" } })

Disable a consent

consent.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 consents.

Returns:

  • (String)

    API resource path for payment consents



32
33
34
# File 'lib/airwallex/resources/payment_consent.rb', line 32

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

Instance Method Details

#disable(params = {}) ⇒ PaymentConsent

Disable this consent so it can no longer be charged

Parameters:

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

    additional params

Returns:



62
63
64
65
66
# File 'lib/airwallex/resources/payment_consent.rb', line 62

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

#verify(params = {}) ⇒ PaymentConsent

Verify this consent (e.g. via a zero/low-value authorization) before it can be used for off-session charges

Parameters:

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

    verification params (e.g. payment_method details)

Returns:



41
42
43
44
45
# File 'lib/airwallex/resources/payment_consent.rb', line 41

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

#verify_continue(params = {}) ⇒ PaymentConsent

Continue a verification that requires further customer action (e.g. completing 3DS)

Parameters:

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

    continuation params

Returns:



52
53
54
55
56
# File 'lib/airwallex/resources/payment_consent.rb', line 52

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