Promociones

Manejo de promociones con OrkestaPay

Las instancias de OrkestaPay también te permiten configurar eventos de promociones de tarjeta, para ello necesitas pasarle un parámetro opcional adicional a la hora de crear, al montar la referencia de las tarjetas o desde el método orkestapay_card.card_number.mountPromotions, dicho parámetro es promotions_params, el cual es un objeto con las siguientes propiedades:

  • currency (Requerido): Sólo es requerido cuando se agrega la propiedad promotions_params.
  • total_amount (Requerido): Sólo es requerido cuando se agrega la propiedad promotions_params.

Importante: Los eventos de promociones funcionan solamente cuando se le proporcionan las referencias de los inputs del formulario de tarjeta.

Ejemplo de inicialización con la configuración de promociones:

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;
}

Ejemplo de inicialización usando el método orkestapay_card.mount con la configuración de promociones:

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;
}

Ejemplo de inicialización usando el método orkestapay_card.card_number.mountPromotions con la configuración de promociones:

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;
}

Gestionar las promociones acorde al BIN de la tarjeta ingresada

El elemento orkestapay_card.card_number ofrece un evento en donde emite el listado de promociones acorde al BIN de tarjeta ingresado, esto sólo funciona cuando se le pasó la referencia/ID del input de número de tarjeta a la instancia de OrkestaPayCard:

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

Finalizar la instancia de OrkestaPayCard

No olvidar desmontar para que complete y cierre todos los eventos generados con el método unmount:

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