Promotions
  • 18 Jul 2024
  • 2 Minutes to read

Promotions


Article summary

Handling Promotions with OrkestaPay

OrkestaPay instances allow you to configure card promotion events. To do this, you need to pass an optional parameter called promotions_params during card creation, mounting, or using the orkestapay_card.card_number.mountPromotions, method. This parameter is an object with the following properties:

  • currency (Required): Only required when the promotions_params is added.

  • total_amount (Required): Only required when the promotions_params is added.

Important: Promotion events work only when card form input references are provided.

Example of initialization with promotion configuration:

async function createOrkestaPayCard() {
    const card_number = document.getElementById('card-number');
    const expiration_date = document.getElementById('card-expiration');
    const verification_code = document.getElementById('card-verification-code');
    const holder_name = document.getElementById('holder-name');
    const holder_last_name = document.getElementById('holder-last-name');

    const currency = 'USD';
    const total_amount = '100.00';
    const promotions_params = { currency, total_amount };

    const orkestapay_card = await orkestapay.createCard({
        card_number,
        expiration_date,
        verification_code,
        holder_name,
        holder_last_name,
        promotions_params,
    });

    return orkestapay_card;
}

Example of initialization using the method orkestapay_card.mount with the promotion settings:

async function createOrkestaPayCard() {
    const orkestapay_card = await orkestapay.createCard();

    const card_number = document.getElementById('card-number');
    const expiration_month = document.getElementById('card-expiration-month');
    const expiration_year = document.getElementById('card-expiration-year');
    const verification_code = document.getElementById('card-verification-code');
    const holder_name = document.getElementById('holder-name');
    const holder_last_name = document.getElementById('holder-last-name');

    const currency = 'USD';
    const total_amount = '100.00';
    const promotions_params = { currency, total_amount };

    await orkestapay_card.mount({
        card_number,
        expiration_date: {
            expiration_month,
            expiration_year,
        },
        verification_code,
        holder_name,
        holder_last_name,
        promotions_params,
    });

    return orkestapay_card;
}

Example of initialization using the method orkestapay_card.card_number.mountPromotions with the promotion settings:

async function createOrkestaPayCard() {
    const orkestapay_card = await orkestapay.createCard();

    const card_number = document.getElementById('card-number');
    const expiration_month = document.getElementById('card-expiration-month');
    const expiration_year = document.getElementById('card-expiration-year');
    const verification_code = document.getElementById('card-verification-code');
    const holder_name = document.getElementById('holder-name');
    const holder_last_name = document.getElementById('holder-last-name');

    await orkestapay_card.mount({
        card_number,
        expiration_date: {
            expiration_month,
            expiration_year,
        },
        verification_code,
        holder_name,
        holder_last_name,
    });

    const currency = 'USD';
    const total_amount = '100.00';
    const promotions_params = { currency, total_amount };

    await orkestapay_card.card_number.mountPromotions(promotions_params);

    return orkestapay_card;
}

Managing Promotions Based on Entered Card BIN

The orkestapay_card.card_number element provides an event that emits the list of promotions according to the entered card BIN. This only works when the input reference/ID of the card number is passed to the OrkestaPayCard instance:

orkestapay_card.card_number.promotions$.subscribe((promotions) => {
  console.log(promotions);
});

Finalizing the OrkestaPayCard Instance

Don’t forget to unmount to complete and close all generated events:

(async function destroyCard() {
  await orkestapay_card.unmount();
})();


Was this article helpful?

What's Next