[#1213] Initiate payment after new booking

Migrated from Redmine #1213 | Author: Nicolas Abrovich
Status: Feedback | Priority: High, I’m very impatient | Created: 2024-04-15


Hello

how can I get the “sbpay_invoice_id” or “sbpay_reference_id”?
after booking with the public api?

I would like to have the same behavior as on the platform.
i.e., i would like to initiate a sbpay me payment with stripe and i receive the link from stripe that i can redirect directly from my front-end.

Can you explain the steps to follow?

Dmytro Bondarev wrote:

Hi, please clarify context and your use case.
It is not clear what you want to do.

Nicolas Abrovich wrote:

I have a custom front end en custom server

When i use public method “book”

i get this result:


const booking = {
  require_confirm: false,
  bookings: [
    {
      id: '567',
      event_id: 41,
      unit_id: 26,
      client_id: '253',
      client_hash: '----------',
      start_date_time: '2025-01-02 11:40:00',
      end_date_time: '2025-01-02 12:25:00',
      time_offset: '0',
      is_confirmed: '1',
      require_payment: false,
      code: '5ptfq7ih',
      hash: '-----------',
    },
  ],
  invoice: {
    client_additional_info: [],
    id: 599,
    number: 'O-00000598',
    datetime: '2024-04-15 10:07:17',
    due_datetime: '2024-04-15 10:37:17',
    payment_datetime: null,
    amount: 10,
    recurring_amount: 0,
    deposit: 0,
    is_with_deposit_amount: true,
    deposit_is_client_can_pay_later: 1,
    rest_amount: 35,
    discount_amount: 0,
    taxes: [{}],
    tax_amount: 1.6667,
    currency: 'EUR',
    tip: null,
    client_id: 253,
    description: '',
    payment_received: false,
    payment_processor: null,
    lines: [
      {
        currency: 'EUR',
        amount: 10,
        name_for_booking_line: 'Réservation',
      },
    ],
    status: 'new',
    support_recurring_payment_method: false,
    require_recurring_payment_method: false,
    recurring_profile_id: null,
    promotion_instances: [],
    package_instances: [],
    deposit_child_invoice: null,
    deposit_parent_invoice: null,
    refund_datetime: null,
    sbpay_reference_id: null,
    sbpay_invoice_id: '',
  },
};

I want to use sbpay to get a stripe url and redirect customer
but how do you do it?

i see “Initialize payment” on SBPay.me - Single place for all payment processors
but how to link sbpay with simplybook ?

Dmytro Bondarev wrote:

Hi, unfortunately, at the moment it is not possible.

Nicolas Abrovich wrote:

so the only solution is to generate a stripe link myself. then validate the payment manually with the admin api?

How do I manage the relationship between the stripe payment and the simplybook booking?

How do I manage refunds?

Dmytro Bondarev wrote:

Hi, unfortunately at the moment the only way is to approve manually with admin API.

How do I manage the relationship between the stripe payment and the simplybook booking?
You can only manage this relationship on your side. It is not possible to store such info in simplybook.

How do I manage refunds?
In this case only manually.

Nicolas Abrovich wrote:

Thanks

But why i cant use this on app.sbpay.me

Initialize payment

Initializes payment and provides output containing details of subsequent actions.

POST /api/payment

Parameters
X-Merchant string
Parameter in header
X-Auth-Token string
Parameter in header
X-Signature string
Parameter in header

Request body: InitPaymentSignedRequestDTO
Response
Details of subsequent actions or error data.
InitPaymentResponseDTO

Example:

POST https://app.sbpay.me/api/payment HTTP/1.1
Host: app.sbpay.me
Accept: application/json
Content-Type: application/json
X-Merchant:
X-Auth-Token:
X-Signature:

{
“storePaymentMethod”: true,
“paymentMethodId”: 1,
“paymentSystem”: “string”,
“referenceId”: “string”,
“description”: “string”,
“currency”: “string”,
“lines”: [
{
“name”: “string”,
“description”: “string”,
“qty”: 1,
“finalPrice”: 0,
“price”: 0,
“discounts”: [
{
“value”: 0,
“type”: “percentage”
}
],
“taxes”: [
{
“name”: “string”,
“rate”: 0,
“inclusive”: true,
“countryId”: “string”,
“stateId”: “string”,
“city”: “string”
}
],
“periodStart”: “2023-01-01T00:00:00+00:00”,
“periodEnd”: “2023-01-01T00:00:00+00:00”,
“referenceId”: “string”,
“referenceType”: “string”,
“planPriceId”: 1,
“amount”: 0
}
],
“amount”: 0,
“customer”: null,
“tags”: null,
“autoMakeInvoiceOnReceivePayment”: true,
“timestamp”: “2023-01-01T00:00:00+00:00”,
“algo”: “sha256”,
“callbacks”: null,
“billingPeriod”: null
}

Dmytro Bondarev wrote:

You can but it will not be connected to simplybook payment and you still will have to approve it manually.

Nicolas Abrovich wrote:

Ok ! thanks you

it would be great to be able to communicate with the api with a secret token rather than via email + password.

Nicolas Abrovich wrote:

admin api*

(Short original content)

Dmytro Bondarev wrote:

We are working on this, it will be possible in upcoming months.