[#660] Slot booking issue

Migrated from Redmine #660 | Author: Fayaz Ahamed PA
Status: Closed | Priority: High, I’m very impatient | Created: 2021-03-13


Our application is getting available slots, and then it sends the available slots for booking, but after we hit booking, we get a slot not available response very frequently, we don’t get this error all the times, but frequently we get such error, even in Postman, we received such errors. But we already get only available slots and sending that. Following are the request and responses.

Available Slots:
https://user-api-v2.simplybook.me/admin/schedule/available-slots?date=2021-03-20&service_id=2

@Response:
[
{
“id”: “2021-03-20 07:00:00”,
“date”: “2021-03-20”,
“time”: “07:00:00”
},
{
“id”: “2021-03-20 09:30:00”,
“date”: “2021-03-20”,
“time”: “09:30:00”
},
{
“id”: “2021-03-20 12:00:00”,
“date”: “2021-03-20”,
“time”: “12:00:00”
},
{
“id”: “2021-03-20 14:30:00”,
“date”: “2021-03-20”,
“time”: “14:30:00”
}
]
@

Booking :
https://user-api-v2.simplybook.me/admin/bookings

@Request:

{“start_datetime”:“2021-03-20 07:00:00”,“provider_id”:1,“service_id”:1,“products”:,“client_id”:“211”,“accept_payment”:“true”,“payment_processor”:“delay”,“additional_fields”:[{“field”:“174f93dea26a3e68edd5863971f1a776”,“value”:“Masha”},{“field”:“1e03f7a8574a6acea8d9871c3fb65b25”,“value”:“66889658”},{“field”:“2d42cf2bb70e82898ba9ffc46dba74f2”,“value”:“South Melbourne Market, Coventry Street, South Melbourne VIC, Australia”},{“field”:“9f785f73333f13a44dbd5cc9df0060f4”,“value”:“Skoda ar”},{“field”:“ac59cc4cfbdefb7805668ea679018e02”,“value”:1110},{“field”:“a25f4d5f4cba4c7428d27430d7dca0d6”,“value”:“VIN”},{“field”:“661e7ff7914016277b3e4de4c62fb285”,“value”:“67823”},{“field”:“a6bf0d4d47602038ef0bbb2fd3ff6f22”,“value”:null},{“field”:“36820785829f0404de8fb18d886350a7”}]}@

Error response:

@{“name”:“StatusCodeError”,“statusCode”:400,“message”:“400 - {"code":400,"message":"","data":{"start_datetime":["Selected time not available"]},"message_data":}”,“error”:{“code”:400,“message”:“”,“data”:{“start_datetime”:[“Selected time not available”]},“message_data”:},“options”:{“baseUrl”:“https://user-api-v2.simplybook.me”,“method”:“POST”,“uri”:“/admin/bookings”,“json”:true,“body”:{“start_datetime”:“2021-03-20 07:00:00”,“provider_id”:1,“service_id”:1,“products”:,“client_id”:“211”,“accept_payment”:“true”,“payment_processor”:“delay”,“additional_fields”:[{“field”:“174f93dea26a3e68edd5863971f1a776”,“value”:“Masha”},{“field”:“1e03f7a8574a6acea8d9871c3fb65b25”,“value”:“66889658”},{“field”:“2d42cf2bb70e82898ba9ffc46dba74f2”,“value”:“South Melbourne Market, Coventry Street, South Melbourne VIC, Australia”},{“field”:“9f785f73333f13a44dbd5cc9df0060f4”,“value”:“Skoda ar”},{“field”:“ac59cc4cfbdefb7805668ea679018e02”,“value”:1110},{“field”:“a25f4d5f4cba4c7428d27430d7dca0d6”,“value”:“VIN”},{“field”:“661e7ff7914016277b3e4de4c62fb285”,“value”:“67823”},{“field”:“a6bf0d4d47602038ef0bbb2fd3ff6f22”,“value”:null},{“field”:“36820785829f0404de8fb18d886350a7”}]},“qs”:{},“headers”:{“Accept”:“application/json”,“Content-Type”:“application/json”,“X-Company-Login”:“safebuy”,“X-Token”:“0c1d2e561e6606da8e2f0ac0a635abcadb7e8d21f8c0a41d2ced771174f28274”},“simple”:true,“resolveWithFullResponse”:false,“transform2xxOnly”:false},“response”:{“statusCode”:400,“body”:{“code”:400,“message”:“”,“data”:{“start_datetime”:[“Selected time not available”]},“message_data”:},“headers”:{“server”:“nginx”,“date”:“Sat, 13 Mar 2021 05:15:42 GMT”,“content-type”:“application/json; charset=UTF-8”,“content-length”:“101”,“connection”:“close”,“access-control-allow-origin”:“*”,“access-control-allow-methods”:“POST, PUT, DELETE, GET, OPTIONS”,“access-control-allow-headers”:“content-type, x-company-login, x-token, x-requested-with”},“request”:{“uri”:{“protocol”:“https:”,“slashes”:true,“auth”:null,“host”:“user-api-v2.simplybook.me”,“port”:443,“hostname”:“user-api-v2.simplybook.me”,“hash”:null,“search”:null,“query”:null,“pathname”:“/admin/bookings”,“path”:“/admin/bookings”,“href”:“https://user-api-v2.simplybook.me/admin/bookings"},“method”:“POST”,“headers”:{“Accept”:“application/json”,“Content-Type”:“application/json”,“X-Company-Login”:“safebuy”,“X-Token”:“0c1d2e561e6606da8e2f0ac0a635abcadb7e8d21f8c0a41d2ced771174f28274”,“content-length”:775}}},"success”:false}@

Dmytro Bondarev wrote:

Hi! In your example i see that you:

  1. do not pass provider id when getting available slots.
  2. you pass different service id in getting slots and in the booking.

Fayaz Ahamed PA wrote:

Dmitry Bondarev wrote:

Hi! In your example i see that you:

  1. do not pass provider id when getting available slots.
  2. you pass different service id in getting slots and in the booking.

Actually, we are not sending provider ID for getting available slots, you can see the request here
https://user-api-v2.simplybook.me/admin/schedule/available-slots?*date=2021-03-20&service_id=2*

Also, the booking request that I have shared is another example, as I mentioned we are not getting this error all the time, buts happening frequently, it’s just one example. But we made sure the service ID is passed properly.

Dmytro Bondarev wrote:

You have to pass provider id when getting available slots to be sure that there is free slot for this provider.

Fayaz Ahamed PA wrote:

We have tried that too but getting a different error. I have attached a video recording for your reference.

Fayaz Ahamed PA wrote:

Video recording

Redmine Admin wrote:

please provide raw http request

Redmine Admin wrote:

API explorere is for old API, but you are using REST API which is absolutely different and you should not reffer to API explorer as example

Fayaz Ahamed PA wrote:

Here is the raw request:

Available-Slots:
URL - https://user-api-v2.simplybook.me/admin/schedule/available-slots
Method - GET
headers - Accept: /
query - provider_id:1, date:2021-04-02

New-Booking:
URL - https://user-api-v2.simplybook.me/admin/bookings
Method - POST
headers - Accept: /
body - {“start_datetime”:“2021-04-02 17:30:00”,“provider_id”:1,“service_id”:6,“products”:,“client_id”:“93”,“accept_payment”:“true”,“payment_processor”:“delay”,“additional_fields”:[{“field”:“174f93dea26a3e68edd5863971f1a776”,“value”:“Sedha”},{“field”:“1e03f7a8574a6acea8d9871c3fb65b25”,“value”:“55476”},{“field”:“2d42cf2bb70e82898ba9ffc46dba74f2”,“value”:“16 Banool Rd, Fairhaven VIC 3231, Australia”},{“field”:“9f785f73333f13a44dbd5cc9df0060f4”,“value”:“mahindra sew”},{“field”:“ac59cc4cfbdefb7805668ea679018e02”,“value”:4555},{“field”:“a25f4d5f4cba4c7428d27430d7dca0d6”,“value”:“Rego”},{“field”:“661e7ff7914016277b3e4de4c62fb285”,“value”:“5445”},{“field”:“a6bf0d4d47602038ef0bbb2fd3ff6f22”,“value”:null},{“field”:“36820785829f0404de8fb18d886350a7”}]}

Redmine Admin wrote:

please provide full raw http request with all headers and server responce

Fayaz Ahamed PA wrote:

Avaliable-Slots:
URL - https://user-api-v2.simplybook.me/admin/schedule/available-slots
Method - GET
headers - GET /api/schedule/available-slots?date=2021-03-31&provider_id=1 HTTP/1.1
Host: https://user-api-v2.simplybook.me
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0
Accept: /
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Origin: http://localhost:3000
DNT: 1
Connection: keep-alive
Referer: http://localhost:3000/
Cookie: safebuyRedis=s%3A8t_ujT_9ligvWWMfrbxp- PpU_rb4ZpP2.XGQrc9oNtTXEpcPmTqKjslHoOlfJP2iTpgxb4HtmQwA
query - provider_id:1, date:2021-04-02

server-response - [{"id":"2021-03-31 17:30:00","date":"2021-03-31","time":"17:30:00"},{"id":"2021-03-31 17:45:00","date":"2021-03-31","time":"17:45:00"}]

New-Booking:
URL - https://user-api-v2.simplybook.me/admin/bookings
Method - POST
headers - POST /api/bookings undefined
Host: https://user-api-v2.simplybook.me
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0
Accept: /
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/json
Content-Length: 767
Origin: http://localhost:3000
DNT: 1
Connection: keep-alive
Referer: http://localhost:3000/
Cookie: safebuyRedis=s%3A8t_ujT_9ligvWWMfrbxp- PpU_rb4ZpP2.XGQrc9oNtTXEpcPmTqKjslHoOlfJP2iTpgxb4HtmQwA

body  - 	{"start_datetime":"2021-03-31 17:30:00","provider_id":1,"service_id":1,"products":[],"client_id":null,"accept_payment":"true","payment_processor":"delay","additional_fields":[{"field":"174f93dea26a3e68edd5863971f1a776","value":"Paul"},{"field":"1e03f7a8574a6acea8d9871c3fb65b25","value":"7859163428"},{"field":"2d42cf2bb70e82898ba9ffc46dba74f2","value":"Southland Westfield, Nepean Highway, Cheltenham VIC, Australia"},{"field":"9f785f73333f13a44dbd5cc9df0060f4","value":"Scorpia AU"},{"field":"ac59cc4cfbdefb7805668ea679018e02","value":1110},{"field":"a25f4d5f4cba4c7428d27430d7dca0d6","value":"VIN"},{"field":"661e7ff7914016277b3e4de4c62fb285","value":"58962"},{"field":"a6bf0d4d47602038ef0bbb2fd3ff6f22","value":null},{"field":"36820785829f0404de8fb18d886350a7"}]}

server-response -
{
“code”: 400,
“message”: “”,
“data”: {
“end_datetime”: [
“Invalid type given, value should be float, string, or integer”,
“Invalid type given, value should be string, or integer”
],
“start_datetime”: [
“Selected time not available”
]
},
“message_data”:
}

Redmine Admin wrote:

seems responce is clear: Selected time not available
please try to book same from web interface

Fayaz Ahamed PA wrote:

I don’t think it’s giving the right response, in our example request, we get available slots and it says 2021-03-31 17:30:00 is available in the response when we send the same slot for booking it says not available.

Dmytro Bondarev wrote:

It is not possible to calculate available slots without full info about service, provider, count, etc.
Now you do not pass service_id. And the service duration can be bigger than timeframe, that is why this slot is not available.

Fayaz Ahamed PA wrote:

We will include service ID and the booking are working, even before this it was working fine but frequently we received such error. We will test with this approach.

Fayaz Ahamed PA wrote:

Thanks for your support, it works fine. We still have some issues.

  1. Even before we complete the payment, the booking got created in Appointment booking service and free online booking service and also we get booking confirmation email from the system. But in your booking website (SafeBuy (ABN: 17510261621) | Scheduling and Booking Website) it is working fine, only after payment confirmation we get emails. How do we restrict that in our approach, we couldn’t find any flag or type in API Documentation?

  2. In your booking website (SafeBuy (ABN: 17510261621) | Scheduling and Booking Website) we can see the time slot with a full gap (refer to attached image), but when we get time slots, we only get service hrs like 7 am, 9 am, but in your application it says 7 am, 7:30 am, 8 am, etc… when we checked, there is an API called time-flexible, which we don’t find in the API documentation. Can you help us to get same flexible time slots to display?

Dmytro Bondarev wrote:

  1. you are using admin API. in this case it is not possible.
  2. currently only slots available, you can divide them in your app.

Fayaz Ahamed PA wrote:

We followed this documentation for the integration API documentation | SimplyBook.me Online Scheduling, and used this API documentation | SimplyBook.me Online Scheduling, we don’t find any specifics about user API. Can you explain more on the user API?

Redmine Admin wrote:

Please check here API documentation | SimplyBook.me Online Scheduling

Fayaz Ahamed PA wrote:

We entirely changed our app to user API and having some issues, please read below.

We tried apply coupon with validatePromoCode function to apply promo code in Company public service methods (a valid promo code)

URL: https://user-api.simplybook.me/
METHOD: POST
HEADER: POST /api/apply-promo-code HTTP/1.1
Host: user-api.simplybook.me/
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0
Accept: /
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/json
Content-Length: 162
Origin: http://localhost:3000
Connection: keep-alive
Referer: http://localhost:3000/
Cookie: safebuyRedis=s%3AnsaUHdpLsYNWJ-dh1RHpUxUJeboGCA9j.KojcsJl7tBGLBEI0LMQLNMxl6QZgZoUpNanErYCB4%2BE

Body: { jsonrpc: ‘2.0’,
method: ‘validatePromoCode’,
params:
[ ‘Zghbtlc’,
‘2021-04-14 09:30:00’,
‘2’,
1,
{ name: ‘Farol’, email: ‘farol@gmail.com’, phone: 7896895364 } ],
id: undefined }

Response:
{“error”:{“code”:-32030,“message”:“Invalid promotion code”,“data”:},“id”:null,“jsonrpc”:“2.0”}

Also, for payment we have tried with confirmBookingPayment, this method contain sign parameter and it has been defined with a procedure( $sign = md5($bookingId . $bookingHash . $secretKey)), if it is the formula then would you explain this formula for api integration