Send Docs Feedback

Manage prepaid balances

As an alternative to a developer or company topping up (increasing) their prepaid balance through a payment provider such as WorldPay, you can top up prepaid balances with an API. You can also retrieve a prepaid balances for developers and companies. Topping up with the API is useful for testing or if developers or companies are unable to top up their accounts with a payment provider.

Toolbox

You use the monetization API to top up or retrieve prepaid balances with the following resources:

POST to top up and GET to retrieve:

  • /organizations/{org_name}/developers/{developer_id}/developer-balances
  • /organizations/{org_name}/companies/{company_id}/developer-balances

Topping up a prepaid balance using the API

To top up a developer’s prepaid balance, issue a POST request to /organizations/{org_name}/developers/{developer_id}/developer-balances, where {developer_id} is the identification of the developer. When you issue the request, you need to specify in the request body the amount to add to the balance and the currency used for the balance. For example, the following request adds $1000 to a developer's prepaid balance:

$ curl -H "Content-Type:application/json" -X POST -d \
'{
  "amount": 1000,
  "supportedCurrency": {
      "id": "usd" 
  } 
}' \
"https://api.enterprise.apigee.com/v1/mint/organizations/{org_name}/developers/{developer_id}/developer-balances" \
-u email:password

To top up a company's prepaid balance:

$ curl -H "Content-Type:application/json" -X POST -d \
'{
  "amount": 1000,
  "supportedCurrency": {
      "id": "usd" 
  } 
}' \
"https://api.enterprise.apigee.com/v1/mint/organizations/{org_name}/companies/{company_id}/developer-balances" \
-u email:password

Prepaid balance configuration settings for the API

The following prepaid balance configuration options are exposed to the API:

Name Description Default Required?
amount

The amount applied to the prepaid balance (in the applicable currency).

N/A Yes
supportedCurrency

The currency used for the prepaid balance. This is the currency that was set up for the plan in the package that the developer purchased.

N/A Yes

Retrieving balances using the API

To retrieve a developer's prepaid balance issue a GET request to /organizations/{org_name}/developers/{developer_id}/developer-balances, where {developer_id} is the identification of the developer. If the developer is a prepaid developer, the request retrieves the developer's current prepaid balance. If the developer is a postpaid developer, the request retrieves the developer's current credit limit.

For example:

$ curl -H "Accept:application/json" -X GET \
GET "https://api.enterprise.apigee.com/v1/mint/organizations/{org_name}/developers/{developer_id}/developer-balances" \
-u email:password

To retrieve a company's prepaid balance:

$ curl -H "Accept:application/json" -X GET \
GET "https://api.enterprise.apigee.com/v1/mint/organizations/{org_name}/companies/{company_id}/developer-balances" \
-u email:password

The response should look something like this (only part of the response is shown):

{
    "developerBalance": [
        {
            "amount": 2005,
            "chargePerUsage": false,
            "id": "cb8f97c5-0e49-4474-9eee-e05b8b2b2c8b",
            "isRecurring": false,
            "supportedCurrency": {
                "description": "United States Dollars",
                "displayName": "United States Dollars",
                "id": "usd",
                "name": "USD",
                "organization": {
                    "address": [
                        {
                            "address1": "10 Almaden Blvd.",
                            "city": "San Jose",
                            "country": "US",
                            "id": "32e808d8-3a3c-4d76-a0ae-17d70a982c61",
                            "isPrimary": true,
                            "state": "CA",
                            "zip": "95113"
                        }
                    ],
                    "approveTrusted": false,
                    "approveUntrusted": false,
                    "billingCycle": "CALENDAR_MONTH",
                    "country": "US",
                    "currency": "USD",
                    "description": "my-org",
                    "groupOrganization": false,
                    "hasBillingAdjustment": false,
                    "hasBroker": false,
                    "hasSelfBilling": false,
                    "hasSeparateInvoiceForProduct": false,
                    "id": "apigee-mint",
                    "issueNettingStmt": false,
                    "name": "my-org",
                    "nettingStmtPerCurrency": false,
                    "selfBillingAsExchOrg": false,
                    "selfBillingForAllDev": false,
                    "separateInvoiceForFees": false,
                    "status": "ACTIVE",
                    "supportedBillingType": "BOTH",
                    "taxModel": "HYBRID",
                    "timezone": "UTC"
                },
                "status": "ACTIVE",
                "virtualCurrency": false
            },
            "usage": 2.1572
        }
    ],
    "totalRecords": 1
}

Next steps

You can post refunds (for purchase transactions only) using monetization. Learn how in Post refunds.

Help or comments?