Requests

Here's a sample integration in plain JavaScript:

const buttonWrapperId = "#clicktopay-button-wrapper";
const paymentScreenId = "#clicktopay-payment-screen";

if ($(buttonWrapperId).length) {
  var orderInformation = {
       currency: "EUR",  // order currency (ISO 4217)
       totalAmount: "0.01"  // total payment amount
  };

  const clickToPayOptions = new BuckarooSdk.ClickToPay.CaptureContextOptions(
    "your-merchant-identifier", // GUID
    ["https://your-domain.com"], // Your domains
    "NL", // Country code
    "en_US", // Language + country
    orderInformation,
    processCallback // Callback function to handle payment data  );

  const captureContext = new BuckarooSdk.ClickToPay.CaptureContext(
    buttonWrapperId,
    paymentScreenId,
    clickToPayOptions
  );

  var clientId = "your-client-id";
  var clientSecret = "your-client-secret";

  captureContext.generateAndLoadCaptureContext(clientId, clientSecret);
}

function processCallback(clickToPayData) {
     // const transientToken = clickToPayData.transientToken;
     // const identifier = clickToPayData.identifier;

      return Promise.resolve();  //Replace with your server-side call by sending these data to Buckaroo
}