inttegro.resources.payment_methods

Generated public typing surface. Do not edit by hand.

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

  1. Tokenize payment details to create a payment method
  2. Verify the payment method (triggers OTP for mobile money)
  3. Confirm verification with OTP
  4. Use the payment method ID for future charges

See https://studio.inttegro.com/charge-repeat-customers for detailed guides.

PaymentMethods(http: inttegro.http_client.HttpClient)
32    def __init__(self, http: HttpClient):
33        """Initialize PaymentMethods resource with HTTP client."""
34        self.http = http

Initialize PaymentMethods resource with HTTP client.

http
 36    def tokenize(self, payload: dict):
 37        """
 38        Create a tokenized payment method from payment details.
 39
 40        Tokenization securely stores payment credentials (mobile money number, bank card,
 41        etc.) and returns a reusable token. The token (payment method ID) can be used for
 42        future charges without requiring the customer to re-enter payment details.
 43
 44        Mobile money payment methods require verification before use. After tokenization,
 45        you must verify the payment method to confirm customer ownership.
 46
 47        Args:
 48            payload: Tokenization parameters including:
 49                - customer_id: Customer to attach payment method to (required)
 50                - payment_method_data: Payment details (required):
 51                    - type: Payment type ("mobile_money") (required)
 52                    - mobile_money: Mobile money details (required if type is "mobile_money"):
 53                        - network: Network ("mtn", "vodafone", "airteltigo") (required)
 54                        - account_number: Phone number (required)
 55                - verify_immediately: Send verification OTP immediately (default: false)
 56
 57        Returns:
 58            domain object containing:
 59                - payment_method: Created payment method with id, type, and status
 60                - requires_verification: Whether verification is needed before use (typically true)
 61
 62        Raises:
 63            ApiError: If parameters are invalid or customer doesn't exist
 64
 65        Example:
 66            ```python
 67            # Tokenize MTN mobile money
 68            result = client.payment_methods.tokenize({
 69                "customer_id": "cu_abc123",
 70                "payment_method_data": {
 71                    "type": "mobile_money",
 72                    "mobile_money": {
 73                        "network": "mtn",
 74                        "account_number": "0241234567"
 75                    }
 76                }
 77            })
 78
 79            pm = result
 80            print(f"Payment method created: {pm['id']}")
 81
 82            # Verify if needed
 83            if result.verified_at is None:
 84                print("Verification required before use")
 85                client.payment_methods.verify(pm['id'])
 86
 87            # Tokenize with immediate verification
 88            result = client.payment_methods.tokenize({
 89                "customer_id": "cu_abc123",
 90                "payment_method_data": {
 91                    "type": "mobile_money",
 92                    "mobile_money": {
 93                        "network": "vodafone",
 94                        "account_number": "0501234567"
 95                    }
 96                },
 97                "verify_immediately": True
 98            })
 99
100            # OTP is sent immediately, prompt customer
101            if result.verified_at is None:
102                otp = input("Enter OTP: ")
103                client.payment_methods.confirm_verification({
104                    "payment_method_id": result.id,
105                    "token": otp
106                })
107            ```
108
109        Security Note:
110            Never log or store raw payment credentials (phone numbers, card numbers).
111            Only store the returned payment_method_id token.
112
113        See Also:
114            - verify(): Initiate verification after tokenization
115            - confirm_verification(): Complete verification with OTP
116            - https://studio.inttegro.com/charge-repeat-customers
117        """
118        return 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:
def verify( self, payment_method_id: str, request_meta: dict[str, str] | None = None) -> inttegro.payment_method.VerificationSession:
120    def verify(self, payment_method_id: str, request_meta: dict | None = None):
121        """
122        Initiate verification for a payment method.
123
124        Verification confirms that the customer owns the payment instrument. For mobile
125        money, this sends an OTP to the phone number. The customer must submit this OTP
126        via confirm_verification() before the payment method can be used for charges.
127
128        Only unverified payment methods need verification. Once verified, the payment
129        method can be used indefinitely.
130
131        Args:
132            payment_method_id: The payment method ID to verify (e.g., "pm_xyz789")
133            request_meta: Request controls such as idempotency_key
134
135        Returns:
136            domain object containing:
137                - payment_method: Updated payment method with verification status
138                - message: Confirmation that OTP was sent
139
140        Raises:
141            ApiError: If payment method doesn't exist or is already verified
142
143        Example:
144            ```python
145            # Tokenize payment method
146            result = client.payment_methods.tokenize({
147                "customer_id": "cu_abc123",
148                "payment_method_data": {
149                    "type": "mobile_money",
150                    "mobile_money": {
151                        "network": "mtn",
152                        "account_number": "0241234567"
153                    }
154                }
155            })
156
157            pm_id = result.id
158
159            # Initiate verification
160            if result.verified_at is None:
161                verify_result = client.payment_methods.verify(pm_id)
162                print("OTP sent to customer's phone")
163
164                # Prompt customer for OTP
165                otp = input("Enter OTP: ")
166
167                # Confirm verification
168                client.payment_methods.confirm_verification({
169                    "payment_method_id": pm_id,
170                    "token": otp
171                })
172            ```
173
174        See Also:
175            - confirm_verification(): Submit OTP to complete verification
176            - tokenize(): Create payment method that may need verification
177            - https://studio.inttegro.com/charge-repeat-customers
178        """
179        return self.http.post(
180            "/payment_methods/verify",
181            {
182                "payment_method_id": payment_method_id,
183                "request_meta": request_meta or _stable_payment_method_request_meta(
184                    "verify", payment_method_id
185                ),
186            },
187        )

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:
def confirm_verification( self, payload: inttegro.payment_method.LookupRequest) -> inttegro.payment_method.PaymentMethod:
189    def confirm_verification(self, payload: dict):
190        """
191        Submit OTP to complete payment method verification.
192
193        After calling verify(), the customer receives an OTP on their mobile device.
194        Collect this OTP from the customer and submit it via this method to complete
195        verification. Once verified, the payment method can be used for charges.
196
197        Args:
198            payload: Verification parameters including:
199                - payment_method_id: The payment method being verified (required)
200                - token: The OTP code from customer (required, 6 digits)
201
202        Returns:
203            domain object containing:
204                - payment_method: Verified payment method ready for use
205                - status: Verification status
206
207        Raises:
208            ApiError: If OTP is invalid, expired, or verification fails
209
210        Example:
211            ```python
212            # Step 1: Tokenize
213            tokenize_result = client.payment_methods.tokenize({
214                "customer_id": "cu_abc123",
215                "payment_method_data": {
216                    "type": "mobile_money",
217                    "mobile_money": {
218                        "network": "mtn",
219                        "account_number": "0241234567"
220                    }
221                }
222            })
223
224            pm_id = tokenize_result.id
225
226            # Step 2: Initiate verification
227            if tokenize_result.verified_at is None:
228                client.payment_methods.verify(pm_id)
229                print("OTP sent. Check your phone.")
230
231                # Step 3: Collect OTP from customer
232                otp = input("Enter the 6-digit code: ")
233
234                # Step 4: Confirm verification
235                result = client.payment_methods.confirm_verification({
236                    "payment_method_id": pm_id,
237                    "token": otp
238                })
239
240                if result.verified:
241                    print("Payment method verified! Ready to use.")
242
243                    # Now you can charge it
244                    client.orders.pay({
245                        "order_id": "or_abc123",
246                        "payment_method_id": pm_id
247                    })
248            ```
249
250        See Also:
251            - verify(): Initiate verification and send OTP
252            - tokenize(): Create payment method
253            - https://studio.inttegro.com/charge-repeat-customers
254        """
255        return 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:
def lookup( self, payment_method_id: str) -> inttegro.payment_method.PaymentMethod:
257    def lookup(self, payment_method_id: str):
258        """
259        Retrieve details of a saved payment method.
260
261        Fetches information about a payment method including its type, verification status,
262        and masked details (last 4 digits for cards, masked phone number for mobile money).
263        Use this to display saved payment methods to customers or verify their status.
264
265        Args:
266            payment_method_id: The payment method ID (e.g., "pm_xyz789")
267
268        Returns:
269            domain object containing:
270                - payment_method: Payment method details including:
271                    - id: Payment method ID
272                    - type: Payment type ("mobile_money", "card", etc.)
273                    - verified: Whether verification is complete
274                    - confirms_use: Whether OTP is required before charges
275                    - masked_details: Safely displayable payment info
276                    - customer_id: Associated customer
277                    - created_at: Creation timestamp
278
279        Raises:
280            ApiError: If payment method doesn't exist
281
282        Example:
283            ```python
284            # Look up payment method
285            result = client.payment_methods.lookup("pm_xyz789")
286            pm = result
287
288            print(f"Type: {pm['type']}")
289            print(f"Verified: {pm['verified']}")
290            print(f"Details: {pm['masked_details']}")  # e.g., "MTN •••• 4567"
291
292            # Display saved payment methods to customer
293            order = client.orders.lookup("or_abc123")
294            customer_id = order.customer.id
295
296            # Get customer's payment methods (from your database)
297            pm_ids = get_customer_payment_methods(customer_id)
298
299            print("Saved payment methods:")
300            for pm_id in pm_ids:
301                result = client.payment_methods.lookup(pm_id)
302                pm = result
303                print(f"  - {pm['masked_details']}")
304            ```
305
306        See Also:
307            - tokenize(): Create a payment method
308            - delete(): Remove a payment method
309            - https://studio.inttegro.com/api/payment-methods/lookup
310        """
311        return 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:
def page( self, payload: inttegro.payment_method.PageRequest | None = None) -> inttegro.payment_method.Page:
313    def page(self, payload: dict | None = None):
314        """
315        List payment methods with optional pagination and customer filtering.
316
317        Args:
318            payload: Optional page_number, page_size, and customer_id filters.
319
320        Returns:
321            domain object containing a page of payment methods.
322        """
323        return 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.

325    def update(self, payload: UpdateRequest):
326        """
327        Update mutable payment method fields.
328
329        Args:
330            payload: Update parameters including payment_method_id.
331
332        Returns:
333            domain object containing the updated payment method.
334        """
335        return 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.

def activate( self, payment_method_id: str) -> inttegro.payment_method.PaymentMethod:
337    def activate(self, payment_method_id: str):
338        """Mark a payment method active.
339
340        API endpoint: ``/payment_methods/activate``.
341
342        Args:
343            payment_method_id (str): Unique identifier of the payment method.
344
345        Returns:
346            ``PaymentMethod`` decoded from the documented response shape.
347
348        Raises:
349            APIError: The API rejected the request or could not complete it.
350            NetworkError: The request could not reach the Inttegro API.
351            TimeoutError: The configured request deadline elapsed.
352        """
353        return 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:

PaymentMethod decoded 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.
def disactivate( self, payment_method_id: str) -> inttegro.payment_method.PaymentMethod:
355    def disactivate(self, payment_method_id: str):
356        """Mark a payment method inactive.
357
358        API endpoint: ``/payment_methods/disactivate``.
359
360        Args:
361            payment_method_id (str): Unique identifier of the payment method.
362
363        Returns:
364            ``PaymentMethod`` decoded from the documented response shape.
365
366        Raises:
367            APIError: The API rejected the request or could not complete it.
368            NetworkError: The request could not reach the Inttegro API.
369            TimeoutError: The configured request deadline elapsed.
370        """
371        return 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:

PaymentMethod decoded 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.
def deactivate( self, payment_method_id: str) -> inttegro.payment_method.PaymentMethod:
373    def deactivate(self, payment_method_id: str):
374        """Alias for disactivate().
375
376        Args:
377            payment_method_id (str): Unique identifier of the payment method.
378
379        Returns:
380            ``PaymentMethod`` decoded from the documented response shape.
381        """
382        return self.disactivate(payment_method_id)

Alias for disactivate().

Arguments:
  • payment_method_id (str): Unique identifier of the payment method.
Returns:

PaymentMethod decoded from the documented response shape.

def archive( self, payment_method_id: str) -> inttegro.payment_method.PaymentMethod:
384    def archive(self, payment_method_id: str):
385        """Archive a payment method.
386
387        API endpoint: ``/payment_methods/archive``.
388
389        Args:
390            payment_method_id (str): Unique identifier of the payment method.
391
392        Returns:
393            ``PaymentMethod`` decoded from the documented response shape.
394
395        Raises:
396            APIError: The API rejected the request or could not complete it.
397            NetworkError: The request could not reach the Inttegro API.
398            TimeoutError: The configured request deadline elapsed.
399        """
400        return 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:

PaymentMethod decoded 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.
def unarchive( self, payment_method_id: str) -> inttegro.payment_method.PaymentMethod:
402    def unarchive(self, payment_method_id: str):
403        """Unarchive a payment method.
404
405        API endpoint: ``/payment_methods/unarchive``.
406
407        Args:
408            payment_method_id (str): Unique identifier of the payment method.
409
410        Returns:
411            ``PaymentMethod`` decoded from the documented response shape.
412
413        Raises:
414            APIError: The API rejected the request or could not complete it.
415            NetworkError: The request could not reach the Inttegro API.
416            TimeoutError: The configured request deadline elapsed.
417        """
418        return 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:

PaymentMethod decoded 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.
def delete( self, payment_method_id: str, request_meta: dict[str, str] | None = None) -> inttegro.payment_method.Deletion:
420    def delete(self, payment_method_id: str, request_meta: dict | None = None):
421        """
422        Delete a saved payment method.
423
424        Permanently removes a payment method from the system. This action cannot be undone.
425        The payment method ID becomes invalid and cannot be used for future charges.
426        Use this when customers want to remove saved payment methods.
427
428        Args:
429            payment_method_id: The payment method ID to delete (e.g., "pm_xyz789")
430            request_meta: Request controls such as idempotency_key
431
432        Returns:
433            domain object confirming deletion:
434                - deleted: True if deletion succeeded
435                - payment_method_id: ID of deleted payment method
436
437        Raises:
438            ApiError: If payment method doesn't exist or deletion fails
439
440        Example:
441            ```python
442            # Delete a payment method
443            result = client.payment_methods.delete("pm_xyz789")
444            print(f"Payment method deleted: {result.payment_method_id}")
445
446            # Customer removes saved card flow
447            def remove_payment_method(customer_id, pm_id):
448                # Verify customer owns this payment method
449                pm_result = client.payment_methods.lookup(pm_id)
450                pm = pm_result
451
452                if pm["customer_id"] != customer_id:
453                    raise ValueError("Payment method doesn't belong to customer")
454
455                # Delete it
456                result = client.payment_methods.delete(pm_id)
457
458                # Remove from your database
459                delete_from_database(pm_id)
460
461                return result.deleted
462
463            # Cleanup unused payment methods
464            for pm_id in old_payment_methods:
465                try:
466                    client.payment_methods.delete(pm_id)
467                    print(f"Deleted {pm_id}")
468                except Exception as e:
469                    print(f"Failed to delete {pm_id}: {e}")
470            ```
471
472        Security Note:
473            Ensure you verify customer ownership before allowing deletion of
474            payment methods to prevent unauthorized removal.
475
476        See Also:
477            - tokenize(): Create payment methods
478            - lookup(): View payment method details
479            - https://studio.inttegro.com/api/payment-methods/delete
480        """
481        return self.http.post(
482            "/payment_methods/delete",
483            {
484                "payment_method_id": payment_method_id,
485                "request_meta": request_meta or _stable_payment_method_request_meta(
486                    "delete", payment_method_id
487                ),
488            },
489        )

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:
def settings(self) -> inttegro.payment_method.Settings:
491    def settings(self):
492        """
493        Retrieve payment method configuration and supported types.
494
495        Gets your application's payment method settings including enabled payment types,
496        supported networks, OTP requirements, and other configuration. Use this to
497        dynamically build payment forms based on what's enabled for your account.
498
499        Returns:
500            domain object containing:
501                - settings: Payment configuration including:
502                    - enabled_types: List of enabled payment types
503                    - mobile_money: Mobile money configuration:
504                        - issuers: Supported networks ("mtn", "vodafone", "airteltigo")
505                        - default_confirms_use: Default OTP requirement
506                    - cards: Card payment configuration (if enabled)
507                    - other type-specific settings
508
509        Example:
510            ```python
511            # Get payment settings
512            result = client.payment_methods.settings()
513            settings = result
514
515            # Check what's enabled
516            enabled_types = settings["enabled_types"]
517            print(f"Enabled payment types: {enabled_types}")
518
519            # Build mobile money form based on supported networks
520            if "mobile_money" in enabled_types:
521                mm_config = settings["mobile_money"]
522                print(f"Supported networks: {mm_config['issuers']}")
523                print(f"Default OTP: {mm_config['default_confirms_use']}")
524
525            # Dynamic payment form
526            def build_payment_form():
527                result = client.payment_methods.settings()
528                settings = result
529
530                form = {"payment_types": []}
531
532                if "mobile_money" in settings["enabled_types"]:
533                    form["payment_types"].append({
534                        "type": "mobile_money",
535                        "issuers": settings["mobile_money"]["issuers"]
536                    })
537
538                if "card" in settings["enabled_types"]:
539                    form["payment_types"].append({
540                        "type": "card",
541                        "brands": settings["card"]["supported_brands"]
542                    })
543
544                return form
545            ```
546
547        See Also:
548            - tokenize(): Create payment methods based on settings
549            - https://studio.inttegro.com/api/payment-methods/settings
550        """
551        return 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: