Class: Airwallex::Beneficiary

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

Overview

Examples:

Create a beneficiary

# nickname/payer_entity_type/transfer_methods are top-level siblings of
# `beneficiary`, not nested inside it. request_id is optional (the
# gem's Idempotency middleware injects one automatically). Call
# .api_schema / .form_schema for the exact required fields per
# entity_type + bank_country_code.
beneficiary = Airwallex::Beneficiary.create(
  nickname: "Acme Corp",
  payer_entity_type: "COMPANY",
  transfer_methods: ["LOCAL"],
  beneficiary: {
    entity_type: "COMPANY",
    company_name: "Acme Corp",
    address: {
      country_code: "AU",
      city: "Melbourne",
      state: "VIC",
      postcode: "3000",
      street_address: "15 William Street"
    },
    bank_details: {
      account_name: "Acme Corp",
      account_number: "12750852",
      account_currency: "AUD",
      bank_country_code: "AU",
      bank_name: "National Australia Bank",
      account_routing_type1: "bsb",
      account_routing_value1: "083064",
      local_clearing_system: "BANK_TRANSFER" # country-specific enum
    }
  }
)

Update a beneficiary

# .update doesn't support a partial patch — resend the full payload
# with your change merged in.
beneficiary.update(
  transfer_methods: ["LOCAL"],
  beneficiary: {
    entity_type: "COMPANY",
    company_name: "Acme Corp Ltd",
    bank_details: { account_currency: "AUD", bank_country_code: "AU", ... }
  }
)

Constant Summary collapse

API_SCHEMA_PATH =
"/api/v1/beneficiary_api_schemas/generate"
FORM_SCHEMA_PATH =
"/api/v1/beneficiary_form_schemas/generate"
SUPPORTED_FINANCIAL_INSTITUTIONS_PATH =
"/api/v1/beneficiary_form_schemas/supported_financial_institutions"

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

.api_schema(params = {}) ⇒ Hash

Retrieve the API schema (field validation rules) for beneficiary bank details, keyed by beneficiary type / entity type / bank country.

Parameters:

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

    e.g. beneficiary_type:, bank_country_code:

Returns:

  • (Hash)

    raw schema response



86
87
88
# File 'lib/airwallex/resources/beneficiary.rb', line 86

def self.api_schema(params = {})
  Airwallex.client.post(API_SCHEMA_PATH, params)
end

.form_schema(params = {}) ⇒ Hash

Retrieve the dynamic form schema used to render beneficiary bank-detail forms in the UI, keyed by beneficiary type / entity type / bank country.

Parameters:

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

    e.g. beneficiary_type:, bank_country_code:

Returns:

  • (Hash)

    raw schema response



95
96
97
# File 'lib/airwallex/resources/beneficiary.rb', line 95

def self.form_schema(params = {})
  Airwallex.client.post(FORM_SCHEMA_PATH, params)
end

.resource_pathObject



59
60
61
# File 'lib/airwallex/resources/beneficiary.rb', line 59

def self.resource_path
  "/api/v1/beneficiaries"
end

.supported_financial_institutions(params = {}) ⇒ Hash

Search financial institutions supported for a given country, currency, entity type, and transfer method, by name keyword.

Parameters:

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

    required: bank_country_code:, account_currency:, entity_type:, transfer_method:, keyword: (a bank-name search term, min 3 chars)

Returns:

  • (Hash)

    raw response listing supported institutions



106
107
108
# File 'lib/airwallex/resources/beneficiary.rb', line 106

def self.supported_financial_institutions(params = {})
  Airwallex.client.get(SUPPORTED_FINANCIAL_INSTITUTIONS_PATH, params)
end

.validate(params = {}) ⇒ Hash

Validate beneficiary details (address, bank details, entity type, transfer method) before attempting to create the beneficiary.

Parameters:

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

    the same shape of params you'd pass to .create

Returns:

  • (Hash)

    raw validation result



68
69
70
# File 'lib/airwallex/resources/beneficiary.rb', line 68

def self.validate(params = {})
  Airwallex.client.post("#{resource_path}/validate", params)
end

.verify_account(params = {}) ⇒ Hash

Verify ownership of a beneficiary's bank account via Confirmation of Payee (CoP) before creation.

Parameters:

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

    beneficiary bank account details to verify

Returns:

  • (Hash)

    raw verification result (status, account_name_match_result)



77
78
79
# File 'lib/airwallex/resources/beneficiary.rb', line 77

def self.(params = {})
  Airwallex.client.post("#{resource_path}/verify_account", params)
end