Class: Inttegro::Resources::PaymentMethods
- Inherits:
-
Object
- Object
- Inttegro::Resources::PaymentMethods
- Defined in:
- lib/inttegro/resources/payment_methods.rb
Overview
Payment Methods resource for tokenizing and managing customer payment instruments.
Payment methods are saved payment instruments (mobile money wallets, cards, bank accounts) that customers can reuse across purchases. Use this resource to tokenize new payment methods, verify ownership, and manage the payment method lifecycle.
Instance Method Summary collapse
- #activate(payment_method_id:) ⇒ Object
- #archive(payment_method_id:) ⇒ Object
-
#confirm_verification(payload) ⇒ Inttegro::PaymentMethod
Submit the OTP received by the customer to complete payment method verification.
-
#delete(payment_method_id:, request_meta: nil) ⇒ Inttegro::PaymentMethodDeletion
Delete a saved payment method, removing it from the customer's account.
- #disactivate(payment_method_id:) ⇒ Object (also: #deactivate)
-
#initialize(http) ⇒ PaymentMethods
constructor
A new instance of PaymentMethods.
-
#lookup(payment_method_id:) ⇒ Inttegro::PaymentMethod
Retrieve details of a saved payment method by its ID.
- #page(payload = {}) ⇒ Object
-
#settings ⇒ Inttegro::PaymentMethodSettings
Get configuration settings for payment methods in your application.
-
#tokenize(payload) ⇒ Inttegro::PaymentMethod
Save a new payment method for a customer without charging it.
- #unarchive(payment_method_id:) ⇒ Object
- #update(payload) ⇒ Object
-
#verify(payment_method_id:, request_meta: nil) ⇒ Inttegro::PaymentMethodVerification
Send an OTP to confirm customer ownership of a payment method.
Constructor Details
#initialize(http) ⇒ PaymentMethods
Returns a new instance of PaymentMethods.
14 15 16 |
# File 'lib/inttegro/resources/payment_methods.rb', line 14 def initialize(http) @http = T.let(http, Inttegro::HTTPClient) end |
Instance Method Details
#activate(payment_method_id:) ⇒ Object
159 160 161 162 163 164 165 |
# File 'lib/inttegro/resources/payment_methods.rb', line 159 def activate(payment_method_id:) @http.post_resource( "/payment_methods/activate", Inttegro::PaymentMethod, :payment_method, { payment_method_id: payment_method_id } ) end |
#archive(payment_method_id:) ⇒ Object
177 178 179 180 181 182 183 |
# File 'lib/inttegro/resources/payment_methods.rb', line 177 def archive(payment_method_id:) @http.post_resource( "/payment_methods/archive", Inttegro::PaymentMethod, :payment_method, { payment_method_id: payment_method_id } ) end |
#confirm_verification(payload) ⇒ Inttegro::PaymentMethod
Submit the OTP received by the customer to complete payment method verification.
On success, the payment method's verified flag is set to true. Tokens expire after 8 minutes, and after 5 failed attempts, verification is locked—call verify() again to restart.
110 111 112 113 114 115 116 |
# File 'lib/inttegro/resources/payment_methods.rb', line 110 def confirm_verification(payload) @http.post_resource( "/payment_methods/confirm_verification", Inttegro::PaymentMethod, :payment_method, payload ) end |
#delete(payment_method_id:, request_meta: nil) ⇒ Inttegro::PaymentMethodDeletion
Delete a saved payment method, removing it from the customer's account.
Permanently deletes the payment method. This action cannot be undone. Use when a customer requests removal of their payment details or when a payment method is no longer valid.
211 212 213 214 215 216 217 218 |
# File 'lib/inttegro/resources/payment_methods.rb', line 211 def delete(payment_method_id:, request_meta: nil) @http.post_model("/payment_methods/delete", Inttegro::PaymentMethodDeletion, { payment_method_id: payment_method_id, request_meta: || ("delete", payment_method_id) } ) end |
#disactivate(payment_method_id:) ⇒ Object Also known as: deactivate
167 168 169 170 171 172 173 |
# File 'lib/inttegro/resources/payment_methods.rb', line 167 def disactivate(payment_method_id:) @http.post_resource( "/payment_methods/disactivate", Inttegro::PaymentMethod, :payment_method, { payment_method_id: payment_method_id } ) end |
#lookup(payment_method_id:) ⇒ Inttegro::PaymentMethod
Retrieve details of a saved payment method by its ID.
Returns full payment method information including type, verification status, and associated customer. Use this to display saved payment methods to customers or verify payment method status.
135 136 137 138 139 140 141 |
# File 'lib/inttegro/resources/payment_methods.rb', line 135 def lookup(payment_method_id:) @http.post_resource( "/payment_methods/lookup", Inttegro::PaymentMethod, :payment_method, { payment_method_id: payment_method_id } ) end |
#page(payload = {}) ⇒ Object
143 144 145 146 147 148 149 |
# File 'lib/inttegro/resources/payment_methods.rb', line 143 def page(payload = {}) @http.post_resource( "/payment_methods/page", Inttegro::PaymentMethodPage, :page, payload || {} ) end |
#settings ⇒ Inttegro::PaymentMethodSettings
Get configuration settings for payment methods in your application.
Returns settings that control payment method behavior, including whether verification is required before charging and supported payment method types.
233 234 235 236 237 238 239 |
# File 'lib/inttegro/resources/payment_methods.rb', line 233 def settings @http.post_resource( "/payment_methods/settings", Inttegro::PaymentMethodSettings, :settings, {} ) end |
#tokenize(payload) ⇒ Inttegro::PaymentMethod
Save a new payment method for a customer without charging it.
Tokenizes and stores payment details for future use. Currently supports mobile money wallets. Use this to collect payment details during customer onboarding, let customers save multiple payment instruments, or set up payment methods before subscription billing.
After tokenization, you can optionally verify the payment method to confirm customer ownership and enable frictionless charging.
50 51 52 53 54 55 56 |
# File 'lib/inttegro/resources/payment_methods.rb', line 50 def tokenize(payload) @http.post_resource( "/payment_methods/tokenize", Inttegro::PaymentMethod, :payment_method, payload ) end |
#unarchive(payment_method_id:) ⇒ Object
185 186 187 188 189 190 191 |
# File 'lib/inttegro/resources/payment_methods.rb', line 185 def unarchive(payment_method_id:) @http.post_resource( "/payment_methods/unarchive", Inttegro::PaymentMethod, :payment_method, { payment_method_id: payment_method_id } ) end |
#update(payload) ⇒ Object
151 152 153 154 155 156 157 |
# File 'lib/inttegro/resources/payment_methods.rb', line 151 def update(payload) @http.post_resource( "/payment_methods/update", Inttegro::PaymentMethod, :payment_method, payload ) end |
#verify(payment_method_id:, request_meta: nil) ⇒ Inttegro::PaymentMethodVerification
Send an OTP to confirm customer ownership of a payment method.
For mobile money, a 6-digit code is sent via SMS to the registered wallet number. The customer submits the token to complete verification. Verified payment methods can be charged without additional OTP confirmation, meet network provider requirements, and have better authorization rates.
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/inttegro/resources/payment_methods.rb', line 77 def verify(payment_method_id:, request_meta: nil) @http.post_resource( "/payment_methods/verify", Inttegro::PaymentMethodVerification, :verification, { payment_method_id: payment_method_id, request_meta: || ("verify", payment_method_id) } ) end |