# S2S MoMo (KES and GHS)

## Initiate S2S

<table><thead><tr><th width="224">Authorization</th><th>Set to Bearer PUBLIC_KEY</th></tr></thead><tbody><tr><td>Content-Type</td><td>Set value to <code>application/json</code></td></tr></tbody></table>

{% hint style="info" %}
The public key can be gotten from the 'Settings' page on your Startbutton dashboard.
{% endhint %}

Post a request to the URL below, where the base URL is determined by the environment you are in.

<details>

<summary>BaseUrl</summary>

Sandbox/PROD : <https://api.startbutton.tech&#x20>;

</details>

{% tabs %}
{% tab title="Endpoint" %}
POST  `{{baseurl}}/transaction/initialize/s2s/mobile_money`
{% endtab %}
{% endtabs %}

Here's a sample request below

{% hint style="info" %}
Find numbers here to simulate test [here](https://startbutton.gitbook.io/startbutton-product-api/test-numbers/test-numbers-for-collections#test-numbers-for-s2s-collection)
{% endhint %}

{% tabs %}
{% tab title="Required parameters (KES)" %}

```
{
    "provider": "mpesa",
    "phone": "+254710000000",
    "email": "kass1-pms@customer.com",
    "amount": 3000,
    "currency": "KES"
}
```

{% endtab %}

{% tab title="Optional parameters included (KES)" %}

```
{
    "provider": "mpesa",
    "phone": "+254710000000",
    "email": "kass1-pms@customer.com",
    "amount": 3000,
    "currency": "KES",
    "reference": "de432cr4d34e"
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Required parameters (GHS)" %}

```
{
    "provider": "MTN",
    "phone": "0551234987",
    "amount": 300000,
    "currency": "GHS",
    "email": "test-pms@customer.com"
}
```

{% hint style="info" %}
We have 3 providers for GHS:\
\- MTN- passed as "MTN"\
\- AIRTEL passed as "ATL"\
\-  VODAFONE- passed as "VOD"
{% endhint %}
{% endtab %}

{% tab title="Optional parameters included (GHS)" %}

```
{
    "provider": "MTN",
    "phone": "0551234987",
    "amount": 300000,
    "currency": "GHS",
    "reference": "de432cr4d34e",
    "email": "test-pms@customer.com"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
The amount should be in fractional units.
{% endhint %}

Here's a sample response

{% tabs %}
{% tab title="Success (GHS)" %}

```json
{
    "success": true,
    "message": "Charge attempted, requery to get status",
    "data": {
        "nextStep": "PIN",
        "reference": "610ae86889ee"
    }
}
```

{% endtab %}

{% tab title="Success (KES)" %}

```
{
    "success": true,
    "message": "Charge attempted, requery to get status",
    "data": {
        "nextStep": "PIN",
        "reference": "42452be51db0"
    }
}
```

{% endtab %}

{% tab title="Failed" %}

```
{
    "success": false,
    "message": "unknown provider"
}
```

{% endtab %}
{% endtabs %}

The next step can either be OTP or PIN. If your customer is new to the service, they'll receive an OTP initially. Afterwards, for subsequent transactions, they'll be provided with a PIN.

When it is an OTP; you need to present the User with a screen to enter OTP and then call the endpoint below

## OTP Verify

{% tabs %}
{% tab title="Endpoint" %}
POST `{{baseurl}}/transaction/initialize/s2s/mobile_money/otp-verify`
{% endtab %}
{% endtabs %}

<table><thead><tr><th width="224">Authorization</th><th>Set to Bearer PUBLIC_KEY</th></tr></thead><tbody><tr><td></td><td></td></tr></tbody></table>

Here's a sample response

{% tabs %}
{% tab title="Verify OTP" %}

```
{
  "reference": "610ae86889ee",
  "otp": "123456"
}
```

{% endtab %}
{% endtabs %}

Here's a sample response

{% tabs %}
{% tab title="Success Response" %}

```
{
    "status": true,
    "message": "Charge attempted",
    "data": {
        "status": "requery",
        "message": "Confirming payment"
    }
}
```

{% endtab %}

{% tab title="Failed Response" %}

```
{
    "success": false,
    "message": "Invalid OTP",
    "data": null
}
```

{% endtab %}
{% endtabs %}

However, if the next step is a PIN your users only need to enter their PIN on the prompt on their phone.


---

# 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://startbutton.gitbook.io/startbutton-product-api/startbutton-api-doc/server-to-server-integration/s2s-integration-for-mobile-money/s2s-momo-kes-and-ghs.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.
