> For the complete documentation index, see [llms.txt](https://doc.ayobantu.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.ayobantu.com/reference/partner-api-reference/donation.md).

# Donation

This will add a donation to selected campaign from Ayobantu partner.

## Create Donation

<mark style="color:green;">`POST`</mark> `{base_url}/api/v1/partner/donation`

Submit new donation to the selected campaign

#### Headers

| Name                                           | Type   | Value                |
| ---------------------------------------------- | ------ | -------------------- |
| Accept                                         | String | application/json     |
| Authorization                                  | String | Bearer \<api\_token> |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json     |

#### Request Body

| Name                                             | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ------------------------------------------------ | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name<mark style="color:red;">\*</mark>           | String  | *John Doe* (Alpha/Numeric Only)                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| email                                            | Email   | <_johndoe@ayobantu.com> (required if is\_fundraiser is true)\_                                                                                                                                                                                                                                                                                                                                                                                                       |
| partner\_code<mark style="color:red;">\*</mark>  | String  | Provided by Ayobantu. See more, [click here](/getting-started/partner-code.md)                                                                                                                                                                                                                                                                                                                                                                                       |
| signature\_key<mark style="color:red;">\*</mark> | String  | <p>Signature code generated every time you make a request. See more, <a href="/getting-started/signature-key.md">click here</a>. <br> </p><p>Formula:</p><p><code>hash("sha512", name + phone + email + amount + is\_anonymous +  campaign\_id + partner\_code + secret\_key);</code></p><p><br>Example Output:<br><code>a2a1d0baa527318794f77122e8b35eb19c83498fb535897d58bcf0fc6a00b3c0de5a113a1d53caa748a0bdcf0b0d6fd941d1ffa6801f0bb99d370f1c83aa13db</code></p> |
| campaign\_id<mark style="color:red;">\*</mark>   | Integer | `id` is obtained from campaign submitted by partners or can be provided by Ayobantu.                                                                                                                                                                                                                                                                                                                                                                                 |
| phone<mark style="color:red;">\*</mark>          | Numeric | 0812345678 or 6287812345678                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| amount<mark style="color:red;">\*</mark>         | Numeric | 100000 (without any . or ,)                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| is\_anonymous                                    | Numeric | 0 or 1 (default 0)                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| is\_fundraiser *(Optional)*                      | Boolean | ***true*** or ***false*** (default ***false***)                                                                                                                                                                                                                                                                                                                                                                                                                      |

{% tabs %}
{% tab title="200: OK Success" %}

```json
{ 
   "status_code": "200", 
   "message": "Success", 
   "data": {
         "reference_id" : 8181,
         "amount" : 100000
   } 
}
```

{% endtab %}

{% tab title="401: Unauthorized Do not have access" %}

```json
{ 
   "status_code": "401", 
   "message": "Access denied due to unauthorized request. Please check the credentials.",   
   "erros": [ 
        "Invalid signature key"
   ] 
}
```

{% endtab %}

{% tab title="404: Not Found Resource not found" %}

```json
{ 
   "status_code": "404", 
   "message": "The requested resource is not found",   
   "erros": [ 
        "Partner not found"
   ] 
}
```

{% endtab %}

{% tab title="500: Internal Server Error Internal server error" %}

```json
{ 
   "status_code": "500", 
   "message": "Internal Server Error",   
   "erros": [ 
        "Registration failed"
   ] 
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity Unprocessable Entity (Validation Error)" %}

```json
{ 
   "status_code": "422", 
   "message": "Unprocessable Entity",   
   "erros": [ 
        "Name is required",
        "Amount is required
   ] 
}
```

{% endtab %}

{% tab title="429: Too Many Requests Too Many Attempts" %}

```json
{ 
   "status_code": "429", 
   "message": "Too Many Attempts",   
   "erros": [ 
        "Please wait 1 minute for next request"
   ] 
}
```

{% endtab %}
{% endtabs %}

{% code lineNumbers="true" %}

```
// Example Generate Signature Key 
//secret_key = '353656da-1695-434b-9f61-a3c9ff90894f';
hash("sha512", 'John Doe0812345678johndoe@example.com500000123AYB12345353656da-1695-434b-9f61-a3c9ff90894f')

//Result
a52fce4c70337fd8749c984f1c8019e3205622b01cd18fc9d3dd3b5c333307c18981a7e90454665e7b42059e4b062c9c306c18bf25da40adafd5040956eacb36

```

{% endcode %}

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

```
curl -X POST \
  {base_url}/api/v1/partner/donation \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer 88A4B7FEADD1667B' \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache' \
  -d '{
        "name"  : "John Doe",
        "phone" : "0812345678",
        "amount" : "50000",
        "email" : "johndoe@example.com",
        "partner_code" : "AYB12345",
        "signature_key" : "a52fce4c70337fd8749c984f1c8019e3205622b01cd18fc9d3dd3b5c333307c18981a7e90454665e7b42059e4b062c9c306c18bf25da40adafd5040956eacb36",
        "campaign_id"   : 123,
        "is_anonymous"    : 0,
        "is_fundraiser" : false
}'
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => {base_url}.'/api/v1/partner/donation',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "name"  : "John Doe",
    "phone" : "0812345678",
    "amount" : "50000",
    "email" : "johndoe@example.com",
    "partner_code" : "AYB12345",
    "signature_key" : "a52fce4c70337fd8749c984f1c8019e3205622b01cd18fc9d3dd3b5c333307c18981a7e90454665e7b42059e4b062c9c306c18bf25da40adafd5040956eacb36",
    "campaign_id"   : 123,
    "is_anonymous"    : 0,
    "is_fundraiser"   : false
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer 88A4B7FEADD1667B',
    'Accept: application/json',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}

{% tab title="Go" %}

<pre class="language-go"><code class="lang-go"><strong>package main
</strong>
import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := {base_url}+"/api/v1/partner/donation"
  method := "POST"

  payload := strings.NewReader(`{
    "name"  : "John Doe",
    "phone" : "0812345678",
    "amount" : "50000",
    "email" : "johndoe@example.com",
    "partner_code" : "AYB12345",
    "signature_key" : "a52fce4c70337fd8749c984f1c8019e3205622b01cd18fc9d3dd3b5c333307c18981a7e90454665e7b42059e4b062c9c306c18bf25da40adafd5040956eacb36",
    "campaign_id"   : 123,
    "is_anonymous"    : 0,
    "is_fundraiser"   : false
}`)

  client := &#x26;http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "Bearer 88A4B7FEADD1667B")
  req.Header.Add("Accept", "application/json")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

</code></pre>

{% endtab %}
{% endtabs %}
