Automation, working with external custom API

Hello,
I’m new to WIX, but I’m really found of it.
Currently I have an external MySQL DB on VPS sever. I have custom php scripts to expose some of functionality I need.
On my store website I want to automate steps after user completed the order.
Steps:

  1. Client complete the order.

  2. Automation send request to external DB, creates entry, returns with information. Basically I need to register user on external DB and set some custom fields in db based on item bought.

  3. Send client an information with login/pass from external db, some information that was generated on external DB side and item name that was bought.

Could you please help me find the best way to do it?

Thanks!

Check the npm MySql module on backend.

Hello,

Read a lot of articles.
I see 2 variants from my understanding, it could be either events from “event.js” in backend, like this (don’t work for me):

import wixData from ‘wix-data’ ;
import wixStores from ‘wix-stores-backend’ ;

export function button8_click(event) {
console.log( “Button clicked!” )
}

export function wixStores_onCartCreated(event) {
let total = event.totals.total;
wixData.insert( ‘Logs’ , { ‘title’ : total})
console.log( “New Cart!” )
}

export function wixStores_onNewOrder(event) {
let newOrderId = event.orderId;
wixData.insert( ‘Logs’ , { ‘orders’ : newOrderId})
console.log( “New Order!” )

}

import wixStoresBackend from ‘wix-stores-backend’ ;

export function wixStoresBackend_onCartCreated(event) {
wixData.insert( “logs” , { “log” : “test from events” });
console.log( “New Order bB.E>!” )
}

Or using Hooks (will try to test soon).