Source

types/redirectElement.d.ts

import { ElementOptions, PaymentMethodWithRedirect } from './element';
import { Intent } from './cardNumber';

/**
 * For alipaycn, alipayhk, gcash, dana, kakaopay, tng, rabbit_line_pay
 */
interface RedirectElementPaymentBasicOptions extends ElementOptions {
  /**
   * The payment intent you would like to checkout
   * Refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/Intro)
   *
   */
  intent: Intent;
  method: PaymentMethodWithRedirect;
  mode?: 'payment';
}

/**
 * For poli, grab_pay, konbini, eps, giropay, ideal, multibankco, bancontact, blik
 * mybank, paybybankapp, maxima, narvesen, paypost, perlas_terminals
 */
interface RedirectElementPaymentOptionsForPoli extends RedirectElementPaymentBasicOptions {
  shopper_name?: string;
}

/**
 * For fpx, enets, pay_easy, tesco_lotus, dragonpay, family_mart, hi_life
 * sam_kiosk, axs_kiosk, bigc, esun, permata_atm, boost, shopee_pay
 */
interface RedirectElementPaymentOptionsForFpx extends RedirectElementPaymentBasicOptions {
  shopper_name?: string;
  shopper_email?: string;
  shopper_phone?: string;
}

/**
 * For paysafecash
 */
interface RedirectElementPaymentOptionsForBankTransfer extends RedirectElementPaymentBasicOptions {
  country_code: string;
  shopper_name?: string;
  shopper_email?: string;
}

/**
 * For bank_transfer, online_banking, seven_eleven
 */
interface RedirectElementPaymentOptionsForOnlineBanking extends RedirectElementPaymentBasicOptions {
  country_code: string;
  shopper_name?: string;
  shopper_email?: string;
  shopper_phone?: string;
}

/**
 * For permatanet, alfamart, indomaret, doku_ewallet, p24, verkkopankki
 */
interface RedirectElementPaymentOptionsForDoku extends RedirectElementPaymentBasicOptions {
  shopper_name?: string;
  shopper_email?: string;
}

/**
 * For skrill
 */
interface RedirectElementPaymentOptionsForSkrill extends RedirectElementPaymentBasicOptions {
  shopper_name?: string;
  shopper_email?: string;
  country_code: string;
}

/**
 * For sofort, trustly, paysafecard, satispay, paysera
 */
interface RedirectElementPaymentOptionsForSofort extends RedirectElementPaymentBasicOptions {
  country_code: string;
  shopper_name?: string;
}

type RedirectElementPaymentOptions =
  | RedirectElementPaymentBasicOptions
  | RedirectElementPaymentOptionsForPoli
  | RedirectElementPaymentOptionsForFpx
  | RedirectElementPaymentOptionsForOnlineBanking
  | RedirectElementPaymentOptionsForBankTransfer
  | RedirectElementPaymentOptionsForDoku
  | RedirectElementPaymentOptionsForSkrill;

interface RedirectElementRecurringOptions extends ElementOptions {
  method: PaymentMethodWithRedirect;
  mode: 'recurring';
  /**
   * The client_secret when you create payment intent, generated by `/pa/customers/${customer_id}/generate_client_secret` api
   */
  client_secret: string;
  /**
   * ID from Airwallex of the customer for whom the consent is created
   */
  customer_id: string;
  /**
   * The success return url after shopper succeeded the payment consent
   */
  successUrl: string;
}

/**
 * Apply to Redirect element type integration, interface used when call createElement with type `redirect`
 */
export type RedirectElementOptions = RedirectElementPaymentOptions | RedirectElementRecurringOptions;