Class: ZaiPayment::Resources::TokenAuth
- Inherits:
-
Object
- Object
- ZaiPayment::Resources::TokenAuth
- Defined in:
- lib/zai_payment/resources/token_auth.rb
Overview
TokenAuth resource for generating tokens for bank or card accounts
Constant Summary collapse
- TOKEN_TYPE_BANK =
Token types
'bank'- TOKEN_TYPE_CARD =
'card'- VALID_TOKEN_TYPES =
Valid token types
[TOKEN_TYPE_BANK, TOKEN_TYPE_CARD].freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#generate(user_id:, token_type: TOKEN_TYPE_BANK) ⇒ Response
Generate a token for bank or card account.
-
#initialize(client: nil) ⇒ TokenAuth
constructor
A new instance of TokenAuth.
Constructor Details
#initialize(client: nil) ⇒ TokenAuth
Returns a new instance of TokenAuth.
18 19 20 |
# File 'lib/zai_payment/resources/token_auth.rb', line 18 def initialize(client: nil) @client = client || Client.new(base_endpoint: :core_base) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/zai_payment/resources/token_auth.rb', line 9 def client @client end |
Instance Method Details
#generate(user_id:, token_type: TOKEN_TYPE_BANK) ⇒ Response
Generate a token for bank or card account
Create a token, either for a bank or a card account, that can be used with the PromisePay.js package to securely send Assembly credit card details.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/zai_payment/resources/token_auth.rb', line 47 def generate(user_id:, token_type: TOKEN_TYPE_BANK) validate_user_id!(user_id) validate_token_type!(token_type) body = { token_type: token_type, user_id: user_id } client.post('/token_auths', body: body) end |