inttegro.async_resources.payment_methods
Generated public typing surface. Do not edit by hand.
1# Generated by scripts/generate_async_resources.py; do not edit by hand. 2"""Payment methods resource for tokenizing and managing payment instruments.""" 3from __future__ import annotations 4from ..async_http_client import AsyncHttpClient 5from inttegro.payment_method.update_request import UpdateRequest 6 7def _stable_payment_method_request_meta(action: str, payment_method_id: str) -> dict: 8 return {'idempotency_key': f'payment_methods_{action}_{payment_method_id}'} 9 10class AsyncPaymentMethods: 11 """ 12 Payment methods resource for securely storing and managing payment instruments. 13 14 Payment methods represent saved payment instruments (mobile money accounts, bank 15 cards, etc.) that customers can reuse for faster checkout. Tokenization converts 16 sensitive payment details into a secure token that you can safely store and charge 17 repeatedly without handling raw payment credentials. 18 19 The typical flow is: 20 1. Tokenize payment details to create a payment method 21 2. Verify the payment method (triggers OTP for mobile money) 22 3. Confirm verification with OTP 23 4. Use the payment method ID for future charges 24 25 See https://studio.inttegro.com/charge-repeat-customers for detailed guides. 26 """ 27 28 def __init__(self, http: AsyncHttpClient): 29 """Initialize PaymentMethods resource with HTTP client.""" 30 self.http = http 31 32 async def tokenize(self, payload: dict): 33 """ 34 Create a tokenized payment method from payment details. 35 36 Tokenization securely stores payment credentials (mobile money number, bank card, 37 etc.) and returns a reusable token. The token (payment method ID) can be used for 38 future charges without requiring the customer to re-enter payment details. 39 40 Mobile money payment methods require verification before use. After tokenization, 41 you must verify the payment method to confirm customer ownership. 42 43 Args: 44 payload: Tokenization parameters including: 45 - customer_id: Customer to attach payment method to (required) 46 - payment_method_data: Payment details (required): 47 - type: Payment type ("mobile_money") (required) 48 - mobile_money: Mobile money details (required if type is "mobile_money"): 49 - network: Network ("mtn", "vodafone", "airteltigo") (required) 50 - account_number: Phone number (required) 51 - verify_immediately: Send verification OTP immediately (default: false) 52 53 Returns: 54 domain object containing: 55 - payment_method: Created payment method with id, type, and status 56 - requires_verification: Whether verification is needed before use (typically true) 57 58 Raises: 59 ApiError: If parameters are invalid or customer doesn't exist 60 61 Example: 62 ```python 63 # Tokenize MTN mobile money 64 result = client.payment_methods.tokenize({ 65 "customer_id": "cu_abc123", 66 "payment_method_data": { 67 "type": "mobile_money", 68 "mobile_money": { 69 "network": "mtn", 70 "account_number": "0241234567" 71 } 72 } 73 }) 74 75 pm = result 76 print(f"Payment method created: {pm['id']}") 77 78 # Verify if needed 79 if result.verified_at is None: 80 print("Verification required before use") 81 client.payment_methods.verify(pm['id']) 82 83 # Tokenize with immediate verification 84 result = client.payment_methods.tokenize({ 85 "customer_id": "cu_abc123", 86 "payment_method_data": { 87 "type": "mobile_money", 88 "mobile_money": { 89 "network": "vodafone", 90 "account_number": "0501234567" 91 } 92 }, 93 "verify_immediately": True 94 }) 95 96 # OTP is sent immediately, prompt customer 97 if result.verified_at is None: 98 otp = input("Enter OTP: ") 99 client.payment_methods.confirm_verification({ 100 "payment_method_id": result.id, 101 "token": otp 102 }) 103 ``` 104 105 Security Note: 106 Never log or store raw payment credentials (phone numbers, card numbers). 107 Only store the returned payment_method_id token. 108 109 See Also: 110 - verify(): Initiate verification after tokenization 111 - confirm_verification(): Complete verification with OTP 112 - https://studio.inttegro.com/charge-repeat-customers 113 """ 114 return await self.http.post('/payment_methods/tokenize', payload) 115 116 async def verify(self, payment_method_id: str, request_meta: dict | None=None): 117 """ 118 Initiate verification for a payment method. 119 120 Verification confirms that the customer owns the payment instrument. For mobile 121 money, this sends an OTP to the phone number. The customer must submit this OTP 122 via confirm_verification() before the payment method can be used for charges. 123 124 Only unverified payment methods need verification. Once verified, the payment 125 method can be used indefinitely. 126 127 Args: 128 payment_method_id: The payment method ID to verify (e.g., "pm_xyz789") 129 request_meta: Request controls such as idempotency_key 130 131 Returns: 132 domain object containing: 133 - payment_method: Updated payment method with verification status 134 - message: Confirmation that OTP was sent 135 136 Raises: 137 ApiError: If payment method doesn't exist or is already verified 138 139 Example: 140 ```python 141 # Tokenize payment method 142 result = client.payment_methods.tokenize({ 143 "customer_id": "cu_abc123", 144 "payment_method_data": { 145 "type": "mobile_money", 146 "mobile_money": { 147 "network": "mtn", 148 "account_number": "0241234567" 149 } 150 } 151 }) 152 153 pm_id = result.id 154 155 # Initiate verification 156 if result.verified_at is None: 157 verify_result = client.payment_methods.verify(pm_id) 158 print("OTP sent to customer's phone") 159 160 # Prompt customer for OTP 161 otp = input("Enter OTP: ") 162 163 # Confirm verification 164 client.payment_methods.confirm_verification({ 165 "payment_method_id": pm_id, 166 "token": otp 167 }) 168 ``` 169 170 See Also: 171 - confirm_verification(): Submit OTP to complete verification 172 - tokenize(): Create payment method that may need verification 173 - https://studio.inttegro.com/charge-repeat-customers 174 """ 175 return await self.http.post('/payment_methods/verify', {'payment_method_id': payment_method_id, 'request_meta': request_meta or _stable_payment_method_request_meta('verify', payment_method_id)}) 176 177 async def confirm_verification(self, payload: dict): 178 """ 179 Submit OTP to complete payment method verification. 180 181 After calling verify(), the customer receives an OTP on their mobile device. 182 Collect this OTP from the customer and submit it via this method to complete 183 verification. Once verified, the payment method can be used for charges. 184 185 Args: 186 payload: Verification parameters including: 187 - payment_method_id: The payment method being verified (required) 188 - token: The OTP code from customer (required, 6 digits) 189 190 Returns: 191 domain object containing: 192 - payment_method: Verified payment method ready for use 193 - status: Verification status 194 195 Raises: 196 ApiError: If OTP is invalid, expired, or verification fails 197 198 Example: 199 ```python 200 # Step 1: Tokenize 201 tokenize_result = client.payment_methods.tokenize({ 202 "customer_id": "cu_abc123", 203 "payment_method_data": { 204 "type": "mobile_money", 205 "mobile_money": { 206 "network": "mtn", 207 "account_number": "0241234567" 208 } 209 } 210 }) 211 212 pm_id = tokenize_result.id 213 214 # Step 2: Initiate verification 215 if tokenize_result.verified_at is None: 216 client.payment_methods.verify(pm_id) 217 print("OTP sent. Check your phone.") 218 219 # Step 3: Collect OTP from customer 220 otp = input("Enter the 6-digit code: ") 221 222 # Step 4: Confirm verification 223 result = client.payment_methods.confirm_verification({ 224 "payment_method_id": pm_id, 225 "token": otp 226 }) 227 228 if result.verified: 229 print("Payment method verified! Ready to use.") 230 231 # Now you can charge it 232 client.orders.pay({ 233 "order_id": "or_abc123", 234 "payment_method_id": pm_id 235 }) 236 ``` 237 238 See Also: 239 - verify(): Initiate verification and send OTP 240 - tokenize(): Create payment method 241 - https://studio.inttegro.com/charge-repeat-customers 242 """ 243 return await self.http.post('/payment_methods/confirm_verification', payload) 244 245 async def lookup(self, payment_method_id: str): 246 """ 247 Retrieve details of a saved payment method. 248 249 Fetches information about a payment method including its type, verification status, 250 and masked details (last 4 digits for cards, masked phone number for mobile money). 251 Use this to display saved payment methods to customers or verify their status. 252 253 Args: 254 payment_method_id: The payment method ID (e.g., "pm_xyz789") 255 256 Returns: 257 domain object containing: 258 - payment_method: Payment method details including: 259 - id: Payment method ID 260 - type: Payment type ("mobile_money", "card", etc.) 261 - verified: Whether verification is complete 262 - confirms_use: Whether OTP is required before charges 263 - masked_details: Safely displayable payment info 264 - customer_id: Associated customer 265 - created_at: Creation timestamp 266 267 Raises: 268 ApiError: If payment method doesn't exist 269 270 Example: 271 ```python 272 # Look up payment method 273 result = client.payment_methods.lookup("pm_xyz789") 274 pm = result 275 276 print(f"Type: {pm['type']}") 277 print(f"Verified: {pm['verified']}") 278 print(f"Details: {pm['masked_details']}") # e.g., "MTN •••• 4567" 279 280 # Display saved payment methods to customer 281 order = client.orders.lookup("or_abc123") 282 customer_id = order.customer.id 283 284 # Get customer's payment methods (from your database) 285 pm_ids = get_customer_payment_methods(customer_id) 286 287 print("Saved payment methods:") 288 for pm_id in pm_ids: 289 result = client.payment_methods.lookup(pm_id) 290 pm = result 291 print(f" - {pm['masked_details']}") 292 ``` 293 294 See Also: 295 - tokenize(): Create a payment method 296 - delete(): Remove a payment method 297 - https://studio.inttegro.com/api/payment-methods/lookup 298 """ 299 return await self.http.post('/payment_methods/lookup', {'payment_method_id': payment_method_id}) 300 301 async def page(self, payload: dict | None=None): 302 """ 303 List payment methods with optional pagination and customer filtering. 304 305 Args: 306 payload: Optional page_number, page_size, and customer_id filters. 307 308 Returns: 309 domain object containing a page of payment methods. 310 """ 311 return await self.http.post('/payment_methods/page', payload or {}) 312 313 async def update(self, payload: UpdateRequest): 314 """ 315 Update mutable payment method fields. 316 317 Args: 318 payload: Update parameters including payment_method_id. 319 320 Returns: 321 domain object containing the updated payment method. 322 """ 323 return await self.http.post('/payment_methods/update', payload) 324 325 async def activate(self, payment_method_id: str): 326 """Mark a payment method active. 327 328 API endpoint: ``/payment_methods/activate``. 329 330 Args: 331 payment_method_id (str): Unique identifier of the payment method. 332 333 Returns: 334 ``PaymentMethod`` decoded from the documented response shape. 335 336 Raises: 337 APIError: The API rejected the request or could not complete it. 338 NetworkError: The request could not reach the Inttegro API. 339 TimeoutError: The configured request deadline elapsed. 340 """ 341 return await self.http.post('/payment_methods/activate', {'payment_method_id': payment_method_id}) 342 343 async def disactivate(self, payment_method_id: str): 344 """Mark a payment method inactive. 345 346 API endpoint: ``/payment_methods/disactivate``. 347 348 Args: 349 payment_method_id (str): Unique identifier of the payment method. 350 351 Returns: 352 ``PaymentMethod`` decoded from the documented response shape. 353 354 Raises: 355 APIError: The API rejected the request or could not complete it. 356 NetworkError: The request could not reach the Inttegro API. 357 TimeoutError: The configured request deadline elapsed. 358 """ 359 return await self.http.post('/payment_methods/disactivate', {'payment_method_id': payment_method_id}) 360 361 async def deactivate(self, payment_method_id: str): 362 """Alias for disactivate(). 363 364 Args: 365 payment_method_id (str): Unique identifier of the payment method. 366 367 Returns: 368 ``PaymentMethod`` decoded from the documented response shape. 369 """ 370 return await self.disactivate(payment_method_id) 371 372 async def archive(self, payment_method_id: str): 373 """Archive a payment method. 374 375 API endpoint: ``/payment_methods/archive``. 376 377 Args: 378 payment_method_id (str): Unique identifier of the payment method. 379 380 Returns: 381 ``PaymentMethod`` decoded from the documented response shape. 382 383 Raises: 384 APIError: The API rejected the request or could not complete it. 385 NetworkError: The request could not reach the Inttegro API. 386 TimeoutError: The configured request deadline elapsed. 387 """ 388 return await self.http.post('/payment_methods/archive', {'payment_method_id': payment_method_id}) 389 390 async def unarchive(self, payment_method_id: str): 391 """Unarchive a payment method. 392 393 API endpoint: ``/payment_methods/unarchive``. 394 395 Args: 396 payment_method_id (str): Unique identifier of the payment method. 397 398 Returns: 399 ``PaymentMethod`` decoded from the documented response shape. 400 401 Raises: 402 APIError: The API rejected the request or could not complete it. 403 NetworkError: The request could not reach the Inttegro API. 404 TimeoutError: The configured request deadline elapsed. 405 """ 406 return await self.http.post('/payment_methods/unarchive', {'payment_method_id': payment_method_id}) 407 408 async def delete(self, payment_method_id: str, request_meta: dict | None=None): 409 """ 410 Delete a saved payment method. 411 412 Permanently removes a payment method from the system. This action cannot be undone. 413 The payment method ID becomes invalid and cannot be used for future charges. 414 Use this when customers want to remove saved payment methods. 415 416 Args: 417 payment_method_id: The payment method ID to delete (e.g., "pm_xyz789") 418 request_meta: Request controls such as idempotency_key 419 420 Returns: 421 domain object confirming deletion: 422 - deleted: True if deletion succeeded 423 - payment_method_id: ID of deleted payment method 424 425 Raises: 426 ApiError: If payment method doesn't exist or deletion fails 427 428 Example: 429 ```python 430 # Delete a payment method 431 result = client.payment_methods.delete("pm_xyz789") 432 print(f"Payment method deleted: {result.payment_method_id}") 433 434 # Customer removes saved card flow 435 def remove_payment_method(customer_id, pm_id): 436 # Verify customer owns this payment method 437 pm_result = client.payment_methods.lookup(pm_id) 438 pm = pm_result 439 440 if pm["customer_id"] != customer_id: 441 raise ValueError("Payment method doesn't belong to customer") 442 443 # Delete it 444 result = client.payment_methods.delete(pm_id) 445 446 # Remove from your database 447 delete_from_database(pm_id) 448 449 return result.deleted 450 451 # Cleanup unused payment methods 452 for pm_id in old_payment_methods: 453 try: 454 client.payment_methods.delete(pm_id) 455 print(f"Deleted {pm_id}") 456 except Exception as e: 457 print(f"Failed to delete {pm_id}: {e}") 458 ``` 459 460 Security Note: 461 Ensure you verify customer ownership before allowing deletion of 462 payment methods to prevent unauthorized removal. 463 464 See Also: 465 - tokenize(): Create payment methods 466 - lookup(): View payment method details 467 - https://studio.inttegro.com/api/payment-methods/delete 468 """ 469 return await self.http.post('/payment_methods/delete', {'payment_method_id': payment_method_id, 'request_meta': request_meta or _stable_payment_method_request_meta('delete', payment_method_id)}) 470 471 async def settings(self): 472 """ 473 Retrieve payment method configuration and supported types. 474 475 Gets your application's payment method settings including enabled payment types, 476 supported networks, OTP requirements, and other configuration. Use this to 477 dynamically build payment forms based on what's enabled for your account. 478 479 Returns: 480 domain object containing: 481 - settings: Payment configuration including: 482 - enabled_types: List of enabled payment types 483 - mobile_money: Mobile money configuration: 484 - issuers: Supported networks ("mtn", "vodafone", "airteltigo") 485 - default_confirms_use: Default OTP requirement 486 - cards: Card payment configuration (if enabled) 487 - other type-specific settings 488 489 Example: 490 ```python 491 # Get payment settings 492 result = client.payment_methods.settings() 493 settings = result 494 495 # Check what's enabled 496 enabled_types = settings["enabled_types"] 497 print(f"Enabled payment types: {enabled_types}") 498 499 # Build mobile money form based on supported networks 500 if "mobile_money" in enabled_types: 501 mm_config = settings["mobile_money"] 502 print(f"Supported networks: {mm_config['issuers']}") 503 print(f"Default OTP: {mm_config['default_confirms_use']}") 504 505 # Dynamic payment form 506 def build_payment_form(): 507 result = client.payment_methods.settings() 508 settings = result 509 510 form = {"payment_types": []} 511 512 if "mobile_money" in settings["enabled_types"]: 513 form["payment_types"].append({ 514 "type": "mobile_money", 515 "issuers": settings["mobile_money"]["issuers"] 516 }) 517 518 if "card" in settings["enabled_types"]: 519 form["payment_types"].append({ 520 "type": "card", 521 "brands": settings["card"]["supported_brands"] 522 }) 523 524 return form 525 ``` 526 527 See Also: 528 - tokenize(): Create payment methods based on settings 529 - https://studio.inttegro.com/api/payment-methods/settings 530 """ 531 return await self.http.post('/payment_methods/settings', {})
11class AsyncPaymentMethods: 12 """ 13 Payment methods resource for securely storing and managing payment instruments. 14 15 Payment methods represent saved payment instruments (mobile money accounts, bank 16 cards, etc.) that customers can reuse for faster checkout. Tokenization converts 17 sensitive payment details into a secure token that you can safely store and charge 18 repeatedly without handling raw payment credentials. 19 20 The typical flow is: 21 1. Tokenize payment details to create a payment method 22 2. Verify the payment method (triggers OTP for mobile money) 23 3. Confirm verification with OTP 24 4. Use the payment method ID for future charges 25 26 See https://studio.inttegro.com/charge-repeat-customers for detailed guides. 27 """ 28 29 def __init__(self, http: AsyncHttpClient): 30 """Initialize PaymentMethods resource with HTTP client.""" 31 self.http = http 32 33 async def tokenize(self, payload: dict): 34 """ 35 Create a tokenized payment method from payment details. 36 37 Tokenization securely stores payment credentials (mobile money number, bank card, 38 etc.) and returns a reusable token. The token (payment method ID) can be used for 39 future charges without requiring the customer to re-enter payment details. 40 41 Mobile money payment methods require verification before use. After tokenization, 42 you must verify the payment method to confirm customer ownership. 43 44 Args: 45 payload: Tokenization parameters including: 46 - customer_id: Customer to attach payment method to (required) 47 - payment_method_data: Payment details (required): 48 - type: Payment type ("mobile_money") (required) 49 - mobile_money: Mobile money details (required if type is "mobile_money"): 50 - network: Network ("mtn", "vodafone", "airteltigo") (required) 51 - account_number: Phone number (required) 52 - verify_immediately: Send verification OTP immediately (default: false) 53 54 Returns: 55 domain object containing: 56 - payment_method: Created payment method with id, type, and status 57 - requires_verification: Whether verification is needed before use (typically true) 58 59 Raises: 60 ApiError: If parameters are invalid or customer doesn't exist 61 62 Example: 63 ```python 64 # Tokenize MTN mobile money 65 result = client.payment_methods.tokenize({ 66 "customer_id": "cu_abc123", 67 "payment_method_data": { 68 "type": "mobile_money", 69 "mobile_money": { 70 "network": "mtn", 71 "account_number": "0241234567" 72 } 73 } 74 }) 75 76 pm = result 77 print(f"Payment method created: {pm['id']}") 78 79 # Verify if needed 80 if result.verified_at is None: 81 print("Verification required before use") 82 client.payment_methods.verify(pm['id']) 83 84 # Tokenize with immediate verification 85 result = client.payment_methods.tokenize({ 86 "customer_id": "cu_abc123", 87 "payment_method_data": { 88 "type": "mobile_money", 89 "mobile_money": { 90 "network": "vodafone", 91 "account_number": "0501234567" 92 } 93 }, 94 "verify_immediately": True 95 }) 96 97 # OTP is sent immediately, prompt customer 98 if result.verified_at is None: 99 otp = input("Enter OTP: ") 100 client.payment_methods.confirm_verification({ 101 "payment_method_id": result.id, 102 "token": otp 103 }) 104 ``` 105 106 Security Note: 107 Never log or store raw payment credentials (phone numbers, card numbers). 108 Only store the returned payment_method_id token. 109 110 See Also: 111 - verify(): Initiate verification after tokenization 112 - confirm_verification(): Complete verification with OTP 113 - https://studio.inttegro.com/charge-repeat-customers 114 """ 115 return await self.http.post('/payment_methods/tokenize', payload) 116 117 async def verify(self, payment_method_id: str, request_meta: dict | None=None): 118 """ 119 Initiate verification for a payment method. 120 121 Verification confirms that the customer owns the payment instrument. For mobile 122 money, this sends an OTP to the phone number. The customer must submit this OTP 123 via confirm_verification() before the payment method can be used for charges. 124 125 Only unverified payment methods need verification. Once verified, the payment 126 method can be used indefinitely. 127 128 Args: 129 payment_method_id: The payment method ID to verify (e.g., "pm_xyz789") 130 request_meta: Request controls such as idempotency_key 131 132 Returns: 133 domain object containing: 134 - payment_method: Updated payment method with verification status 135 - message: Confirmation that OTP was sent 136 137 Raises: 138 ApiError: If payment method doesn't exist or is already verified 139 140 Example: 141 ```python 142 # Tokenize payment method 143 result = client.payment_methods.tokenize({ 144 "customer_id": "cu_abc123", 145 "payment_method_data": { 146 "type": "mobile_money", 147 "mobile_money": { 148 "network": "mtn", 149 "account_number": "0241234567" 150 } 151 } 152 }) 153 154 pm_id = result.id 155 156 # Initiate verification 157 if result.verified_at is None: 158 verify_result = client.payment_methods.verify(pm_id) 159 print("OTP sent to customer's phone") 160 161 # Prompt customer for OTP 162 otp = input("Enter OTP: ") 163 164 # Confirm verification 165 client.payment_methods.confirm_verification({ 166 "payment_method_id": pm_id, 167 "token": otp 168 }) 169 ``` 170 171 See Also: 172 - confirm_verification(): Submit OTP to complete verification 173 - tokenize(): Create payment method that may need verification 174 - https://studio.inttegro.com/charge-repeat-customers 175 """ 176 return await self.http.post('/payment_methods/verify', {'payment_method_id': payment_method_id, 'request_meta': request_meta or _stable_payment_method_request_meta('verify', payment_method_id)}) 177 178 async def confirm_verification(self, payload: dict): 179 """ 180 Submit OTP to complete payment method verification. 181 182 After calling verify(), the customer receives an OTP on their mobile device. 183 Collect this OTP from the customer and submit it via this method to complete 184 verification. Once verified, the payment method can be used for charges. 185 186 Args: 187 payload: Verification parameters including: 188 - payment_method_id: The payment method being verified (required) 189 - token: The OTP code from customer (required, 6 digits) 190 191 Returns: 192 domain object containing: 193 - payment_method: Verified payment method ready for use 194 - status: Verification status 195 196 Raises: 197 ApiError: If OTP is invalid, expired, or verification fails 198 199 Example: 200 ```python 201 # Step 1: Tokenize 202 tokenize_result = client.payment_methods.tokenize({ 203 "customer_id": "cu_abc123", 204 "payment_method_data": { 205 "type": "mobile_money", 206 "mobile_money": { 207 "network": "mtn", 208 "account_number": "0241234567" 209 } 210 } 211 }) 212 213 pm_id = tokenize_result.id 214 215 # Step 2: Initiate verification 216 if tokenize_result.verified_at is None: 217 client.payment_methods.verify(pm_id) 218 print("OTP sent. Check your phone.") 219 220 # Step 3: Collect OTP from customer 221 otp = input("Enter the 6-digit code: ") 222 223 # Step 4: Confirm verification 224 result = client.payment_methods.confirm_verification({ 225 "payment_method_id": pm_id, 226 "token": otp 227 }) 228 229 if result.verified: 230 print("Payment method verified! Ready to use.") 231 232 # Now you can charge it 233 client.orders.pay({ 234 "order_id": "or_abc123", 235 "payment_method_id": pm_id 236 }) 237 ``` 238 239 See Also: 240 - verify(): Initiate verification and send OTP 241 - tokenize(): Create payment method 242 - https://studio.inttegro.com/charge-repeat-customers 243 """ 244 return await self.http.post('/payment_methods/confirm_verification', payload) 245 246 async def lookup(self, payment_method_id: str): 247 """ 248 Retrieve details of a saved payment method. 249 250 Fetches information about a payment method including its type, verification status, 251 and masked details (last 4 digits for cards, masked phone number for mobile money). 252 Use this to display saved payment methods to customers or verify their status. 253 254 Args: 255 payment_method_id: The payment method ID (e.g., "pm_xyz789") 256 257 Returns: 258 domain object containing: 259 - payment_method: Payment method details including: 260 - id: Payment method ID 261 - type: Payment type ("mobile_money", "card", etc.) 262 - verified: Whether verification is complete 263 - confirms_use: Whether OTP is required before charges 264 - masked_details: Safely displayable payment info 265 - customer_id: Associated customer 266 - created_at: Creation timestamp 267 268 Raises: 269 ApiError: If payment method doesn't exist 270 271 Example: 272 ```python 273 # Look up payment method 274 result = client.payment_methods.lookup("pm_xyz789") 275 pm = result 276 277 print(f"Type: {pm['type']}") 278 print(f"Verified: {pm['verified']}") 279 print(f"Details: {pm['masked_details']}") # e.g., "MTN •••• 4567" 280 281 # Display saved payment methods to customer 282 order = client.orders.lookup("or_abc123") 283 customer_id = order.customer.id 284 285 # Get customer's payment methods (from your database) 286 pm_ids = get_customer_payment_methods(customer_id) 287 288 print("Saved payment methods:") 289 for pm_id in pm_ids: 290 result = client.payment_methods.lookup(pm_id) 291 pm = result 292 print(f" - {pm['masked_details']}") 293 ``` 294 295 See Also: 296 - tokenize(): Create a payment method 297 - delete(): Remove a payment method 298 - https://studio.inttegro.com/api/payment-methods/lookup 299 """ 300 return await self.http.post('/payment_methods/lookup', {'payment_method_id': payment_method_id}) 301 302 async def page(self, payload: dict | None=None): 303 """ 304 List payment methods with optional pagination and customer filtering. 305 306 Args: 307 payload: Optional page_number, page_size, and customer_id filters. 308 309 Returns: 310 domain object containing a page of payment methods. 311 """ 312 return await self.http.post('/payment_methods/page', payload or {}) 313 314 async def update(self, payload: UpdateRequest): 315 """ 316 Update mutable payment method fields. 317 318 Args: 319 payload: Update parameters including payment_method_id. 320 321 Returns: 322 domain object containing the updated payment method. 323 """ 324 return await self.http.post('/payment_methods/update', payload) 325 326 async def activate(self, payment_method_id: str): 327 """Mark a payment method active. 328 329 API endpoint: ``/payment_methods/activate``. 330 331 Args: 332 payment_method_id (str): Unique identifier of the payment method. 333 334 Returns: 335 ``PaymentMethod`` decoded from the documented response shape. 336 337 Raises: 338 APIError: The API rejected the request or could not complete it. 339 NetworkError: The request could not reach the Inttegro API. 340 TimeoutError: The configured request deadline elapsed. 341 """ 342 return await self.http.post('/payment_methods/activate', {'payment_method_id': payment_method_id}) 343 344 async def disactivate(self, payment_method_id: str): 345 """Mark a payment method inactive. 346 347 API endpoint: ``/payment_methods/disactivate``. 348 349 Args: 350 payment_method_id (str): Unique identifier of the payment method. 351 352 Returns: 353 ``PaymentMethod`` decoded from the documented response shape. 354 355 Raises: 356 APIError: The API rejected the request or could not complete it. 357 NetworkError: The request could not reach the Inttegro API. 358 TimeoutError: The configured request deadline elapsed. 359 """ 360 return await self.http.post('/payment_methods/disactivate', {'payment_method_id': payment_method_id}) 361 362 async def deactivate(self, payment_method_id: str): 363 """Alias for disactivate(). 364 365 Args: 366 payment_method_id (str): Unique identifier of the payment method. 367 368 Returns: 369 ``PaymentMethod`` decoded from the documented response shape. 370 """ 371 return await self.disactivate(payment_method_id) 372 373 async def archive(self, payment_method_id: str): 374 """Archive a payment method. 375 376 API endpoint: ``/payment_methods/archive``. 377 378 Args: 379 payment_method_id (str): Unique identifier of the payment method. 380 381 Returns: 382 ``PaymentMethod`` decoded from the documented response shape. 383 384 Raises: 385 APIError: The API rejected the request or could not complete it. 386 NetworkError: The request could not reach the Inttegro API. 387 TimeoutError: The configured request deadline elapsed. 388 """ 389 return await self.http.post('/payment_methods/archive', {'payment_method_id': payment_method_id}) 390 391 async def unarchive(self, payment_method_id: str): 392 """Unarchive a payment method. 393 394 API endpoint: ``/payment_methods/unarchive``. 395 396 Args: 397 payment_method_id (str): Unique identifier of the payment method. 398 399 Returns: 400 ``PaymentMethod`` decoded from the documented response shape. 401 402 Raises: 403 APIError: The API rejected the request or could not complete it. 404 NetworkError: The request could not reach the Inttegro API. 405 TimeoutError: The configured request deadline elapsed. 406 """ 407 return await self.http.post('/payment_methods/unarchive', {'payment_method_id': payment_method_id}) 408 409 async def delete(self, payment_method_id: str, request_meta: dict | None=None): 410 """ 411 Delete a saved payment method. 412 413 Permanently removes a payment method from the system. This action cannot be undone. 414 The payment method ID becomes invalid and cannot be used for future charges. 415 Use this when customers want to remove saved payment methods. 416 417 Args: 418 payment_method_id: The payment method ID to delete (e.g., "pm_xyz789") 419 request_meta: Request controls such as idempotency_key 420 421 Returns: 422 domain object confirming deletion: 423 - deleted: True if deletion succeeded 424 - payment_method_id: ID of deleted payment method 425 426 Raises: 427 ApiError: If payment method doesn't exist or deletion fails 428 429 Example: 430 ```python 431 # Delete a payment method 432 result = client.payment_methods.delete("pm_xyz789") 433 print(f"Payment method deleted: {result.payment_method_id}") 434 435 # Customer removes saved card flow 436 def remove_payment_method(customer_id, pm_id): 437 # Verify customer owns this payment method 438 pm_result = client.payment_methods.lookup(pm_id) 439 pm = pm_result 440 441 if pm["customer_id"] != customer_id: 442 raise ValueError("Payment method doesn't belong to customer") 443 444 # Delete it 445 result = client.payment_methods.delete(pm_id) 446 447 # Remove from your database 448 delete_from_database(pm_id) 449 450 return result.deleted 451 452 # Cleanup unused payment methods 453 for pm_id in old_payment_methods: 454 try: 455 client.payment_methods.delete(pm_id) 456 print(f"Deleted {pm_id}") 457 except Exception as e: 458 print(f"Failed to delete {pm_id}: {e}") 459 ``` 460 461 Security Note: 462 Ensure you verify customer ownership before allowing deletion of 463 payment methods to prevent unauthorized removal. 464 465 See Also: 466 - tokenize(): Create payment methods 467 - lookup(): View payment method details 468 - https://studio.inttegro.com/api/payment-methods/delete 469 """ 470 return await self.http.post('/payment_methods/delete', {'payment_method_id': payment_method_id, 'request_meta': request_meta or _stable_payment_method_request_meta('delete', payment_method_id)}) 471 472 async def settings(self): 473 """ 474 Retrieve payment method configuration and supported types. 475 476 Gets your application's payment method settings including enabled payment types, 477 supported networks, OTP requirements, and other configuration. Use this to 478 dynamically build payment forms based on what's enabled for your account. 479 480 Returns: 481 domain object containing: 482 - settings: Payment configuration including: 483 - enabled_types: List of enabled payment types 484 - mobile_money: Mobile money configuration: 485 - issuers: Supported networks ("mtn", "vodafone", "airteltigo") 486 - default_confirms_use: Default OTP requirement 487 - cards: Card payment configuration (if enabled) 488 - other type-specific settings 489 490 Example: 491 ```python 492 # Get payment settings 493 result = client.payment_methods.settings() 494 settings = result 495 496 # Check what's enabled 497 enabled_types = settings["enabled_types"] 498 print(f"Enabled payment types: {enabled_types}") 499 500 # Build mobile money form based on supported networks 501 if "mobile_money" in enabled_types: 502 mm_config = settings["mobile_money"] 503 print(f"Supported networks: {mm_config['issuers']}") 504 print(f"Default OTP: {mm_config['default_confirms_use']}") 505 506 # Dynamic payment form 507 def build_payment_form(): 508 result = client.payment_methods.settings() 509 settings = result 510 511 form = {"payment_types": []} 512 513 if "mobile_money" in settings["enabled_types"]: 514 form["payment_types"].append({ 515 "type": "mobile_money", 516 "issuers": settings["mobile_money"]["issuers"] 517 }) 518 519 if "card" in settings["enabled_types"]: 520 form["payment_types"].append({ 521 "type": "card", 522 "brands": settings["card"]["supported_brands"] 523 }) 524 525 return form 526 ``` 527 528 See Also: 529 - tokenize(): Create payment methods based on settings 530 - https://studio.inttegro.com/api/payment-methods/settings 531 """ 532 return await self.http.post('/payment_methods/settings', {})
Payment methods resource for securely storing and managing payment instruments.
Payment methods represent saved payment instruments (mobile money accounts, bank cards, etc.) that customers can reuse for faster checkout. Tokenization converts sensitive payment details into a secure token that you can safely store and charge repeatedly without handling raw payment credentials.
The typical flow is:
- Tokenize payment details to create a payment method
- Verify the payment method (triggers OTP for mobile money)
- Confirm verification with OTP
- Use the payment method ID for future charges
See https://studio.inttegro.com/charge-repeat-customers for detailed guides.
29 def __init__(self, http: AsyncHttpClient): 30 """Initialize PaymentMethods resource with HTTP client.""" 31 self.http = http
Initialize PaymentMethods resource with HTTP client.
33 async def tokenize(self, payload: dict): 34 """ 35 Create a tokenized payment method from payment details. 36 37 Tokenization securely stores payment credentials (mobile money number, bank card, 38 etc.) and returns a reusable token. The token (payment method ID) can be used for 39 future charges without requiring the customer to re-enter payment details. 40 41 Mobile money payment methods require verification before use. After tokenization, 42 you must verify the payment method to confirm customer ownership. 43 44 Args: 45 payload: Tokenization parameters including: 46 - customer_id: Customer to attach payment method to (required) 47 - payment_method_data: Payment details (required): 48 - type: Payment type ("mobile_money") (required) 49 - mobile_money: Mobile money details (required if type is "mobile_money"): 50 - network: Network ("mtn", "vodafone", "airteltigo") (required) 51 - account_number: Phone number (required) 52 - verify_immediately: Send verification OTP immediately (default: false) 53 54 Returns: 55 domain object containing: 56 - payment_method: Created payment method with id, type, and status 57 - requires_verification: Whether verification is needed before use (typically true) 58 59 Raises: 60 ApiError: If parameters are invalid or customer doesn't exist 61 62 Example: 63 ```python 64 # Tokenize MTN mobile money 65 result = client.payment_methods.tokenize({ 66 "customer_id": "cu_abc123", 67 "payment_method_data": { 68 "type": "mobile_money", 69 "mobile_money": { 70 "network": "mtn", 71 "account_number": "0241234567" 72 } 73 } 74 }) 75 76 pm = result 77 print(f"Payment method created: {pm['id']}") 78 79 # Verify if needed 80 if result.verified_at is None: 81 print("Verification required before use") 82 client.payment_methods.verify(pm['id']) 83 84 # Tokenize with immediate verification 85 result = client.payment_methods.tokenize({ 86 "customer_id": "cu_abc123", 87 "payment_method_data": { 88 "type": "mobile_money", 89 "mobile_money": { 90 "network": "vodafone", 91 "account_number": "0501234567" 92 } 93 }, 94 "verify_immediately": True 95 }) 96 97 # OTP is sent immediately, prompt customer 98 if result.verified_at is None: 99 otp = input("Enter OTP: ") 100 client.payment_methods.confirm_verification({ 101 "payment_method_id": result.id, 102 "token": otp 103 }) 104 ``` 105 106 Security Note: 107 Never log or store raw payment credentials (phone numbers, card numbers). 108 Only store the returned payment_method_id token. 109 110 See Also: 111 - verify(): Initiate verification after tokenization 112 - confirm_verification(): Complete verification with OTP 113 - https://studio.inttegro.com/charge-repeat-customers 114 """ 115 return await self.http.post('/payment_methods/tokenize', payload)
Create a tokenized payment method from payment details.
Tokenization securely stores payment credentials (mobile money number, bank card, etc.) and returns a reusable token. The token (payment method ID) can be used for future charges without requiring the customer to re-enter payment details.
Mobile money payment methods require verification before use. After tokenization, you must verify the payment method to confirm customer ownership.
Arguments:
- payload: Tokenization parameters including:
- customer_id: Customer to attach payment method to (required)
- payment_method_data: Payment details (required):
- type: Payment type ("mobile_money") (required)
- mobile_money: Mobile money details (required if type is "mobile_money"):
- network: Network ("mtn", "vodafone", "airteltigo") (required)
- account_number: Phone number (required)
- verify_immediately: Send verification OTP immediately (default: false)
Returns:
domain object containing: - payment_method: Created payment method with id, type, and status - requires_verification: Whether verification is needed before use (typically true)
Raises:
- ApiError: If parameters are invalid or customer doesn't exist
Example:
# Tokenize MTN mobile money result = client.payment_methods.tokenize({ "customer_id": "cu_abc123", "payment_method_data": { "type": "mobile_money", "mobile_money": { "network": "mtn", "account_number": "0241234567" } } }) pm = result print(f"Payment method created: {pm['id']}") # Verify if needed if result.verified_at is None: print("Verification required before use") client.payment_methods.verify(pm['id']) # Tokenize with immediate verification result = client.payment_methods.tokenize({ "customer_id": "cu_abc123", "payment_method_data": { "type": "mobile_money", "mobile_money": { "network": "vodafone", "account_number": "0501234567" } }, "verify_immediately": True }) # OTP is sent immediately, prompt customer if result.verified_at is None: otp = input("Enter OTP: ") client.payment_methods.confirm_verification({ "payment_method_id": result.id, "token": otp })
Security Note:
Never log or store raw payment credentials (phone numbers, card numbers). Only store the returned payment_method_id token.
See Also:
- verify(): Initiate verification after tokenization
- confirm_verification(): Complete verification with OTP
- https://studio.inttegro.com/charge-repeat-customers
117 async def verify(self, payment_method_id: str, request_meta: dict | None=None): 118 """ 119 Initiate verification for a payment method. 120 121 Verification confirms that the customer owns the payment instrument. For mobile 122 money, this sends an OTP to the phone number. The customer must submit this OTP 123 via confirm_verification() before the payment method can be used for charges. 124 125 Only unverified payment methods need verification. Once verified, the payment 126 method can be used indefinitely. 127 128 Args: 129 payment_method_id: The payment method ID to verify (e.g., "pm_xyz789") 130 request_meta: Request controls such as idempotency_key 131 132 Returns: 133 domain object containing: 134 - payment_method: Updated payment method with verification status 135 - message: Confirmation that OTP was sent 136 137 Raises: 138 ApiError: If payment method doesn't exist or is already verified 139 140 Example: 141 ```python 142 # Tokenize payment method 143 result = client.payment_methods.tokenize({ 144 "customer_id": "cu_abc123", 145 "payment_method_data": { 146 "type": "mobile_money", 147 "mobile_money": { 148 "network": "mtn", 149 "account_number": "0241234567" 150 } 151 } 152 }) 153 154 pm_id = result.id 155 156 # Initiate verification 157 if result.verified_at is None: 158 verify_result = client.payment_methods.verify(pm_id) 159 print("OTP sent to customer's phone") 160 161 # Prompt customer for OTP 162 otp = input("Enter OTP: ") 163 164 # Confirm verification 165 client.payment_methods.confirm_verification({ 166 "payment_method_id": pm_id, 167 "token": otp 168 }) 169 ``` 170 171 See Also: 172 - confirm_verification(): Submit OTP to complete verification 173 - tokenize(): Create payment method that may need verification 174 - https://studio.inttegro.com/charge-repeat-customers 175 """ 176 return await self.http.post('/payment_methods/verify', {'payment_method_id': payment_method_id, 'request_meta': request_meta or _stable_payment_method_request_meta('verify', payment_method_id)})
Initiate verification for a payment method.
Verification confirms that the customer owns the payment instrument. For mobile money, this sends an OTP to the phone number. The customer must submit this OTP via confirm_verification() before the payment method can be used for charges.
Only unverified payment methods need verification. Once verified, the payment method can be used indefinitely.
Arguments:
- payment_method_id: The payment method ID to verify (e.g., "pm_xyz789")
- request_meta: Request controls such as idempotency_key
Returns:
domain object containing: - payment_method: Updated payment method with verification status - message: Confirmation that OTP was sent
Raises:
- ApiError: If payment method doesn't exist or is already verified
Example:
# Tokenize payment method result = client.payment_methods.tokenize({ "customer_id": "cu_abc123", "payment_method_data": { "type": "mobile_money", "mobile_money": { "network": "mtn", "account_number": "0241234567" } } }) pm_id = result.id # Initiate verification if result.verified_at is None: verify_result = client.payment_methods.verify(pm_id) print("OTP sent to customer's phone") # Prompt customer for OTP otp = input("Enter OTP: ") # Confirm verification client.payment_methods.confirm_verification({ "payment_method_id": pm_id, "token": otp })
See Also:
- confirm_verification(): Submit OTP to complete verification
- tokenize(): Create payment method that may need verification
- https://studio.inttegro.com/charge-repeat-customers
178 async def confirm_verification(self, payload: dict): 179 """ 180 Submit OTP to complete payment method verification. 181 182 After calling verify(), the customer receives an OTP on their mobile device. 183 Collect this OTP from the customer and submit it via this method to complete 184 verification. Once verified, the payment method can be used for charges. 185 186 Args: 187 payload: Verification parameters including: 188 - payment_method_id: The payment method being verified (required) 189 - token: The OTP code from customer (required, 6 digits) 190 191 Returns: 192 domain object containing: 193 - payment_method: Verified payment method ready for use 194 - status: Verification status 195 196 Raises: 197 ApiError: If OTP is invalid, expired, or verification fails 198 199 Example: 200 ```python 201 # Step 1: Tokenize 202 tokenize_result = client.payment_methods.tokenize({ 203 "customer_id": "cu_abc123", 204 "payment_method_data": { 205 "type": "mobile_money", 206 "mobile_money": { 207 "network": "mtn", 208 "account_number": "0241234567" 209 } 210 } 211 }) 212 213 pm_id = tokenize_result.id 214 215 # Step 2: Initiate verification 216 if tokenize_result.verified_at is None: 217 client.payment_methods.verify(pm_id) 218 print("OTP sent. Check your phone.") 219 220 # Step 3: Collect OTP from customer 221 otp = input("Enter the 6-digit code: ") 222 223 # Step 4: Confirm verification 224 result = client.payment_methods.confirm_verification({ 225 "payment_method_id": pm_id, 226 "token": otp 227 }) 228 229 if result.verified: 230 print("Payment method verified! Ready to use.") 231 232 # Now you can charge it 233 client.orders.pay({ 234 "order_id": "or_abc123", 235 "payment_method_id": pm_id 236 }) 237 ``` 238 239 See Also: 240 - verify(): Initiate verification and send OTP 241 - tokenize(): Create payment method 242 - https://studio.inttegro.com/charge-repeat-customers 243 """ 244 return await self.http.post('/payment_methods/confirm_verification', payload)
Submit OTP to complete payment method verification.
After calling verify(), the customer receives an OTP on their mobile device. Collect this OTP from the customer and submit it via this method to complete verification. Once verified, the payment method can be used for charges.
Arguments:
- payload: Verification parameters including:
- payment_method_id: The payment method being verified (required)
- token: The OTP code from customer (required, 6 digits)
Returns:
domain object containing: - payment_method: Verified payment method ready for use - status: Verification status
Raises:
- ApiError: If OTP is invalid, expired, or verification fails
Example:
# Step 1: Tokenize tokenize_result = client.payment_methods.tokenize({ "customer_id": "cu_abc123", "payment_method_data": { "type": "mobile_money", "mobile_money": { "network": "mtn", "account_number": "0241234567" } } }) pm_id = tokenize_result.id # Step 2: Initiate verification if tokenize_result.verified_at is None: client.payment_methods.verify(pm_id) print("OTP sent. Check your phone.") # Step 3: Collect OTP from customer otp = input("Enter the 6-digit code: ") # Step 4: Confirm verification result = client.payment_methods.confirm_verification({ "payment_method_id": pm_id, "token": otp }) if result.verified: print("Payment method verified! Ready to use.") # Now you can charge it client.orders.pay({ "order_id": "or_abc123", "payment_method_id": pm_id })
See Also:
- verify(): Initiate verification and send OTP
- tokenize(): Create payment method
- https://studio.inttegro.com/charge-repeat-customers
246 async def lookup(self, payment_method_id: str): 247 """ 248 Retrieve details of a saved payment method. 249 250 Fetches information about a payment method including its type, verification status, 251 and masked details (last 4 digits for cards, masked phone number for mobile money). 252 Use this to display saved payment methods to customers or verify their status. 253 254 Args: 255 payment_method_id: The payment method ID (e.g., "pm_xyz789") 256 257 Returns: 258 domain object containing: 259 - payment_method: Payment method details including: 260 - id: Payment method ID 261 - type: Payment type ("mobile_money", "card", etc.) 262 - verified: Whether verification is complete 263 - confirms_use: Whether OTP is required before charges 264 - masked_details: Safely displayable payment info 265 - customer_id: Associated customer 266 - created_at: Creation timestamp 267 268 Raises: 269 ApiError: If payment method doesn't exist 270 271 Example: 272 ```python 273 # Look up payment method 274 result = client.payment_methods.lookup("pm_xyz789") 275 pm = result 276 277 print(f"Type: {pm['type']}") 278 print(f"Verified: {pm['verified']}") 279 print(f"Details: {pm['masked_details']}") # e.g., "MTN •••• 4567" 280 281 # Display saved payment methods to customer 282 order = client.orders.lookup("or_abc123") 283 customer_id = order.customer.id 284 285 # Get customer's payment methods (from your database) 286 pm_ids = get_customer_payment_methods(customer_id) 287 288 print("Saved payment methods:") 289 for pm_id in pm_ids: 290 result = client.payment_methods.lookup(pm_id) 291 pm = result 292 print(f" - {pm['masked_details']}") 293 ``` 294 295 See Also: 296 - tokenize(): Create a payment method 297 - delete(): Remove a payment method 298 - https://studio.inttegro.com/api/payment-methods/lookup 299 """ 300 return await self.http.post('/payment_methods/lookup', {'payment_method_id': payment_method_id})
Retrieve details of a saved payment method.
Fetches information about a payment method including its type, verification status, and masked details (last 4 digits for cards, masked phone number for mobile money). Use this to display saved payment methods to customers or verify their status.
Arguments:
- payment_method_id: The payment method ID (e.g., "pm_xyz789")
Returns:
domain object containing: - payment_method: Payment method details including: - id: Payment method ID - type: Payment type ("mobile_money", "card", etc.) - verified: Whether verification is complete - confirms_use: Whether OTP is required before charges - masked_details: Safely displayable payment info - customer_id: Associated customer - created_at: Creation timestamp
Raises:
- ApiError: If payment method doesn't exist
Example:
# Look up payment method result = client.payment_methods.lookup("pm_xyz789") pm = result print(f"Type: {pm['type']}") print(f"Verified: {pm['verified']}") print(f"Details: {pm['masked_details']}") # e.g., "MTN •••• 4567" # Display saved payment methods to customer order = client.orders.lookup("or_abc123") customer_id = order.customer.id # Get customer's payment methods (from your database) pm_ids = get_customer_payment_methods(customer_id) print("Saved payment methods:") for pm_id in pm_ids: result = client.payment_methods.lookup(pm_id) pm = result print(f" - {pm['masked_details']}")
See Also:
- tokenize(): Create a payment method
- delete(): Remove a payment method
- https://studio.inttegro.com/api/payment-methods/lookup
302 async def page(self, payload: dict | None=None): 303 """ 304 List payment methods with optional pagination and customer filtering. 305 306 Args: 307 payload: Optional page_number, page_size, and customer_id filters. 308 309 Returns: 310 domain object containing a page of payment methods. 311 """ 312 return await self.http.post('/payment_methods/page', payload or {})
List payment methods with optional pagination and customer filtering.
Arguments:
- payload: Optional page_number, page_size, and customer_id filters.
Returns:
domain object containing a page of payment methods.
314 async def update(self, payload: UpdateRequest): 315 """ 316 Update mutable payment method fields. 317 318 Args: 319 payload: Update parameters including payment_method_id. 320 321 Returns: 322 domain object containing the updated payment method. 323 """ 324 return await self.http.post('/payment_methods/update', payload)
Update mutable payment method fields.
Arguments:
- payload: Update parameters including payment_method_id.
Returns:
domain object containing the updated payment method.
326 async def activate(self, payment_method_id: str): 327 """Mark a payment method active. 328 329 API endpoint: ``/payment_methods/activate``. 330 331 Args: 332 payment_method_id (str): Unique identifier of the payment method. 333 334 Returns: 335 ``PaymentMethod`` decoded from the documented response shape. 336 337 Raises: 338 APIError: The API rejected the request or could not complete it. 339 NetworkError: The request could not reach the Inttegro API. 340 TimeoutError: The configured request deadline elapsed. 341 """ 342 return await self.http.post('/payment_methods/activate', {'payment_method_id': payment_method_id})
Mark a payment method active.
API endpoint: /payment_methods/activate.
Arguments:
- payment_method_id (str): Unique identifier of the payment method.
Returns:
PaymentMethoddecoded from the documented response shape.
Raises:
- APIError: The API rejected the request or could not complete it.
- NetworkError: The request could not reach the Inttegro API.
- TimeoutError: The configured request deadline elapsed.
344 async def disactivate(self, payment_method_id: str): 345 """Mark a payment method inactive. 346 347 API endpoint: ``/payment_methods/disactivate``. 348 349 Args: 350 payment_method_id (str): Unique identifier of the payment method. 351 352 Returns: 353 ``PaymentMethod`` decoded from the documented response shape. 354 355 Raises: 356 APIError: The API rejected the request or could not complete it. 357 NetworkError: The request could not reach the Inttegro API. 358 TimeoutError: The configured request deadline elapsed. 359 """ 360 return await self.http.post('/payment_methods/disactivate', {'payment_method_id': payment_method_id})
Mark a payment method inactive.
API endpoint: /payment_methods/disactivate.
Arguments:
- payment_method_id (str): Unique identifier of the payment method.
Returns:
PaymentMethoddecoded from the documented response shape.
Raises:
- APIError: The API rejected the request or could not complete it.
- NetworkError: The request could not reach the Inttegro API.
- TimeoutError: The configured request deadline elapsed.
362 async def deactivate(self, payment_method_id: str): 363 """Alias for disactivate(). 364 365 Args: 366 payment_method_id (str): Unique identifier of the payment method. 367 368 Returns: 369 ``PaymentMethod`` decoded from the documented response shape. 370 """ 371 return await self.disactivate(payment_method_id)
Alias for disactivate().
Arguments:
- payment_method_id (str): Unique identifier of the payment method.
Returns:
PaymentMethoddecoded from the documented response shape.
373 async def archive(self, payment_method_id: str): 374 """Archive a payment method. 375 376 API endpoint: ``/payment_methods/archive``. 377 378 Args: 379 payment_method_id (str): Unique identifier of the payment method. 380 381 Returns: 382 ``PaymentMethod`` decoded from the documented response shape. 383 384 Raises: 385 APIError: The API rejected the request or could not complete it. 386 NetworkError: The request could not reach the Inttegro API. 387 TimeoutError: The configured request deadline elapsed. 388 """ 389 return await self.http.post('/payment_methods/archive', {'payment_method_id': payment_method_id})
Archive a payment method.
API endpoint: /payment_methods/archive.
Arguments:
- payment_method_id (str): Unique identifier of the payment method.
Returns:
PaymentMethoddecoded from the documented response shape.
Raises:
- APIError: The API rejected the request or could not complete it.
- NetworkError: The request could not reach the Inttegro API.
- TimeoutError: The configured request deadline elapsed.
391 async def unarchive(self, payment_method_id: str): 392 """Unarchive a payment method. 393 394 API endpoint: ``/payment_methods/unarchive``. 395 396 Args: 397 payment_method_id (str): Unique identifier of the payment method. 398 399 Returns: 400 ``PaymentMethod`` decoded from the documented response shape. 401 402 Raises: 403 APIError: The API rejected the request or could not complete it. 404 NetworkError: The request could not reach the Inttegro API. 405 TimeoutError: The configured request deadline elapsed. 406 """ 407 return await self.http.post('/payment_methods/unarchive', {'payment_method_id': payment_method_id})
Unarchive a payment method.
API endpoint: /payment_methods/unarchive.
Arguments:
- payment_method_id (str): Unique identifier of the payment method.
Returns:
PaymentMethoddecoded from the documented response shape.
Raises:
- APIError: The API rejected the request or could not complete it.
- NetworkError: The request could not reach the Inttegro API.
- TimeoutError: The configured request deadline elapsed.
409 async def delete(self, payment_method_id: str, request_meta: dict | None=None): 410 """ 411 Delete a saved payment method. 412 413 Permanently removes a payment method from the system. This action cannot be undone. 414 The payment method ID becomes invalid and cannot be used for future charges. 415 Use this when customers want to remove saved payment methods. 416 417 Args: 418 payment_method_id: The payment method ID to delete (e.g., "pm_xyz789") 419 request_meta: Request controls such as idempotency_key 420 421 Returns: 422 domain object confirming deletion: 423 - deleted: True if deletion succeeded 424 - payment_method_id: ID of deleted payment method 425 426 Raises: 427 ApiError: If payment method doesn't exist or deletion fails 428 429 Example: 430 ```python 431 # Delete a payment method 432 result = client.payment_methods.delete("pm_xyz789") 433 print(f"Payment method deleted: {result.payment_method_id}") 434 435 # Customer removes saved card flow 436 def remove_payment_method(customer_id, pm_id): 437 # Verify customer owns this payment method 438 pm_result = client.payment_methods.lookup(pm_id) 439 pm = pm_result 440 441 if pm["customer_id"] != customer_id: 442 raise ValueError("Payment method doesn't belong to customer") 443 444 # Delete it 445 result = client.payment_methods.delete(pm_id) 446 447 # Remove from your database 448 delete_from_database(pm_id) 449 450 return result.deleted 451 452 # Cleanup unused payment methods 453 for pm_id in old_payment_methods: 454 try: 455 client.payment_methods.delete(pm_id) 456 print(f"Deleted {pm_id}") 457 except Exception as e: 458 print(f"Failed to delete {pm_id}: {e}") 459 ``` 460 461 Security Note: 462 Ensure you verify customer ownership before allowing deletion of 463 payment methods to prevent unauthorized removal. 464 465 See Also: 466 - tokenize(): Create payment methods 467 - lookup(): View payment method details 468 - https://studio.inttegro.com/api/payment-methods/delete 469 """ 470 return await self.http.post('/payment_methods/delete', {'payment_method_id': payment_method_id, 'request_meta': request_meta or _stable_payment_method_request_meta('delete', payment_method_id)})
Delete a saved payment method.
Permanently removes a payment method from the system. This action cannot be undone. The payment method ID becomes invalid and cannot be used for future charges. Use this when customers want to remove saved payment methods.
Arguments:
- payment_method_id: The payment method ID to delete (e.g., "pm_xyz789")
- request_meta: Request controls such as idempotency_key
Returns:
domain object confirming deletion: - deleted: True if deletion succeeded - payment_method_id: ID of deleted payment method
Raises:
- ApiError: If payment method doesn't exist or deletion fails
Example:
# Delete a payment method result = client.payment_methods.delete("pm_xyz789") print(f"Payment method deleted: {result.payment_method_id}") # Customer removes saved card flow def remove_payment_method(customer_id, pm_id): # Verify customer owns this payment method pm_result = client.payment_methods.lookup(pm_id) pm = pm_result if pm["customer_id"] != customer_id: raise ValueError("Payment method doesn't belong to customer") # Delete it result = client.payment_methods.delete(pm_id) # Remove from your database delete_from_database(pm_id) return result.deleted # Cleanup unused payment methods for pm_id in old_payment_methods: try: client.payment_methods.delete(pm_id) print(f"Deleted {pm_id}") except Exception as e: print(f"Failed to delete {pm_id}: {e}")
Security Note:
Ensure you verify customer ownership before allowing deletion of payment methods to prevent unauthorized removal.
See Also:
- tokenize(): Create payment methods
- lookup(): View payment method details
- https://studio.inttegro.com/api/payment-methods/delete
472 async def settings(self): 473 """ 474 Retrieve payment method configuration and supported types. 475 476 Gets your application's payment method settings including enabled payment types, 477 supported networks, OTP requirements, and other configuration. Use this to 478 dynamically build payment forms based on what's enabled for your account. 479 480 Returns: 481 domain object containing: 482 - settings: Payment configuration including: 483 - enabled_types: List of enabled payment types 484 - mobile_money: Mobile money configuration: 485 - issuers: Supported networks ("mtn", "vodafone", "airteltigo") 486 - default_confirms_use: Default OTP requirement 487 - cards: Card payment configuration (if enabled) 488 - other type-specific settings 489 490 Example: 491 ```python 492 # Get payment settings 493 result = client.payment_methods.settings() 494 settings = result 495 496 # Check what's enabled 497 enabled_types = settings["enabled_types"] 498 print(f"Enabled payment types: {enabled_types}") 499 500 # Build mobile money form based on supported networks 501 if "mobile_money" in enabled_types: 502 mm_config = settings["mobile_money"] 503 print(f"Supported networks: {mm_config['issuers']}") 504 print(f"Default OTP: {mm_config['default_confirms_use']}") 505 506 # Dynamic payment form 507 def build_payment_form(): 508 result = client.payment_methods.settings() 509 settings = result 510 511 form = {"payment_types": []} 512 513 if "mobile_money" in settings["enabled_types"]: 514 form["payment_types"].append({ 515 "type": "mobile_money", 516 "issuers": settings["mobile_money"]["issuers"] 517 }) 518 519 if "card" in settings["enabled_types"]: 520 form["payment_types"].append({ 521 "type": "card", 522 "brands": settings["card"]["supported_brands"] 523 }) 524 525 return form 526 ``` 527 528 See Also: 529 - tokenize(): Create payment methods based on settings 530 - https://studio.inttegro.com/api/payment-methods/settings 531 """ 532 return await self.http.post('/payment_methods/settings', {})
Retrieve payment method configuration and supported types.
Gets your application's payment method settings including enabled payment types, supported networks, OTP requirements, and other configuration. Use this to dynamically build payment forms based on what's enabled for your account.
Returns:
domain object containing: - settings: Payment configuration including: - enabled_types: List of enabled payment types - mobile_money: Mobile money configuration: - issuers: Supported networks ("mtn", "vodafone", "airteltigo") - default_confirms_use: Default OTP requirement - cards: Card payment configuration (if enabled) - other type-specific settings
Example:
# Get payment settings result = client.payment_methods.settings() settings = result # Check what's enabled enabled_types = settings["enabled_types"] print(f"Enabled payment types: {enabled_types}") # Build mobile money form based on supported networks if "mobile_money" in enabled_types: mm_config = settings["mobile_money"] print(f"Supported networks: {mm_config['issuers']}") print(f"Default OTP: {mm_config['default_confirms_use']}") # Dynamic payment form def build_payment_form(): result = client.payment_methods.settings() settings = result form = {"payment_types": []} if "mobile_money" in settings["enabled_types"]: form["payment_types"].append({ "type": "mobile_money", "issuers": settings["mobile_money"]["issuers"] }) if "card" in settings["enabled_types"]: form["payment_types"].append({ "type": "card", "brands": settings["card"]["supported_brands"] }) return form
See Also:
- tokenize(): Create payment methods based on settings
- https://studio.inttegro.com/api/payment-methods/settings