# Cash-in from a Mini App

As a Maya Mini App partner, you can leverage Maya's <a href="/docs/cash-in-to-maya-wallet" target="_blank" style="text-decoration:none;">**Cash-in** <img class="icon-redirect"/></a> to offer your customers a seamless way to transfer funds directly into their Maya wallet.

[block:html]
{
  "html": "<style>\n  details.steps[open] summary.steps details.others[open] summary.others~ * {\n    animation: open 0.3s ease-in-out;\n  }\n  \n  @keyframes open {\n    0% {\n      opacity: 0;\n    }\n    100% {\n      opacity: 1;\n    }\n  }                                            \n  \n  details.steps summary.steps details.others summary.others::-webkit-details-marker {\n    display: none;\n  }                                                \n  \n  details.steps summary.steps {\n    cursor: pointer;\n    /**font-size: 1.25rem;**/\n    font-weight: 300;\n    list-style: none;\n    padding: 0.1rem 0;\n    position: relative;\n    width: 100%;\n  }\n  \n  details.steps summary.steps:after {\n    color: #270E7A;\n    content: \"Read more\";\n    /**font-size: 1.75rem;**/\n    font-weight: 200;\n    line-height: 0;\n    margin-top: 0.02rem;\n    position: absolute;\n    right: 0;\n    transform-origin: center;\n    transition: 200ms linear;\n  }\n  \n  details.steps[open] summary.steps:after {\n    content: \"X\";\n  }  \n\n  details.steps summary.steps details.others summary.others {\n    outline: 0;\n  }                                                                   \n  \n  details.others summary.others {\n    border: none !important;\n    cursor: pointer;\n    font-size: 1.25rem;\n    font-weight: 300;\n    list-style: none;\n    outline: 0;\n    padding: 0.1rem 0;\n    position: relative;\n    width: 100%;\n  }\n  \n  details.others summary.others:after {\n    color: black;\n    content: \"+\";\n    font-size: 1.75rem;\n    font-weight: 200;\n    line-height: 0;\n    --margin-top: 0rem;\n    margin-bottom: 0.5rem;\n    position: absolute;\n    top: 15px;\n    right: 0;\n    transform-origin: center;\n    transition: 200ms linear;\n  }\n  \n  details.others[open] summary.others:after {\n    /**font-size: 2rem;**/\n    transform: rotate(45deg);\n  }\n  \n  /*Custome style for detail expand*/\n  .genericExpand {\n    background-color: #FFFFFF;\n  }\n  \n  .genericExpand.steps {\n    background-color: #FFFFFF;\n    /**border: 1px solid #797C7A;**/\n    border: none !important;\n    padding: 0;\n    margin: 0;\n  }\n  \n  .genericExpand.others {\n    background-color: #FFFFFF;\n    border: none !important;\n    border-radius: 0 !important;;\n    border-bottom: 2px solid #e7e7e7 !important;\n  }\n  \n  .divExpand {\n    background-color: #FFFFFF;\n    border: 1px solid #797C7A;\n    border-radius: 5px;\n    padding: 0 10px 12px 10px;\n    margin: 0;\n  } \n  \n  .top-border {\n    border-top: 2px solid #e7e7e7 !important;\n  }\n  \n  img {\n    display: block !important;\n  }\n\n  .icon-redirect {\n    display: inline !important;\n  }\n  \n</style>"
}
[/block]

<div class="note-yellow">

This solution requires complete implementation of the <a href="/reference/maya-mini-app" target="_blank" style="text-decoration:none;">**Maya Mini App** <img class="icon-redirect"/></a>.

</div>

<br />

<div class="divExpand">

# API Sequence

<section>
<details class="genericExpand steps" id="read-more-cash-in-mma-api-sequence">
<summary class="steps">

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/5b86eee2da1fb8ada39d20fc91150605ba664fad3137da627c83d1e43f06109a-cash-in-from-mini-app-api-sequence.png",
        "",
        ""
      ],
      "align": "center",
      "sizing": "90% "
    }
  ]
}
[/block]

<br />

</summary>

<br />

<div class="note-yellow" style="background-color: #fdfaf0">

This solution requires the Customer Access Token (`accessToken`), which you will obtain during session initiation as part of the full implementation of the Maya Mini App. For more details, please refer to the <a href="/reference/maya-mini-app" target="_blank" style="text-decoration:none;">**Maya Mini App** <img class="icon-redirect"/></a> guide.

</div>

<br />

1. The customer initiates a Cash-in to their Maya wallet through the API Consumer using a web view within the Maya App.
2. The API Consumer prepares the valid token. Refer to the <a href="/docs/maya-mini-apps-technical-guide" target="_blank" style="text-decoration:none;">**Maya Mini App** <img class="icon-redirect"/></a> for more details.
3. The API Consumer calls the <a href="/reference/initiateusingpost" target="_blank" style="text-decoration:none;">**Initiate a Transfer** <img class="icon-redirect"/></a> endpoint of Maya Cash-in using the **Customer Access Token** (`accessToken`) in Maya.
4. Maya Cash-in creates the transfer intent in Maya, uniquely identified by a `transferId`.
5. Maya Cash-in responds to the API Consumer with the generated transferId in Maya.
6. The API Consumer saves the `transferId` acquired from Maya.
7. The API Consumer calls the <a href="/reference/executeusingput" target="_blank" style="text-decoration:none;">**Execute Transfer** <img class="icon-redirect"/></a> endpoint of Maya, providing the `transferId` associated with the transfer intent in Maya.
8. Maya Cash-in processes the transfer intent in Maya.
9. If successful or failed, Maya Cash-in responds with the result.
10. If the API Consumer receives an <a href="/reference/business-rules-to-code-for-cash-in#handling-of-ambiguous-errors-in-cash-in-to-maya-wallet" target="_blank" style="text-decoration:none;">**ambiguous error** <img class="icon-redirect"/></a> or no response from Maya Cash-in:
    * API Consumer calls the <a href="/reference/retrieveusingget_1" target="_blank" style="text-decoration:none;">**Retrieve a Transfer** <img class="icon-redirect"/></a> endpoint of Maya providing the `transferId` in Maya.
    * Maya Cash-in returns the details of the transfer intent associated with the `transferId` in Maya.
11. The API Consumer notifies the customer of the status.

</details>
</section>

</div>

***

# Build your Integration

<div class="note-yellow" style="background-color: #fdfaf0">

This solution uses **Basic Authentication**, which requires **API keys** to authenticate incoming requests. To obtain your API key, please refer to the <a href="/reference/basic-authentication#c-acquire-from-your-maya-relationship-manager" target="_blank" style="text-decoration:none;"><b>Acquire Keys from Relationship Manager</b> <img class="icon-redirect"/></a> guide.

</div>

<div class="divExpand">

## Create the required pages

<section>
<details class="genericExpand steps" id="read-more-cash-in-mma-create-pages">
<summary class="steps">

Design and host your mini app or webview pages.

</summary>

<br />

Based on your envisioned customer journey, design and create a button within your page for your customers to initiate the Cash-in transaction.

</details>
</section>

</div>

<div class="divExpand">

## Initiate and execute a Cash-in transaction

<section>
<details class="genericExpand steps" id="read-more-cash-in-mma-initiate-execute">
<summary class="steps">

Use customer `accessToken` from the Maya Mini App to initiate and execute a Cash-in to Maya wallet.

</summary>

<br />

When implementing **Maya Mini App**, your Mini App shall be able to utilize the **Customer Access Token** or the `accessToken` obtained from Maya through your <a href="/reference/maya-mini-app#manage-mini-app-session-new-customer-session" target="_blank" style="text-decoration:none;">**session URL** <img class="icon-redirect"/></a> or acquired by <a href="/reference/maya-mini-app#manage-mini-app-session-expired-customer-session" target="_blank" style="text-decoration:none;">**refreshing the tokens** <img class="icon-redirect"/></a>, whichever is the most recent or valid value.

Once your application has acquired the Customer Access Token (`accessToken`) from Maya, you may proceed with the following steps.

***

### Step 1: Initiate Transfer

<div class="note-yellow">

Any requests using an expired Customer Access Token (`accessToken`) will result in an **error**.

Be sure to use a **valid** `accessToken` and request a **new** `accessToken` as needed. Refer to the <a href="/reference/maya-mini-app#manage-mini-app-session-expired-customer-session" target="_blank" style="text-decoration:none;">**Manage Mini App Session: Expired Customer Session** <img class="icon-redirect"/></a> for the handling of expired `accessToken`.

</div>

<br />

Initiate the Cash-in by calling the <a href="/reference/initiateusingpost" target="_blank" style="text-decoration:none;">**Initiate a Transfer** <img class="icon-redirect"/></a> endpoint of Maya. Each transfer attempt creates a **new intent** and is assigned a unique `transferId` in Maya. Maya recommends generating a unique request reference number for each transfer.

Note that Maya's `transferId` will be used to ensure the idempotency of the transfer intent during execution.

<div class="note-yellow">

At present, there is **no time restriction** for executing a transfer intent after it has been created. However, if you choose not to proceed, you can discard the `transferId` and handle the customer management on your end.

**NOTE**: *Change in this behavior may be imposed in the future.*

</div>

<br />

At this stage, **no funds are moved** within Maya. This provides you ample time to validate transfer details, including recipient information, potential fees, and other relevant factors.

[block:tutorial-tile]
{
  "backgroundColor": "#018FF4",
  "emoji": "📖",
  "id": "6a6196383c739db831fe2c75",
  "link": "https://developers.maya.ph/v6.00/recipes/initiate-cash-in-using-maya-mini-apps-token",
  "slug": "initiate-cash-in-using-maya-mini-apps-token",
  "title": "Initiate Cash-in using Maya Mini Apps Token"
}
[/block]

***

### Step 2: Execute Transfer

After creating the intent to transfer in Maya, proceed by calling the <a href="/reference/executeusingput" target="_blank" style="text-decoration:none;">**Execute Transfer** <img class="icon-redirect"/></a> endpoint of Maya with the provided `transferId`. Triggering the Execute Transfer of Maya finalizes the request and authorizes the balance movement in Maya.

<div class="note-yellow">

Execution of a particular transfer in Maya can only be done **ONCE**. Whether `APPROVED` or `DECLINED`, succeeding execution in Maya will return an error.

</div>

<br />

At this stage, **funds are moved** from your account in Maya to the customer’s Maya wallet.

[block:tutorial-tile]
{
  "backgroundColor": "#018FF4",
  "emoji": "📖",
  "id": "6a6196383c739db831fe2c76",
  "link": "https://developers.maya.ph/v6.00/recipes/execute-a-transfer-intent",
  "slug": "execute-a-transfer-intent",
  "title": "Execute a Transfer Intent"
}
[/block]

</details>
</section>

</div>

<div class="divExpand">

## Monitor the Cash-in transaction

<section>
<details class="genericExpand steps" id="read-more-cash-in-mma-monitor">
<summary class="steps">

Monitoring the Cash-in transaction in Maya.

</summary>

<br />

### As a Cash-in partner

Maya's Cash-In solution does not support webhooks. Instead, the cash-in endpoint handles the transaction synchronously, and the final status is returned directly in the response.

In cases where a timeout or an [**uncertain error**](https://developers.maya.ph/reference/business-rules-to-code-for-cash-in#handling-of-ambiguous-errors-in-cash-in-to-maya-wallet) occurs, you can verify the transaction status by calling Maya’s [**Retrieve a Transfer**](https://developers.maya.ph/reference/retrieveusingget_1) endpoint using the `transferId`. This allows you to confirm whether the transaction was successfully processed.

#### Refer to the Code Recipe below to guide you in building the request:

[block:tutorial-tile]
{
  "backgroundColor": "#018FF4",
  "emoji": "📖",
  "id": "6a6196383c739db831fe2c77",
  "link": "https://developers.maya.ph/v6.00/recipes/retrieve-a-transfer-intent",
  "slug": "retrieve-a-transfer-intent",
  "title": "Retrieve a Transfer Intent"
}
[/block]

***

### As a Maya Wallet user

Customers will be notified via SMS from Maya or the Maya mobile app notification. They can view the Cash-in transaction in the **Transaction List within the Maya App**.

</details>
</section>

</div>

<div class="divExpand">

## Monitor Your Funding Account Balance

<section>
<details class="genericExpand steps" id="read-more-cash-in-mma-balance">
<summary class="steps">

Monitor your Funding Account Balance in Maya.

</summary>

<br />

To monitor your funding account balance in real time and ensure you have sufficient funds for cash-in transactions, refer to the [**Retrieving Your Funding Account Balance**](/reference/retrieving-your-funding-account-balance) guide.

</details>
</section>

</div>

<div class="note-green">

Refer to <a href="/reference/payments-via-maya-mini-app" target="_blank" style="text-decoration:none;">**Payments via Mini App** <img class="icon-redirect"/></a> to implement payments in the Maya Mini App.

</div>

***

# Endpoints

The following are the endpoints relevant for **Cash-in using Maya Mini App Token**.

[block:parameters]
{
  "data": {
    "h-0": "Name",
    "h-1": "HTTP Method",
    "h-2": "Key Type",
    "h-3": "Endpoint",
    "h-4": "Description",
    "0-0": "**Initiate Transfer**",
    "0-1": "<span class=\"methodPost\">POST</span>",
    "0-2": "<span class=\"statusOptional\">SECRET</span>",
    "0-3": "<a href=\"/reference/initiateusingpost\" target=\"_blank\" style=\"text-decoration:none;\">/transfers</a>",
    "0-4": "Creates a transfer intent in Maya. Generates a `transferId`",
    "1-0": "**Execute Transfer**",
    "1-1": "<span class=\"methodPut\">PUT</span>",
    "1-2": "<span class=\"statusOptional\">SECRET</span>",
    "1-3": "<a href=\"/reference/executeusingput\" target=\"_blank\" style=\"text-decoration:none;\">/transfers/{transferId}/execute</a>",
    "1-4": "Processes a transfer intent on Maya associated with the `transferId`",
    "2-0": "**Retrieve a Transfer**",
    "2-1": "<span class=\"methodGet\">GET</span>",
    "2-2": "<span class=\"statusOptional\">SECRET</span>",
    "2-3": "<a href=\"/reference/retrieveusingget_1\" target=\"_blank\" style=\"text-decoration:none;\">/transfers/{transferId}</a>",
    "2-4": "Get the transfer intent in Maya associated with the `transferId`",
    "3-0": "**Retrieve Balance**",
    "3-1": "<span class=\"methodGet\">GET</span>",
    "3-2": "<span class=\"statusOptional\">SECRET</span>",
    "3-3": "<a href=\"/reference/retrievebalanceusingget\" target=\"_blank\" style=\"text-decoration:none;\">/balance</a>",
    "3-4": "Retrieve your funding account balance in real time"
  },
  "cols": 5,
  "rows": 4,
  "align": [
    "left",
    "left",
    "left",
    "left",
    "left"
  ]
}
[/block]

***

# Business Rules to Code

To supplement your knowledge of the integration, it is essential to read the following business rules:

* <a href="/reference/business-rules-to-code-for-maya-mini-apps" target="_blank" style="text-decoration:none;">**Business Rules to Code for Maya Mini Apps** </a>
* <a href="/reference/business-rules-to-code-for-cash-in" target="_blank" style="text-decoration:none;">**Business Rules to Code for Cash-in** </a>

This ensures that technology requirements and other development considerations are met.

***

<div class="note-green">

At this point, you have understood the following:

* The necessary APIs and their endpoints
* The sequence and purpose of each API
* The prerequisites for building your integration

</div>

<br />

***

<div class="faq-tag">

# Frequently Asked

</div>

<div class="faq-container">

<section>

<details class="genericExpand faqs" id="read-more-cash-in-mma-access-token-expires">
<summary class="faqs"><b>What to do when customer's <code>accessToken</code> expires?</b></summary>

<div class="faq-answer">

**Answer:** Your platform must request to generate a **new** Customer Access Token (`accessToken`) from the Maya endpoints. See the <a href="/reference/maya-mini-app#manage-mini-app-session-expired-user-session" target="_blank" style="text-decoration:none;">**Manage Mini App Session: Expired User Session** <img class="icon-redirect"/></a> for more details.

</div></details>

<details class="genericExpand faqs" id="read-more-cash-in-mma-transfer-expiry">
<summary class="faqs"><b>Is there an expiry on for transfer intent?</b></summary>

<div class="faq-answer">

**Answer:** **No expiry** is implemented to the transfer intent in Maya. However, please note that a change in this behavior may be imposed in the future.

</div></details>

<details class="genericExpand faqs" id="read-more-faq-errors">
<summary class="faqs"><b>My transaction in Sandbox keeps failing. How can I fix this?</b></summary>

<div class="faq-answer">

**Answer:** First, ensure your code is implemented correctly by reviewing the required steps. If your setup is correct but errors persist, check the <a href="/page/sandbox-health" target="_blank" style="text-decoration:none;">**Sandbox Health Page** <img class="icon-redirect"/></a> to verify if the service is operational. If the service is up, retrieve the error code and use the **search box in the Maya Developer Hub** to find relevant guides on resolving it.

</div></details>

<details class="genericExpand faqs" id="read-more-faq-timeouts">
<summary class="faqs"><b>Getting timeouts when connecting to the Sandbox of Maya. How can we resolve this?</b></summary>

<div class="faq-answer">

**Answer:** If you're encountering timeouts in the Sandbox, first check the <a href="/page/sandbox-health" target="_blank" style="text-decoration:none;">**Sandbox Health Page** <img class="icon-redirect"/></a> to see if the service is operational. If the service is up but the issue persists, visit our <a href="/docs/support" target="_blank" style="text-decoration:none;">**Support Page** <img class="icon-redirect"/></a> for the appropriate channel to escalate your concern.

</div></details>

</section>

</div>