# Collection

Represent Collection Client used for collection product

| Method                                                                                           |
| ------------------------------------------------------------------------------------------------ |
| *async* [`create_access_token()`](#awaitcreate_access_token-authorization)                       |
| *async* [`get_account_balance()`](#await-get_account_balance-authorization-target)               |
| *async* [`get_account_balance_in()`](#awaitget_account_balance_in-currency-authorization-target) |
| *async* [`get_basic_user_info()`](#awaitget_basic_user_info-msisdn-authorization-target)         |
| *async* [`ask_user_info()`](#awaitask_user_info-authorization-target)                            |
| *async* [`request_to_pay()`](#await-request_to_pay-authorization-uuid-target-body-callback)      |
| *async* [`get_withdraw_status()`](#awaitget_withdraw_status-authorization-uuid-target)           |
| *async* [`withdraw()`](#await-withdraw-authorization-uuid-target-body-callback)                  |
| *async* [`isActive()`](#await-isactive-account-account_type-authorization-target)                |

### *`await`*`create_access_token( authorization )`

&#x20;  Method to create access token for collection user

#### Parameters :

* **authorization** (str) - a valid basic authentification token

#### Return

(bool, data)

{% tabs %}
{% tab title="data" %}

```json
{
  "access_token": "string",
  "token_type": "string",
  "expires_in": 0
}
```

{% endtab %}
{% endtabs %}

#### Return Type :

Tuple

### *`await`*` ``get_account_balance( authorization, target )`

Method to get balance for collection user

#### Parameters :

* **authorization** (str) - A valid bearer authentification token
* **target** (str) - The target environment

#### Return :

(bool, data)

{% tabs %}
{% tab title="data" %}

```json
{
  "availableBalance": "string",
  "currency": "string"
}
```

{% endtab %}
{% endtabs %}

#### Return Type :

Tuple

### *`await`*` ``get_account_balance_in( currency, authorization, target )`

Method to get balance in specific currency for collection user

#### Parameters :

* **currency** (str) - A valid ISO4217 Currency
* **authorization** (str) - A valid bearer authentification token
* **target** (str) - The target environment

#### Return :

(bool, data)

{% tabs %}
{% tab title="data" %}

```json
{
  "availableBalance": "string",
  "currency": "string"
}
```

{% endtab %}
{% endtabs %}

#### Return Type :

Tuple

### *`await`*` ``get_basic_user_info( msisdn, authorization, target )`

Method to get basic user info without consent for collection user

#### Parameters :

* **msisdn** (str) - The number of the user
* **authorization** (str) - A valid bearer authentification token
* **target** (str) - The target environment

#### Return :

(bool, data)

{% tabs %}
{% tab title="data" %}

```json
{
  "given_name": "string",
  "family_name": "string",
  "birthdate": "string",
  "locale": "string",
  "gender": "string",
  "status": "string"
}
```

{% endtab %}
{% endtabs %}

#### Return Type:

Tuple

### *`await`*` ``ask_user_info( authorization, target )`

Method to get user info with consent for collection user

#### Parameters :

* **authorization** (str) - A valld bearer authentification token
* **target** (str) - The target environment

#### Return :

(bool, data)

{% tabs %}
{% tab title="data" %}

```json
{
  "sub": "string",
  "name": "string",
  "given_name": "string",
  "family_name": "string",
  "middle_name": "string",
  "email": "string",
  "email_verified": true,
  "gender": "string",
  "locale": "string",
  "phone_number": "string",
  "phone_number_verified": true,
  "address": "string",
  "updated_at": 0,
  "status": "string",
  "birthdate": "string",
  "credit_score": "string",
  "active": true,
  "country_of_birth": "string",
  "region_of_birth": "string",
  "city_of_birth": "string",
  "occupation": "string",
  "employer_name": "string",
  "identification_type": "string",
  "identification_value": "string"
}
```

{% endtab %}
{% endtabs %}

#### Return Type :

Tuple

### *`await`*` ``request_to_pay( authorization, uuid, target, body, callback )`

Method to request a payment for collection user

#### Parameters :

* **authorization** (str) - A valid bearer authentification token
* **uuid** (str) - A valid UUID version 4
* **target** (str) - The target environment
* **body** (Dict) - A dictionnary with full detail of the payment \[*see detail below*]

{% tabs %}
{% tab title="body" %}
According to [MTN MOMO API](https://momodeveloper.mtn.com/docs/services/collection/operations/RequesttoPay?#requesttab1)

```json
{
  "amount": "string",
  "currency": "string",
  "externalId": "string",
  "payer": {
    "partyIdType": "MSISDN",
    "partyId": "string"
  },
  "payerMessage": "string",
  "payeeNote": "string"
}
```

{% endtab %}

{% tab title="details" %}

```json
{
  "type": "object",
  "properties": {
    "amount": {
      "type": "string",
      "description": "Amount that will be debited from the payer account."
    },
    "currency": {
      "type": "string",
      "description": "ISO4217 Currency"
    },
    "externalId": {
      "type": "string",
      "description": "External id is used as a reference to the transaction. External id is used for reconciliation. The external id will be included in transaction history report. <br>External id is not required to be unique."
    },
    "payer": {
      "type": "object",
      "properties": {
        "partyIdType": {
          "enum": [
            "MSISDN",
            "EMAIL",
            "PARTY_CODE"
          ],
          "type": "string"
        },
        "partyId": {
          "type": "string"
        }
      },
      "description": "Party identifies a account holder in the wallet platform. Party consists of two parameters, type and partyId. Each type have its own validation of the partyId<br> MSISDN - Mobile Number validated according to ITU-T E.164. Validated with IsMSISDN<br> EMAIL - Validated to be a valid e-mail format. Validated with IsEmail<br> PARTY_CODE - UUID of the party. Validated with IsUuid"
    },
    "payerMessage": {
      "type": "string",
      "description": "Message that will be written in the payer transaction history message field."
    },
    "payeeNote": {
      "type": "string",
      "description": "Message that will be written in the payee transaction history note field."
    }
  }
}
```

{% endtab %}
{% endtabs %}

* **callback** ( Optional\[str] ) - The website receiving call back

#### Return :

(bool, data)

#### Retrun Type :

Tuple

### *`await`*` ``get_withdraw_status( authorization, uuid, target )`

Method to get a withdrawal status for collection user

#### Parameters :

* **authorization** (str) - A valid bearer authentification token
* **uuid** (str) - A valid UUID version 4
* **target** (str) - The target environment

#### Return :

(bool, data)

{% tabs %}
{% tab title="data" %}
According to [MTN MOMO API](https://momodeveloper.mtn.com/docs/services/collection/operations/RequestToWithdrawTransactionStatus?#response200tab3)

```json
{
  "amount": "string",
  "currency": "string",
  "financialTransactionId": "string",
  "externalId": "string",
  "payer": {
    "partyIdType": "MSISDN",
    "partyId": "string"
  },
  "payerMessage": "string",
  "payeeNote": "string",
  "status": "PENDING",
  "reason": {
    "code": "PAYEE_NOT_FOUND",
    "message": "string"
  }
}
```

{% endtab %}
{% endtabs %}

#### Return Type:

Tuple

### *`await`*` ``withdraw( authorization, uuid, target, body, callback )`

Method to withdraw money for collection user

{% hint style="warning" %}
The library is taking in charge only Withdraw V2
{% endhint %}

#### Parameters :

* authorization (str) - A valid bearer authentification token
* uuid (str) - A valid UUID version 4
* target (str) - The target environment
* body (Dict) - A dictionnary with full detail of the payment \[[*see detail below*](/reference/api-reference/body-details.md)]
* callback ( Optional\[str] ) - The website receiving call back

#### Return :

(bool, data)

#### Return Type :

Tuple

### *`await`*` ``isActive( account, account_type, authorization, target )`

Method to check if an account is active for a collection user

#### Parameters :

* **account** (str) - The account target
* **account\_type** (str) - Specifies the type of the party ID. Allowed values \[msisdn, email, party\_code]. default set to msisdn
* **authorization** (str) - A valid bearer authentification token
* **target** (str) - The target environment

#### Return :

(bool, data)

#### Return Type :

Tuple


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://momopy.rewriteapi.cm/reference/api-reference/client/collection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
