Obtain a payment method ID

In order to make a payment you should provide an ID of the payment method you want to use. We provide Payment Methods API to get a list of payment methods you added to your wallet in the Maroo app.

curl --request GET \
     --url https://api.maroo.us/v1/payment_methods \
     --header "accept: application/json" \
     --header "authorization: Bearer $API_TOKEN"
{
  "timestamp": "2023-11-30T20:19:52.935Z",
  "data": {
    "items": [
      {
        "id": "ecac18e9-9ae6-4f25-a048-3777b2eba10d",
        "type": "CreditCard",
        "name": {
          "brand": "visa",
          "last4": "4242"
        }
      },
      {
        "id": "3a3f9174-8c06-41c7-a30e-0c7107e83f2c",
        "type": "DebitCard",
        "name": {
          "brand": "visa",
          "last4": "5556"
        }
      },
      {
        "id": "376a8645-eb5e-4ee4-ba1c-f87ac3feb128",
        "type": "BankAccount",
        "name": {
          "bankName": "REGIONS BANK",
          "last4": "0000"
        }
      }
    ]
  },
  "error": null
}

These IDs could be used to specify a payment method to make a payment. You can save IDs to the configuration file of your application, or provide it as environment variables.

Note that if you delete a payment method from your wallet in the Maroo app and reconnect it again, the ID will be changed.

Make a payment

Assume we have a payment method ID of the bank account stored in the PRIMARY_PAYMENT_METHOD_ID environment variable. Let's make an API request to create a new payment:

PRIMARY_PAYMENT_METHOD_ID=376a8645-eb5e-4ee4-ba1c-f87ac3feb128

curl --request POST \
     --url https://api.maroo.us/v1/payments \
     --header "accept: application/json" \
     --header "authorization: Bearer $API_TOKEN" \
     --header "content-type: application/json" \
     --data "
{
  \"totalAmount\": 180000,
  \"scheduleDate\": \"2024-01-01\",
  \"paymentMethodId\": \"${PRIMARY_PAYMENT_METHOD_ID}\",
  \"note\": \"Wedding Photography Services\"
}
"