Okay
  Public Ticket #3697968
API Endpoint
Closed

Comments

  •  1
    Bernard started the conversation

    Hi,

    I am using the API endpoints from Amelia. I can get the most things done. 
    What is unclear for me is how to use the Mollie payments when I use the API endpoints.
    When I use Amelia itself and go to payments then it opens a url to Mollie and I can do the payment. Mollie will show the choices of banks what can be used for Ideal.


    My questions.

    1. What flow do I need to do after selecting a location, service and timeslot?
    For example first create a booking? 
    2. How can I  do the payment when I use Mollie (service key is insert into Amelia).  Is there an API call so it opens the screen from Mollie to do a payment? Or do I need to create it myself?
    3. If I need to do it by myself question 2. Then I need to post to an API call that the payment was successful? Otherwise the dashboard fails in Amelia I assume ? The goal is that the dashboards keep working in Amelia. 


    Thank you for answering my question!


  •  1,500
    Uroš replied

    Hello Bernard,

    Thank you for reaching out to us.

    I have passed this question to our developers and we will provide you with an update as soon as we have one.

    Thank you for your patience.

    Kind Regards, 

    Uros Jovanovic
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  1,500
    Uroš replied

    Hello Bernard,

    For now you ca use the same endpoint used by the plugin, http://localhost/amelia/wp-admin/admin-ajax.php?action=wpamelia_api&call=/payment/mollie . The data sent is similar to the one for the normal bookings call: /api/v1/bookings. Here is an example:

    {    "type": "appointment",    "bookings": [        {            "customFields": {                "1": {                    "label": "address line 1",                    "type": "text",                    "value": ""                }            },            "customerId": 4,            "customer": {                "id": 4,                "firstName": "Amelia",                "lastName": "Test",                "email": "[email protected]",                "phone": "",                "countryPhoneIso": "us",                "translations": "{\"defaultLanguage\":\"en_US\"}"            },            "extras": [],            "persons": 1,            "duration": 5400,            "utcOffset": 120        }    ],    "payment": {        "gateway": "mollie",        "currency": "USD",        "data": {}    },    "componentProps": {        "state": {},        "form": {}    },    "returnUrl": "http://localhost/amelia/booking/",    "couponCode": null,    "notifyParticipants": 1,    "isCart": 0,    "recurring": [],    "package": [],    "serviceId": 5,    "providerId": 14,    "locationId": 1,    "bookingStart": "2024-08-27 08:30",    "utcOffset": 120,    "extras": [],    "persons": 1,    "duration": 5400
    }
    

    The "componentProps" attribute is used for storing data so the form can be rebuilt when the customer is returned from Mollie with the appropriate parameters. This data will be stored in the wp_amelia_cache table. The "returnUrl" is the url Mollie will redirect to after the payment (the current site url in our plugin).

    This endpoint will return a response like this:

    {     "message": "Proceed to Mollie Payment Page",     "data": { "redirectUrl": "https://www.mollie.com/checkout/select-method/FMBJrTNUjk" }
    }

    It will also create a booking that is pending. After the payment has been processed Mollie will redirect the user to the given "returnUrl" and call a webhook  (/payment/mollie/notify), which will mark the booking as "Approved" and payment "Paid". You don't have to change anything in the webhook part.

    The returnUrl will have a query parameter appended called ameliaCache.

    (example ?ameliaCache=50_f13badfb06_appointment)

    The plugin will get the saved data and put it in a global variable ameliaCache, which you can access with window.ameliaCache. However if the plugin is not on the page, you will have to retrieve this data yourself from the wp_amelia_cache table. You can also just store this data in localStorage or something similar, or you may not need it depending on which data you want to show on the "Congratulations" step. You can check on page load if the url has the "ameliaCache" parameter, if it does the booking is made and you are redirected from Mollie and can show the customer the final page and then you can call the /api/v1/bookings/success endpoint to send emails and other post-booking actions.

    We will add this endpoint in our API and documentation in a future update.

    Kind Regards, 

    Uros Jovanovic
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables