Don’t miss our Special Offer!

Up to 50% off
Grab Amelia
Grab Amelia

Amelia API – Payments

Here you can see API endpoints related to payments.

You can see all the API endpoints with examples of requests and responses in the Amelia API Postman collection which you can download here.

Please note: The API Endpoints are included only in the Elite license plans. Using API Endpoints requires a certain level of coding skills, and is not included in the provided support for the plugin.

Authorization

All Amelia endpoints use an API key authorization, using the header property named “Amelia”.

Path

Amelia API paths start with: {{your_site_URL}}/wp-admin/admin-ajax.php?action=wpamelia_api&call=/api/v1

Add payment

Add a payment to a booking.

Method

This endpoint accepts POST requests.

Path

/payments

Required Properties

The following properties are required.

Key Type Description
customerBookingId integer The booking ID to attach the payment to.
amount number The amount of the payment.
gateway string The gateway of the payment. Possible values:
‘onSite’, ‘payPal’, ‘stripe’, ‘wc’, ‘mollie’, ‘razorpay’
status string The status of the payment. Possible values:
‘paid’, ‘pending’, ‘partiallyPaid’, ‘refunded’
packageCustomerId integer The id of the package customer object. Required if the payment will be related to a package.
entity string Entity type. Possible values:
appointment, event, package

Other Properties

Key Type Description
dateTime string The date and time when the payment was made or will be made (right now for online payment methods, booking date for on-site payments).
In the format: “YYYY-MM-DD HH:mm”
gatewayTitle string Specific gateway title when using WooCommerce. Examples:
Stripe, Cash on Delivery, Bank transfer
actionsCompleted boolean Whether post-booking actions were completed.
wcOrderId integer WooCommerce order ID.
transactionId string The online gateway transaction ID. Used for refund action, when not using WooCommerce.

Example

curl --location 'http://localhost/amelia/wp-admin/admin-ajax.php?action=wpamelia_api&call=/api/v1/payments' \
--data '{
    "customerBookingId": 268,
    "amount": 10,
    "dateTime": "2023-05-05 15:00:00",
    "status": "paid",
    "gateway": "stripe",
    "data": {},
    "packageCustomerId": null,
    "entity": "appointment"
}'

{
    "message": "New payment successfully created.",
    "data": {
        "payment": {
            "id": null,
            "customerBookingId": 268,
            "packageCustomerId": null,
            "parentId": null,
            "amount": 10,
            "gateway": "stripe",
            "gatewayTitle": "",
            "dateTime": "2023-05-05 15:00:00",
            "status": "paid",
            "data": "[]",
            "entity": "appointment",
            "created": null,
            "actionsCompleted": null,
            "wcOrderId": null,
            "wcOrderUrl": null,
            "wcItemCouponValue": null,
            "wcItemTaxValue": null
        }
    }
}

Update payment

Update payment details.

Method

This endpoint accepts POST requests.

Path

/payments/{{payment_id}}

Optional Properties

Send only the properties you would like to update.

Key Type Description
customerBookingId integer The booking ID to attach the payment to.
amount number The amount of the payment.
gateway string The gateway of the payment. Possible values:
‘onSite’, ‘payPal’, ‘stripe’, ‘wc’, ‘mollie’, ‘razorpay’
status string The status of the payment. Possible values:
‘paid’, ‘pending’, ‘partiallyPaid’, ‘refunded’
packageCustomerId integer The id of the package customer object. Required if the payment will be related to a package.
entity string Entity type. Possible values:
appointment, event, package
dateTime string The date and time when the payment was made or will be made (right now for online payment methods, booking date for on-site payments).
In the format: “YYYY-MM-DD HH:mm”
gatewayTitle string Specific gateway title when using WooCommerce. Examples:
Stripe, Cash on Delivery, Bank transfer
actionsCompleted boolean Whether post-booking actions were completed.
wcOrderId integer WooCommerce order ID.
transactionId string The online gateway transaction ID. Used for refund action, when not using WooCommerce.

Example

curl --location 'http://localhost/amelia/wp-admin/admin-ajax.php?action=wpamelia_api&call=/api/v1/payments/280' \
--data '{
    "customerBookingId": 268,
    "amount": 15,
    "dateTime": "2023-05-05 15:00:00",
    "status": "paid",
    "gateway": "stripe",
    "gatewayTitle": null,
    "data": null,
    "packageCustomerId": null,
    "entity": "appointment",
    "actionsCompleted": 1,
    "wcOrderId": null,
    "transactionId": null
}'
{
    "message": "Payment successfully updated.",
    "data": {
        "payment": {
            "id": null,
            "customerBookingId": 268,
            "packageCustomerId": null,
            "parentId": null,
            "amount": 15,
            "gateway": "stripe",
            "gatewayTitle": "",
            "dateTime": "2023-05-05 15:00:00",
            "status": "paid",
            "data": "",
            "entity": null,
            "created": null,
            "actionsCompleted": null,
            "wcOrderId": null,
            "wcOrderUrl": null,
            "wcItemCouponValue": null,
            "wcItemTaxValue": null
        }
    }
}

Get payment

Retrieve payment details.

Method

This endpoint accepts GET requests.

Path

/payments/{{payment_id}}

Example

curl --location 'http://localhost/amelia/wp-admin/admin-ajax.php?action=wpamelia_api&call=/api/v1/payments/312' \
--header 'Amelia: qUmkNNOLrWbf28izIgNnZ29O+7gVWL5M+8ySJ8VXq3r0'
{
    "message": "Successfully retrieved payment.",
    "data": {
        "payment": {
            "id": 312,
            "customerBookingId": 268,
            "packageCustomerId": null,
            "parentId": null,
            "amount": 10,
            "gateway": "onSite",
            "gatewayTitle": "",
            "dateTime": "2023-05-05 13:00:00",
            "status": "paid",
            "data": "",
            "entity": "appointment",
            "created": "2023-05-05 11:18:32",
            "actionsCompleted": null,
            "wcOrderId": null,
            "wcOrderUrl": null,
            "wcItemCouponValue": null,
            "wcItemTaxValue": null
        }
    }
}

Get payments

Retrieve payments details.

Method

This endpoint accepts GET requests.

Path

/payments

Query Parameters

You can use the following query parameters:

Key Type Description
dates string Beginning and end date to filter payments response
page integer Page of the results. Limit is set in Amelia settings.

Example

curl --location 'http://localhost/amelia/wp-admin/admin-ajax.php?action=wpamelia_api&call=/api/v1/payments&page=1&dates=2023-05-05,2023-05-06' \
--header 'Amelia: qUmkNNOLrWbf28izIgNnZ29O+7gVWL5M+8ySJ8VXq3r0'
{
    "message": "Successfully retrieved payments.",
    "data": {
        "payments": [
            {
                "id": 234,
                "dateTime": "2023-05-05 11:00:00",
                "bookingStart": "2023-05-05 11:00:00",
                "status": "pending",
                "wcOrderId": null,
                "gateway": "onSite",
                "gatewayTitle": "",
                "name": "free service",
                "customerBookingId": 196,
                "packageCustomerId": null,
                "amount": 0,
                "providers": [
                    {
                        "id": 3,
                        "fullName": "Milica2 Employee2",
                        "email": "[email protected]"
                    }
                ],
                "customerId": 11,
                "serviceId": 6,
                "appointmentId": 128,
                "packageId": null,
                "bookedPrice": 10,
                "bookableName": "free service",
                "customerFirstName": "Amelia",
                "customerLastName": "Test",
                "info": "{\"firstName\":\"Amelia\",\"lastName\":\"Test\",\"phone\":null,\"locale\":\"en_US\",\"timeZone\":\"Europe\\/Belgrade\",\"urlParams\":null}",
                "customerEmail": "[email protected]",
                "coupon": null,
                "persons": 1,
                "aggregatedPrice": 1,
                "bookingExtrasSum": 0,
                "secondaryPayments": []
            },
            {
                "id": 260,
                "dateTime": "2023-05-05 11:00:00",
                "bookingStart": "2023-05-05 11:00:00",
                "status": "pending",
                "wcOrderId": null,
                "gateway": "onSite",
                "gatewayTitle": "",
                "name": "milica service",
                "customerBookingId": 219,
                "packageCustomerId": null,
                "amount": 0,
                "providers": [
                    {
                        "id": 1,
                        "fullName": "Milica Employee",
                        "email": "[email protected]"
                    }
                ],
                "customerId": 17,
                "serviceId": 2,
                "appointmentId": 144,
                "packageId": null,
                "bookedPrice": 100,
                "bookableName": "milica service",
                "customerFirstName": "Avatar",
                "customerLastName": "Last Airbender",
                "info": null,
                "customerEmail": "[email protected]",
                "coupon": null,
                "persons": 1,
                "aggregatedPrice": 1,
                "bookingExtrasSum": 0,
                "secondaryPayments": []
            },
            {
                "id": 261,
                "dateTime": "2023-05-05 11:00:00",
                "bookingStart": "2023-05-05 11:00:00",
                "status": "pending",
                "wcOrderId": null,
                "gateway": "onSite",
                "gatewayTitle": "",
                "name": "milica service",
                "customerBookingId": 220,
                "packageCustomerId": null,
                "amount": 0,
                "providers": [
                    {
                        "id": 1,
                        "fullName": "Milica Employee",
                        "email": "[email protected]"
                    }
                ],
                "customerId": 8,
                "serviceId": 2,
                "appointmentId": 144,
                "packageId": null,
                "bookedPrice": 100,
                "bookableName": "milica service",
                "customerFirstName": "Kim",
                "customerLastName": "KibBum",
                "info": null,
                "customerEmail": "[email protected]",
                "coupon": null,
                "persons": 1,
                "aggregatedPrice": 1,
                "bookingExtrasSum": 0,
                "secondaryPayments": []
            },
            {
                "id": 257,
                "dateTime": "2023-05-05 12:00:00",
                "bookingStart": "2023-05-05 12:00:00",
                "status": "pending",
                "wcOrderId": null,
                "gateway": "onSite",
                "gatewayTitle": "",
                "name": "new service",
                "customerBookingId": 216,
                "packageCustomerId": null,
                "amount": 0,
                "providers": [
                    {
                        "id": 1,
                        "fullName": "Milica Employee",
                        "email": "[email protected]"
                    }
                ],
                "customerId": 5,
                "serviceId": 7,
                "appointmentId": 142,
                "packageId": null,
                "bookedPrice": 33.44,
                "bookableName": "new service",
                "customerFirstName": "Milica",
                "customerLastName": "Test",
                "info": null,
                "customerEmail": "[email protected]",
                "coupon": null,
                "persons": 3,
                "aggregatedPrice": 1,
                "bookingExtrasSum": 0,
                "secondaryPayments": []
            },
            {
                "id": 258,
                "dateTime": "2023-05-05 12:00:00",
                "bookingStart": "2023-05-05 12:00:00",
                "status": "pending",
                "wcOrderId": null,
                "gateway": "onSite",
                "gatewayTitle": "",
                "name": "new service",
                "customerBookingId": 217,
                "packageCustomerId": null,
                "amount": 0,
                "providers": [
                    {
                        "id": 1,
                        "fullName": "Milica Employee",
                        "email": "[email protected]"
                    }
                ],
                "customerId": 8,
                "serviceId": 7,
                "appointmentId": 142,
                "packageId": null,
                "bookedPrice": 33.44,
                "bookableName": "new service",
                "customerFirstName": "Kim",
                "customerLastName": "KibBum",
                "info": null,
                "customerEmail": "[email protected]",
                "coupon": null,
                "persons": 2,
                "aggregatedPrice": 1,
                "bookingExtrasSum": 0,
                "secondaryPayments": []
            },
            {
                "id": 312,
                "dateTime": "2023-05-05 15:00:00",
                "bookingStart": "2023-05-23 09:00:00",
                "status": "paid",
                "wcOrderId": null,
                "gateway": "onSite",
                "gatewayTitle": "",
                "name": "amelia service",
                "customerBookingId": 268,
                "packageCustomerId": null,
                "amount": 10,
                "providers": [
                    {
                        "id": 1,
                        "fullName": "Milica Employee",
                        "email": "[email protected]"
                    }
                ],
                "customerId": 2,
                "serviceId": 1,
                "appointmentId": 181,
                "packageId": null,
                "bookedPrice": 20,
                "bookableName": "amelia service",
                "customerFirstName": "Milica",
                "customerLastName": "Snake",
                "info": "{\"firstName\":\"Milica\",\"lastName\":\"Snake\",\"phone\":null,\"locale\":\"en_US\",\"timeZone\":\"Europe\\/Belgrade\",\"urlParams\":null}",
                "customerEmail": "[email protected]",
                "coupon": null,
                "persons": 1,
                "aggregatedPrice": 1,
                "bookingExtrasSum": 0,
                "secondaryPayments": [
                    {
                        "id": 309,
                        "customerBookingId": 268,
                        "packageCustomerId": null,
                        "parentId": null,
                        "amount": 5,
                        "gateway": "square",
                        "gatewayTitle": "",
                        "dateTime": "2023-05-04 17:32:38",
                        "status": "partiallyPaid",
                        "data": "",
                        "entity": "appointment",
                        "created": "2023-05-04 15:32:38",
                        "actionsCompleted": null,
                        "wcOrderId": null,
                        "wcOrderUrl": null,
                        "wcItemCouponValue": null,
                        "wcItemTaxValue": null
                    }
                ]
            }
        ],
        "filteredCount": 6,
        "totalCount": 265
    }
}

Get transaction amount

Retrieve payment transaction amount from the online payment gateway.

Method

This endpoint accepts GET requests.

Path

/payments/transaction/{{payment_id}}

Example

curl --location 'http://localhost/amelia/wp-admin/admin-ajax.php?action=wpamelia_api&call=/api/v1/payments/transaction/312' \
--header 'Amelia: qUmkNNOLrWbf28izIgNnZ29O+7gVWL5M+8ySJ8VXq3r0'
{
    "message": "Successfully retrieved payment.",
    "data": {
        "payment": {
            "id": 312,
            "customerBookingId": 268,
            "packageCustomerId": null,
            "parentId": null,
            "amount": 10,
            "gateway": "onSite",
            "gatewayTitle": "",
            "dateTime": "2023-05-05 13:00:00",
            "status": "paid",
            "data": "",
            "entity": "appointment",
            "created": "2023-05-05 11:18:32",
            "actionsCompleted": null,
            "wcOrderId": null,
            "wcOrderUrl": null,
            "wcItemCouponValue": null,
            "wcItemTaxValue": null
        }
    }
}

Get payment amount

Calculate payment amount for certain booking information.

Method

This endpoint accepts POST requests.

Path

/payments/amount

Required Properties

The following properties are required.

Key Type Description
type string Entity type. Possible values: appointment, event, package
bookings array Array of bookings
bookingStart string The booking start date and time.
locationId integer The location ID
providerId integer The employee ID
serviceId integer The service ID
recurring array Array of recurring appointments. Required if appointment should be recurring.

Optional Properties

Key Type Description
couponCode string Code of the coupon used.

Example

curl --location 'http://localhost/amelia/wp-admin/admin-ajax.php?action=wpamelia_api&call=/api/v1/payments/amount' \
--header 'Content-Type: application/json' \
--header 'Amelia: qUmkNNOLrWbf28izIgNnZ29O+7gVWL5M+8ySJ8VXq3r0' \
--data '{
    "type": "appointment", 
    "bookings": [ 
        {
            "extras": [
                {
                    "extraId": 4,
                    "quantity": 1
                }
            ],
            "deposit": true,
            "persons": 2,
            "duration": 1800
        }
    ],
    "bookingStart": "2023-09-06 19:00", 
    "locationId": 2, 
    "providerId": 1, 
    "serviceId": 1, 
    "recurring": [], 
    "couponCode": null 
}'
{
    "message": null,
    "data": {
        "amount": 28,
        "currency": "USD"
    }
}

Method

This endpoint accepts POST requests.

Path

/payments/link

Required Properties

The following properties are required.

Key Type Description
data object Object with two properties: type (appointment/event/package) and bookingId (the id of the booking)
paymentMethod string Payment gateway for the link. Possible values: ‘payPal’, ‘stripe’, ‘mollie’, ‘razorpay’, ‘wc’

Optional Properties

Key Type Description
redirectUrl string The url to redirect the customer after a successful payment. By default it is the customer panel link set in Amelia settings.

Example

curl --location 'http://localhost/amelia/wp-admin/admin-ajax.php?action=wpamelia_api&call=/api/v1/payments/link' \
--header 'Content-Type: application/json' \
--header 'Amelia: qUmkNNOLrWbf28izIgNnZ29O+7gVWL5M+8ySJ8VXq3r0' \
--data '{
    "data": {
        "type": "appointment",
        "bookingId": 901
    },
    "paymentMethod": "payPal",
    "redirectUrl": null 
}'
{
    "message": null,
    "data": {
        "paymentLink": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-3D332917B6694771R&useraction=commit",
        "error": null
    }
}

Refund payment

Refund online payment

Method

This endpoint accepts POST requests.

Path

/payments/refund/{{payment_id}}

Example

curl --location --request POST 'http://localhost/amelia/wp-admin/admin-ajax.php?action=wpamelia_api&call=/api/v1/payments/refund/917' \
--header 'Amelia: qUmkNNOLrWbf28izIgNnZ29O+7gVWL5M+8ySJ8VXq3r0'
{
    "message": "Payment successfully refunded.",
    "data": {
        "payment": {
            "id": 917,
            "customerBookingId": 901,
            "packageCustomerId": null,
            "parentId": null,
            "amount": 13,
            "gateway": "payPal",
            "gatewayTitle": "",
            "dateTime": "2023-08-25 10:30:50",
            "status": "paid",
            "data": "",
            "entity": "appointment",
            "created": "2023-08-24 16:59:19",
            "actionsCompleted": true,
            "wcOrderId": null,
            "wcOrderUrl": null,
            "wcItemCouponValue": null,
            "wcItemTaxValue": null,
            "transactionId": "PAYID-MTUIFFI1Y628646J56263609"
        },
        "response": {
            "error": false
        }
    }
}

Delete payment

Delete payment.

Method

This endpoint accepts POST requests.

Path

/payments/delete/{{payment_id}}

Example

curl --location --request POST 'http://localhost/amelia/wp-admin/admin-ajax.php?action=wpamelia_api&call=/api/v1/payments/delete/313' \
--header 'Amelia: qUmkNNOLrWbf28izIgNnZ29O+7gVWL5M+8ySJ8VXq3r0'
{
    "message": "Payment successfully deleted.",
    "data": {
        "payment": {
            "id": 313,
            "customerBookingId": 268,
            "packageCustomerId": null,
            "parentId": null,
            "amount": 15,
            "gateway": "stripe",
            "gatewayTitle": "",
            "dateTime": "2023-05-05 13:00:00",
            "status": "paid",
            "data": "",
            "entity": "appointment",
            "created": "2023-05-05 11:22:49",
            "actionsCompleted": true,
            "wcOrderId": null,
            "wcOrderUrl": null,
            "wcItemCouponValue": null,
            "wcItemTaxValue": null
        }
    }
}