[#1203] Not working as expected

Migrated from Redmine #1203 | Author: Olaf Siebert
Status: Feedback | Priority: Immediate, there is BUG! | Created: 2024-03-20


Nothing is really working as expected. The documentation is next to useless.

Book function:

  1. Why is my booking alway setup require_payment: false!!!
  2. Why does handle invoice ‘handle_invoice: true’ has no affect at all
  3. Cannot add additional fields. It works fine with restAPI.

const token = await loginUser();

if(!token?.result) {
throw new Error(‘Error token’);
}

const additionalFields = await getAdditionalFields();
const fields: any = ;

console.log(‘makeBooking’, additionalFields)

for (const key of Object.keys(client)) {
additionalFields.forEach((item: any) => {
if (item.title === key && client[key]) {
item.value = client[key];
fields.push({
name: item.name,
type: item.type,
value: client[key]
});
}
})
}

console.log(‘makeBooking’, fields)

const time = dateTime.split(’ ');

try {

const response = await axios.post('https://user-api.simplybook.me/admin', {
  jsonrpc: '2.0',
  method: 'book',
  params: [
    Number(eventId),
    Number(unitId),
    client.id,
    time[0],
    time[1],
    null,
    null,
    null,
    {
      handle_invoice: true,
      terms: true,
      ...fields
    },
    1
  ],
  id: 1
}, {
  headers: {
    'X-Company-Login': process.env.SIMPLEBOOKME_COMPANY_LOGIN,
    'X-User-token': token.result
  }
});

Dmytro Bondarev wrote:

Hi Olaf,

Could you please explain a bit more what is exactly not working?
From your message it is not clear what you are expecting and what exactly is wrong.

Olaf Siebert wrote:

Booking {
require_confirm: false,
bookings: [
{
id: ‘81’,
event_id: 3,
unit_id: 2,
client_id: ‘8’,
client_hash: ‘d370327301c50a8e8f52fd54f7afa0fe’,
start_date_time: ‘2024-03-21 09:00:00’,
end_date_time: ‘2024-03-21 12:00:00’,
time_offset: ‘0’,
is_confirmed: ‘1’,
require_payment: false,
code: ‘1tm828ayb’,
hash: ‘8a915120ee78280c79f5e88373e3375b’
}
],
invoice: null
}

  1. Additional fields not being populated in calendar
  2. Payment should be required and like to confirm it after stripe payment successful
  3. No invoice being generated

Dmytro Bondarev wrote:

To investigate your issue, please provide your HTTP request.

Olaf Siebert wrote:

I am calling the booking function with following parameters, it does make the booking but I am not able to add fields value, create an invoice or make the payment a required. Why do you need the HTTP? I have no error. I just cannot set addtional fields, make an invoice or wait for payment before confirmation mail is send.

jsonrpc: ‘2.0’,
method: ‘book’,
params: [
Number(eventId),
Number(unitId),
client.id,
time[0],
time[1],
null,
null,
null,
{
handle_invoice: true,
terms: true,
…fields
},
1

Olaf Siebert wrote:

I am calling the booking function with following parameters, it does make the booking but I am not able to add fields value, create an invoice or make the payment a required. Why do you need the HTTP? I have no error. I just cannot set addtional fields, make an invoice or wait for payment before confirmation mail is send.

jsonrpc: ‘2.0’,
method: ‘book’,
params: [
Number(eventId),
Number(unitId),
client.id,
time[0],
time[1],
null,
null,
null,
{
handle_invoice: true,
terms: true,
…fields
},
1

Parameters I send to the function:

makeBooking [
3,
2,
‘8’,
‘2024-03-21’,
‘09:00:00’,
null,
null,
null,
{
‘0’: {
name: ‘d1cdba45ca1dd3bcab80be22ae4842b6’,
type: ‘textarea’,
value: ‘Kassel, Germany’
},
‘1’: {
name: ‘8d9168103633cc47fb0936c4a738cf60’,
type: ‘text’,
value: ‘2024-02-29T23:00:00.000Z’
},
‘2’: {
name: ‘92511b828b0bbc0d3df66acc4c502153’,
type: ‘textarea’,
value: {"planet":{"angles":{"ascendant":{"degree":204.7810043214495,"zodiacDegree":"24º 46' 51\\" Libra"},"midheaven":{"degree":122.8590442279377,"zodiacDegree":"2º 51' 32\\" Leo"},"descendant":{"degree":24.7810043214495,"zodiacDegree":"24º 46' 51\\" Aries"},"lowerMidheaven":{"degree":302.8590442279377,"zodiacDegree":"2º 51' 32\\" Aquarius"}},"planets":{"sun":{"degree":311.5552082674428,"zodiacDegree":"11º 33' 18\\" Aquarius"},"moon":{"degree":199.1872281873117,"zodiacDegree":"19º 11' 14\\" Libra"},"mercury":{"degree":293.580403265071,"zodiacDegree":"23º 34' 49\\" Capricorn"},"venus":{"degree":280.5835451815385,"zodiacDegree":"10º 35' 0\\" Capricorn"},"mars":{"degree":290.5917772734051,"zodiacDegree":"20º 35' 30\\" Capricorn"},"jupiter":{"degree":37.276379679754484,"zodiacDegree":"7º 16' 34\\" Taurus"},"saturn":{"degree":336.43535175323035,"zodiacDegree":"6º 26' 7\\" Pisces"},"uranus":{"degree":49.09786268603936,"zodiacDegree":"19º 5' 52\\" Taurus"},"neptune":{"degree":355.7667608751491,"zodiacDegree":"25º 46' 0\\" Pisces"},"pluto":{"degree":300.35330860127226,"zodiacDegree":"0º 21' 11\\" Aquarius"}},"houses":{"equal":[{"degree":204.7810043214495,"zodiacDegree":"24º 46' 51\\" Libra"},{"degree":234.7810043214495,"zodiacDegree":"24º 46' 51\\" Scorpio"},{"degree":264.7810043214495,"zodiacDegree":"24º 46' 51\\" Sagittarius"},{"degree":294.7810043214495,"zodiacDegree":"24º 46' 51\\" Capricorn"},{"degree":324.7810043214495,"zodiacDegree":"24º 46' 51\\" Aquarius"},{"degree":354.7810043214495,"zodiacDegree":"24º 46' 51\\" Pisces"},{"degree":24.7810043214495,"zodiacDegree":"24º 46' 51\\" Aries"},{"degree":54.7810043214495,"zodiacDegree":"24º 46' 51\\" Taurus"},{"degree":84.7810043214495,"zodiacDegree":"24º 46' 51\\" Gemini"},{"degree":114.7810043214495,"zodiacDegree":"24º 46' 51\\" Cancer"},{"degree":144.7810043214495,"zodiacDegree":"24º 46' 51\\" Leo"},{"degree":174.7810043214495,"zodiacDegree":"24º 46' 51\\" Virgo"}],"koch":[{"degree":204.7810043214495,"zodiacDegree":"24º 46' 51\\" Libra"},{"degree":231.9847578366976,"zodiacDegree":"21º 59' 5\\" Scorpio"},{"degree":261.1800401938212,"zodiacDegree":"21º 10' 48\\" Sagittarius"},{"degree":302.8590442279377,"zodiacDegree":"2º 51' 32\\" Aquarius"},{"degree":330.1540428546407,"zodiacDegree":"0º 9' 14\\" Pisces"},{"degree":357.4457671132791,"zodiacDegree":"27º 26' 44\\" Pisces"},{"degree":24.7810043214495,"zodiacDegree":"24º 46' 51\\" Aries"},{"degree":51.9847578366976,"zodiacDegree":"21º 59' 5\\" Taurus"},{"degree":81.1800401938212,"zodiacDegree":"21º 10' 48\\" Gemini"},{"degree":122.8590442279377,"zodiacDegree":"2º 51' 32\\" Leo"},{"degree":150.1540428546407,"zodiacDegree":"0º 9' 14\\" Virgo"},{"degree":177.4457671132791,"zodiacDegree":"27º 26' 44\\" Virgo"}],"porphyry":[{"degree":204.7810043214495,"zodiacDegree":"24º 46' 51\\" Libra"},{"degree":237.4736842902789,"zodiacDegree":"27º 28' 25\\" Scorpio"},{"degree":270.1663642591084,"zodiacDegree":"0º 9' 58\\" Capricorn"},{"degree":302.8590442279377,"zodiacDegree":"2º 51' 32\\" Aquarius"},{"degree":330.1663642591084,"zodiacDegree":"0º 9' 58\\" Pisces"},{"degree":357.4736842902789,"zodiacDegree":"27º 28' 25\\" Pisces"},{"degree":24.7810043214495,"zodiacDegree":"24º 46' 51\\" Aries"},{"degree":57.4736842902789,"zodiacDegree":"27º 28' 25\\" Taurus"},{"degree":90.1663642591084,"zodiacDegree":"0º 9' 58\\" Cancer"},{"degree":122.8590442279377,"zodiacDegree":"2º 51' 32\\" Leo"},{"degree":150.1663642591084,"zodiacDegree":"0º 9' 58\\" Virgo"},{"degree":177.4736842902789,"zodiacDegree":"27º 28' 25\\" Virgo"}],"regiomontanus":[{"degree":204.7810043214495,"zodiacDegree":"24º 46' 51\\" Libra"},{"degree":228.0429802591138,"zodiacDegree":"18º 2' 34\\" Scorpio"},{"degree":260.5344639405031,"zodiacDegree":"20º 32' 4\\" Sagittarius"},{"degree":302.8590442279377,"zodiacDegree":"2º 51' 32\\" Aquarius"},{"degree":338.7501171526903,"zodiacDegree":"8º 45' 0\\" Pisces"},{"degree":3.8176858899099,"zodiacDegree":"3º 49' 3\\" Aries"},{"degree":24.7810043214495,"zodiacDegree":"24º 46' 51\\" Aries"},{"degree":48.0429802591138,"zodiacDegree":"18º 2' 34\\" Taurus"},{"degree":80.5344639405031,"zodiacDegree":"20º 32' 4\\" Gemini"},{"degree":122.8590442279377,"zodiacDegree":"2º 51' 32\\" Leo"},{"degree":158.7501171526903,"zodiacDegree":"8º 45' 0\\" Virgo"},{"degree":183.8176858899099,"zodiacDegree":"3º 49' 3\\" Libra"}],"topocentric":[{"degree":204.7810043214495,"zodiacDegree":"24º 46' 51\\" Libra"},{"degree":231.6939536120815,"zodiacDegree":"21º 41' 38\\" Scorpio"},{"degree":265.2205541879775,"zodiacDegree":"25º 13' 13\\" Sagittarius"},{"degree":302.8590442279377,"zodiacDegree":"2º 51' 32\\" Aquarius"},{"degree":337.1626336946285,"zodiacDegree":"7º 9' 45\\" Pisces"},{"degree":4.1203204565578,"zodiacDegree":"4º 7' 13\\" Aries"},{"degree":24.7810043214495,"zodiacDegree":"24º 46' 51\\" Aries"},{"degree":51.6939536120815,"zodiacDegree":"21º 41' 38\\" Taurus"},{"degree":85.2205541879775,"zodiacDegree":"25º 13' 13\\" Gemini"},{"degree":122.8590442279377,"zodiacDegree":"2º 51' 32\\" Leo"},{"degree":157.1626336946285,"zodiacDegree":"7º 9' 45\\" Virgo"},{"degree":184.1203204565578,"zodiacDegree":"4º 7' 13\\" Libra"}]}},"convertedData":{"planets":{"sun":[312],"moon":[199],"mercury":[294],"venus":[281],"mars":[291],"jupiter":[37],"saturn":[336],"uranus":[49],"neptune":[356],"pluto":[300]},"cusps":[205,235,265,295,325,355,25,55,85,115,145,175]},"graphUrl":"http://localhost:3000/astro-chart?data=%7B%22planets%22%3A%7B%22sun%22%3A%5B312%5D%2C%22moon%22%3A%5B199%5D%2C%22mercury%22%3A%5B294%5D%2C%22venus%22%3A%5B281%5D%2C%22mars%22%3A%5B291%5D%2C%22jupiter%22%3A%5B37%5D%2C%22saturn%22%3A%5B336%5D%2C%22uranus%22%3A%5B49%5D%2C%22neptune%22%3A%5B356%5D%2C%22pluto%22%3A%5B300%5D%7D%2C%22cusps%22%3A%5B205%2C235%2C265%2C295%2C325%2C355%2C25%2C55%2C85%2C115%2C145%2C175%5D%7D"}
},
‘3’: {
name: ‘032323fec950b87d5430f4f62a7d9bb9’,
type: ‘text’,
value: ‘http://localhost:3000/astro-chart?data={“planets”%3A{“sun”%3A[312]%2C"moon"%3A[199]%2C"mercury"%3A[294]%2C"venus"%3A[281]%2C"mars"%3A[291]%2C"jupiter"%3A[37]%2C"saturn"%3A[336]%2C"uranus"%3A[49]%2C"neptune"%3A[356]%2C"pluto"%3A[300]}%2C"cusps"%3A[205%2C235%2C265%2C295%2C325%2C355%2C25%2C55%2C85%2C115%2C145%2C175]}
},
handle_invoice: true,
terms: true
},
1
]

Dmytro Bondarev wrote:

We need HTTP request to be able to check it.
You pass data in wrong format. In your case @additional@ must be

{
    "d1cdba45ca1dd3bcab80be22ae4842b6": "Kassel, Germany",
    "8d9168103633cc47fb0936c4a738cf60": "2024-02-29T23:00:00.000Z",
    "handle_invoice": true
}

Olaf Siebert wrote:

Thanks, i will try this

Olaf Siebert wrote:

Ok, that fixed additional fields. Thanks.

But I still have no invoice and as I require payment, should require_payment be true?

Dmytro Bondarev wrote:

Could you please provide company login or could you please confirm that you have set service price and accept payment is turned on?

Olaf Siebert wrote:

SIMPLEBOOKME_COMPANY_LOGIN=myelementalbeing

Dmytro Bondarev wrote:

Since you are using admin API, please pass
“make_invoice”: true to additional as well

Olaf Siebert wrote:

Great, that generated an invoice. Now I still have that issue that the payment should be required.

{“client_hash”:“d370327301c50a8e8f52fd54f7afa0fe”,“client_id”:“8”,“code”:“1tm82jerm”,“end_date_time”:“2024-03-21 12:00:00”,“event_id”:3,“hash”:“facf91817da8ce412941244f19545b41”,“id”:“92”,“is_confirmed”:“1”,“require_payment”:false,“start_date_time”:“2024-03-21 09:00:00”,“time_offset”:“0”,“unit_id”:2}

Also the method confirmBookingPayment has stopped working for me.

{“error”:{“code”:-32000,“message”:“Unexpected error”,“data”:null},“id”:“1”,“jsonrpc”:“2.0”}

I was hoping to do the booking using book method. When I get confirmation from stripe the payment was successful, I call the confirmBookingPayment method.

Dmytro Bondarev wrote:

You can pass
“payment_processor”: “delay”

To not confirm payment immediately.
When you receive payment on your side you can call
[[API documentation | SimplyBook.me Online Scheduling]]
or
[[API documentation | SimplyBook.me Online Scheduling]]

Olaf Siebert wrote:

Great that seems to work. One last question, what happens when the payment is not being confirmed? Does the booking gets deleted automatically?

Dmytro Bondarev wrote:

Since you are making booking via admin API it will not be automatically canceled.

Olaf Siebert wrote:

One last question, how do I delay the automatic confirmation mail for booking confirm and booking cancelation? The confirmation should only be send out once the payment has been confirm. Any error during the payment process, I have to cancel the booking, i like to avoid the cancellation message at this point?

Dmytro Bondarev wrote:

For such functionality you should use public API:

Olaf Siebert wrote:

Ok, the reason I am being using book from admin is that i can pass in the client id. When I was using the book method from the public api, it was creating multiple clients with same email address. How can just use an existing users with public api?

Dmytro Bondarev wrote:

In this case you can pass
client_id - Your client id
client_sign - md5(client_id + client_hash + secret)

You can add client using addClient in the response you will get client_hash.
Or you can use getClient of Admin API to get client info with client_hash.