> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.mycargoextra.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mycargoextra.com/_mcp/server.

# Top Up Wallet

POST http://localhost:9000/api/v1/billing/wallet/topup
Content-Type: application/json

Credits wallet after a supported external payment gateway transaction.

Required body fields: `amount`, `paymentGateway`, `currency`. Conditional: `reference` required for Paystack; `paymentIntentId` required for Stripe; `paymentId` required for PayPal. `currency` is code such as `NGN`, `USD`, `GBP`.

Response fields: `message`, `transactionId`, `amount`, `walletBalance`.

Possible errors:
- 400: Invalid amount - amount is missing, non-numeric, or less than 1.
- 404: User not found - authenticated customer was not found downstream.
- 404: Currency not found - supplied currency code is unknown.
- 400: Payment method is disabled - selected gateway is not active for the currency.
- 400: This transaction cannot be completed - duplicate reference/payment id detected.
- 400: Reference is required - Paystack top-up requires `reference`.
- 400: Payment Intent is required - Stripe top-up requires `paymentIntentId`.
- 400: Payment Id is required - PayPal top-up requires `paymentId`.
- 400: Missing One or More Required Parameters - required body/query fields were not supplied.
- 401: Unauthorized - token is missing, expired, invalid, or the account/token pair was not found.
- 403: Access denied - gateway traffic guard/rate policy blocked the request.
- 429: Too many requests - gateway rate limit exceeded.
- 500: Unexpected Error - unhandled gateway or downstream service failure.

Reference: https://docs.mycargoextra.com/cargo-extra-gateway-api-copy/billing/billing-wallet/topup/top-up-wallet

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: collection
  version: 1.0.0
paths:
  /api/v1/billing/wallet/topup:
    post:
      operationId: top-up-wallet
      summary: Top Up Wallet
      description: >-
        Credits wallet after a supported external payment gateway transaction.


        Required body fields: `amount`, `paymentGateway`, `currency`.
        Conditional: `reference` required for Paystack; `paymentIntentId`
        required for Stripe; `paymentId` required for PayPal. `currency` is code
        such as `NGN`, `USD`, `GBP`.


        Response fields: `message`, `transactionId`, `amount`, `walletBalance`.


        Possible errors:

        - 400: Invalid amount - amount is missing, non-numeric, or less than 1.

        - 404: User not found - authenticated customer was not found downstream.

        - 404: Currency not found - supplied currency code is unknown.

        - 400: Payment method is disabled - selected gateway is not active for
        the currency.

        - 400: This transaction cannot be completed - duplicate
        reference/payment id detected.

        - 400: Reference is required - Paystack top-up requires `reference`.

        - 400: Payment Intent is required - Stripe top-up requires
        `paymentIntentId`.

        - 400: Payment Id is required - PayPal top-up requires `paymentId`.

        - 400: Missing One or More Required Parameters - required body/query
        fields were not supplied.

        - 401: Unauthorized - token is missing, expired, invalid, or the
        account/token pair was not found.

        - 403: Access denied - gateway traffic guard/rate policy blocked the
        request.

        - 429: Too many requests - gateway rate limit exceeded.

        - 500: Unexpected Error - unhandled gateway or downstream service
        failure.
      tags:
        - >-
          subpackage_billing.subpackage_billing/billingWallet.subpackage_billing/billingWallet/topup
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/billing_billing > wallet_topup_Top Up
                  Wallet_Response_200
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PostApiV1BillingWalletTopupRequestBadRequestError
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PostApiV1BillingWalletTopupRequestUnauthorizedError
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PostApiV1BillingWalletTopupRequestForbiddenError
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PostApiV1BillingWalletTopupRequestNotFoundError
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PostApiV1BillingWalletTopupRequestTooManyRequestsError
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PostApiV1BillingWalletTopupRequestInternalServerError
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                amount:
                  type: integer
                currency:
                  type: string
                paymentId:
                  type: string
                reference:
                  type: string
                paymentGateway:
                  type: string
                paymentIntentId:
                  type: string
              required:
                - amount
                - currency
                - paymentId
                - reference
                - paymentGateway
                - paymentIntentId
servers:
  - url: http://localhost:9000
    description: http://localhost:9000
components:
  schemas:
    billing_billing > wallet_topup_Top Up Wallet_Response_200:
      type: object
      properties:
        key_0:
          type: integer
        key_1:
          type: string
        key_2:
          type: number
          format: double
        key_3:
          type: string
        key_4:
          type: boolean
      required:
        - key_0
        - key_1
        - key_2
        - key_3
        - key_4
      title: billing_billing > wallet_topup_Top Up Wallet_Response_200
    PostApiV1BillingWalletTopupRequestBadRequestError:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      title: PostApiV1BillingWalletTopupRequestBadRequestError
    PostApiV1BillingWalletTopupRequestUnauthorizedError:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      title: PostApiV1BillingWalletTopupRequestUnauthorizedError
    PostApiV1BillingWalletTopupRequestForbiddenError:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      title: PostApiV1BillingWalletTopupRequestForbiddenError
    PostApiV1BillingWalletTopupRequestNotFoundError:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      title: PostApiV1BillingWalletTopupRequestNotFoundError
    PostApiV1BillingWalletTopupRequestTooManyRequestsError:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      title: PostApiV1BillingWalletTopupRequestTooManyRequestsError
    PostApiV1BillingWalletTopupRequestInternalServerError:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      title: PostApiV1BillingWalletTopupRequestInternalServerError

```

## Examples



**Request**

```json
{
  "amount": 5000,
  "currency": "NGN",
  "paymentId": "",
  "reference": "PAYSTACK_REF_20240615_001",
  "paymentGateway": "Paystack",
  "paymentIntentId": ""
}
```

**Response**

```json
{
  "key_0": 987654,
  "key_1": "TXN20240615NGN987654",
  "key_2": 5000,
  "key_3": "Wallet credited successfully",
  "key_4": true
}
```

**SDK Code**

```python billing_billing > wallet_topup_Top Up Wallet_example
import requests

url = "http://localhost:9000/api/v1/billing/wallet/topup"

payload = {
    "amount": 5000,
    "currency": "NGN",
    "paymentId": "",
    "reference": "PAYSTACK_REF_20240615_001",
    "paymentGateway": "Paystack",
    "paymentIntentId": ""
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript billing_billing > wallet_topup_Top Up Wallet_example
const url = 'http://localhost:9000/api/v1/billing/wallet/topup';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"amount":5000,"currency":"NGN","paymentId":"","reference":"PAYSTACK_REF_20240615_001","paymentGateway":"Paystack","paymentIntentId":""}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go billing_billing > wallet_topup_Top Up Wallet_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "http://localhost:9000/api/v1/billing/wallet/topup"

	payload := strings.NewReader("{\n  \"amount\": 5000,\n  \"currency\": \"NGN\",\n  \"paymentId\": \"\",\n  \"reference\": \"PAYSTACK_REF_20240615_001\",\n  \"paymentGateway\": \"Paystack\",\n  \"paymentIntentId\": \"\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby billing_billing > wallet_topup_Top Up Wallet_example
require 'uri'
require 'net/http'

url = URI("http://localhost:9000/api/v1/billing/wallet/topup")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"amount\": 5000,\n  \"currency\": \"NGN\",\n  \"paymentId\": \"\",\n  \"reference\": \"PAYSTACK_REF_20240615_001\",\n  \"paymentGateway\": \"Paystack\",\n  \"paymentIntentId\": \"\"\n}"

response = http.request(request)
puts response.read_body
```

```java billing_billing > wallet_topup_Top Up Wallet_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("http://localhost:9000/api/v1/billing/wallet/topup")
  .header("Content-Type", "application/json")
  .body("{\n  \"amount\": 5000,\n  \"currency\": \"NGN\",\n  \"paymentId\": \"\",\n  \"reference\": \"PAYSTACK_REF_20240615_001\",\n  \"paymentGateway\": \"Paystack\",\n  \"paymentIntentId\": \"\"\n}")
  .asString();
```

```php billing_billing > wallet_topup_Top Up Wallet_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:9000/api/v1/billing/wallet/topup', [
  'body' => '{
  "amount": 5000,
  "currency": "NGN",
  "paymentId": "",
  "reference": "PAYSTACK_REF_20240615_001",
  "paymentGateway": "Paystack",
  "paymentIntentId": ""
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp billing_billing > wallet_topup_Top Up Wallet_example
using RestSharp;

var client = new RestClient("http://localhost:9000/api/v1/billing/wallet/topup");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"amount\": 5000,\n  \"currency\": \"NGN\",\n  \"paymentId\": \"\",\n  \"reference\": \"PAYSTACK_REF_20240615_001\",\n  \"paymentGateway\": \"Paystack\",\n  \"paymentIntentId\": \"\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift billing_billing > wallet_topup_Top Up Wallet_example
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "amount": 5000,
  "currency": "NGN",
  "paymentId": "",
  "reference": "PAYSTACK_REF_20240615_001",
  "paymentGateway": "Paystack",
  "paymentIntentId": ""
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:9000/api/v1/billing/wallet/topup")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```