SDK Examples

Checkout, with Aeropay generated button

Code Example

window.AeroPay.init({
  env: "staging"
});

var onSuccess = function(uuid) {
  console.log(uuid);
};

// event callback is optional 
var onEvent = function(event) {
  console.log(event);
};

var apButton = window.AeroPay.button({
  location: "6ced28ccc4",
  type: "checkout",
  onSuccess: onSuccess,
  onEvent: onEvent  // optional
});

apButton.total("88.50");
apButton.render("aeropay-button-container");

Checkout, with custom button and branding

Code Example

window.AeroPay.init({
  env: "staging"
});

var onSuccess = function(uuid) {
  console.log(uuid);
};

// event callback is optional 
var onEvent = function(event) {
  console.log(event);
};

var apButton = window.AeroPay.button({
  location: "6ced28ccc4",
  type: "checkout",
  onSuccess: onSuccess,
  onEvent: onEvent  // optional
});

document
  .getElementById("my-aeropay-button")
  .addEventListener("click",
    function apClickEvent() {
      apButton.launch("88.50");
    });

userAuthorize, with Aeropay generated button

Code Example

window.AeroPay.init({
  env: "staging"
});

var onSuccess = function(result) {
  console.log(result);
};

// event callback is optional 
var onEvent = function(event) {
  console.log(event);
};

var apButton = window.AeroPay.button({
  location: "6ced28ccc4",
  type: "userAuthorize",
  onSuccess: onSuccess,
  onEvent: onEvent  // optional
});

apButton.total("88.50");
apButton.render("aeropay-button-container");

selfCheckout, with Aeropay generated button

Code Example

window.AeroPay.init({
  env: "staging"
});

var onSuccess = function(uuid) {
  console.log(uuid);
};

// event callback is optional 
var onEvent = function(event) {
  console.log(event);
};

var apButton = window.AeroPay.button({
  location: "6ced28ccc4",
  type: "selfCheckout",
  onSuccess: onSuccess,
  onEvent: onEvent  // optional
});

apButton.render("aeropay-button-container");

selfCheckout, with custom generated button

Code Example

window.AeroPay.init({
  env: "staging"
});

var onSuccess = function(uuid) {
  console.log(uuid);
};

// event callback is optional

var apButton = window.AeroPay.button({
  location: "6ced28ccc4",
  type: "selfCheckout",
  onSuccess: onSuccess
});

document
  .getElementById("my-aeropay-button")
  .addEventListener("click",
    function apClickEvent() {
      apButton.launch();
    })

subscription, with Aeropay generated button, passing a selected amount

Code Example

window.AeroPay.init({
  env: "staging"
});

var onSuccess = function(result) {
  console.log(result);
};

// event callback is optional 
var onEvent = function(event) {
  console.log(event);
};

var apButton = window.AeroPay.button({
  location: "6ced28ccc4",
  type: "subscription",
  onSuccess: onSuccess,
  onEvent: onEvent  // optional
});

apButton.subId("28");
apButton.subAmount("79.00");
apButton.render("aeropay-button-container");

subscription with custom button, not passing a selected amount

Code Example

window.AeroPay.init({
  env: "staging"
});

var onSuccess = function(result) {
  console.log(result);
};

// event callback is optional 
var onEvent = function(event) {
  console.log(event);
};

var apButton = window.AeroPay.button({
  location: "6ced28ccc4",
  type: "subscription",
  onSuccess: onSuccess,
  onEvent: onEvent  // optional
});

document
  .getElementById("my-aeropay-button")
  .addEventListener("click",
    function apClickEvent() {
      apButton.launchSub("28");
    });