@astropay/payments-lib 2.0.22 → 2.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/astropay-payments-lib.es.js +6 -5
- package/dist/astropay-payments-lib.umd.js +29 -9
- package/dist/{main-DChoo5ch.js → main-D6KiGA5-.js} +178 -9
- package/dist/main.d.ts +2 -1
- package/dist/{profiler-DD6Lx2mk.js → profiler-BftqmTdG.js} +1 -1
- package/dist/public/AstroPaySinglePaymentMethod/index.d.ts +61 -0
- package/dist/{startRecording-Cbikqz3n.js → startRecording-CKEF3p21.js} +1 -1
- package/dist/types/index.d.ts +8 -1
- package/package.json +1 -1
|
@@ -3287,11 +3287,11 @@ instance.setDefaultNamespace;
|
|
|
3287
3287
|
instance.hasLoadedNamespace;
|
|
3288
3288
|
instance.loadNamespaces;
|
|
3289
3289
|
instance.loadLanguages;
|
|
3290
|
-
const translation$2 = { additional_information: "Additional information", almost_done: "Almost done...", already_paid: "Already paid?", astro_express_checkout: "Express checkout", check_payment_status: "Check payment status", checkout_method: "Checkout method", or: "OR", email: "E-mail", enter_country_code: "Please enter a country or code", enter_your_email: "Enter your e-mail", enter_your_document_number: "Enter your document number", enter_your_document_type: "Select a document type", enter_your_first_name: "Enter your first name", enter_your_last_name: "Enter your last name", enter_your_phone: "Enter your phone number", continue: "Continue", copied: "Copied!", copy_payment_link: "Copy payment link", document_number: "Document number", document_type: "Document type", do_not_close_window: "Please do not close this window.", didnt_receive: "Didn't receive it?", first_name: "First name", generic_error: "An error occurred. Please try again.", hold_on: "Hold on!", invalid_field: "Invalid field", last_name: "Last name", loading_wait: "Loading, please wait...", pay_amount: "Pay {{amount}}", payment_amount: "Payment amount", push_notification_sent: "We sent a push notification to your app", qr_code: "QR code", required_field: "Required Field", scan_qr_copy_link: "Scan the QR code with your phone's camera or copy the link.", select: "Select", select_item: "Select an item", time_up: "Time's up!", try_again: "Try again", waiting_confirmation: "Waiting for confirmation...", card_holder_label: "Cardholder name", card_holder_placeholder: "Full name as on card", card_number: "Card number", card_exp_date: "Expiration date", card_tokenization_error: "We couldn't process your card payment. Please check your details and try again.", payment_processing: "Processing your payment...", payment_still_processing: "This is taking a bit longer than usual, please hold on...", save_card_title: "Save this card", save_card_subtitle: "Pay faster next time", saved_cards_title: "Saved cards", pay_with_new_card: "Use another card", credit: "Credit", debit: "Debit", expires: "Exp.", cvv_security_hint: "We ask every time for security. It's the 3 digits on the back of your card.", delete_card_label: "Delete card", delete_card_confirm: "Remove this card?", delete_card_confirm_action: "Delete", delete_card_cancel_label: "Cancel", delete_card_error: "Could not remove card. Please try again." }, en$1 = {
|
|
3290
|
+
const translation$2 = { additional_information: "Additional information", almost_done: "Almost done...", already_paid: "Already paid?", astro_express_checkout: "Express checkout", check_payment_status: "Check payment status", checkout_method: "Checkout method", or: "OR", email: "E-mail", enter_country_code: "Please enter a country or code", enter_your_email: "Enter your e-mail", enter_your_document_number: "Enter your document number", enter_your_document_type: "Select a document type", enter_your_first_name: "Enter your first name", enter_your_last_name: "Enter your last name", enter_your_phone: "Enter your phone number", continue: "Continue", copied: "Copied!", copy_payment_link: "Copy payment link", document_number: "Document number", document_type: "Document type", do_not_close_window: "Please do not close this window.", didnt_receive: "Didn't receive it?", first_name: "First name", generic_error: "An error occurred. Please try again.", hold_on: "Hold on!", invalid_field: "Invalid field", last_name: "Last name", loading_wait: "Loading, please wait...", pay_amount: "Pay {{amount}}", payment_amount: "Payment amount", payment_method_unavailable: "Payment method not available.", push_notification_sent: "We sent a push notification to your app", qr_code: "QR code", required_field: "Required Field", scan_qr_copy_link: "Scan the QR code with your phone's camera or copy the link.", select: "Select", select_item: "Select an item", time_up: "Time's up!", try_again: "Try again", waiting_confirmation: "Waiting for confirmation...", card_holder_label: "Cardholder name", card_holder_placeholder: "Full name as on card", card_number: "Card number", card_exp_date: "Expiration date", card_tokenization_error: "We couldn't process your card payment. Please check your details and try again.", payment_processing: "Processing your payment...", payment_still_processing: "This is taking a bit longer than usual, please hold on...", save_card_title: "Save this card", save_card_subtitle: "Pay faster next time", saved_cards_title: "Saved cards", pay_with_new_card: "Use another card", credit: "Credit", debit: "Debit", expires: "Exp.", cvv_security_hint: "We ask every time for security. It's the 3 digits on the back of your card.", delete_card_label: "Delete card", delete_card_confirm: "Remove this card?", delete_card_confirm_action: "Delete", delete_card_cancel_label: "Cancel", delete_card_error: "Could not remove card. Please try again." }, en$1 = {
|
|
3291
3291
|
translation: translation$2
|
|
3292
|
-
}, translation$1 = { additional_information: "Información adicional", almost_done: "Casi listo...", already_paid: "Ya pagaste?", astro_express_checkout: "Pago express", check_payment_status: "Ver estado del pago", checkout_method: "Método de pago", or: "O", email: "Correo electrónico", enter_country_code: "Introduce el país o código del país", enter_your_email: "Ingrese su correo electrónico", enter_your_document_number: "Ingrese su número de documento", enter_your_document_type: "Seleccione un tipo de documento", enter_your_first_name: "Ingrese su nombre", enter_your_last_name: "Ingrese su apellido", enter_your_phone: "Introduzca su número de teléfono", continue: "Continuar", copied: "Copiado!", copy_payment_link: "Copiar enlace de pago", document_number: "Número de documento", document_type: "Tipo de documento", do_not_close_window: "Por favor, no cierres esta ventana.", didnt_receive: "No lo recibiste?", first_name: "Nombre", generic_error: "Ocurrió un error. Por favor, inténtelo de nuevo.", hold_on: "¡Un instante...!", invalid_field: "Campo inválido", last_name: "Apellido", loading_wait: "Cargando, aguantá un toque...", pay_amount: "Pagar {{amount}}", payment_amount: "Monto a pagar", push_notification_sent: "Enviamos una notificación push a tu app", qr_code: "código QR", required_field: "Campo Requerido", scan_qr_copy_link: "Escaneá el código QR con la cámara de tu teléfono o copia el enlace.", select: "Seleccionar", select_item: "Selecciona una opción", time_up: "Se acabó el tiempo!", try_again: "Inténtalo de nuevo", waiting_confirmation: "Esperando confirmación...", card_holder_label: "Nombre del titular", card_holder_placeholder: "Nombre completo en la tarjeta", card_number: "Número de tarjeta", card_exp_date: "Fecha de vencimiento", card_tokenization_error: "No pudimos procesar tu pago con tarjeta. Verificá los datos y volvé a intentarlo.", payment_processing: "Procesando tu pago...", payment_still_processing: "Está tardando un poco más de lo habitual, estamos verificando su estado.", save_card_title: "Guardar esta tarjeta", save_card_subtitle: "Para pagar más rápido la próxima vez", saved_cards_title: "Tarjetas guardadas", pay_with_new_card: "Usar otra tarjeta", credit: "Crédito", debit: "Débito", expires: "Vence", cvv_security_hint: "Lo pedimos cada vez por seguridad. Son los 3 dígitos al dorso de tu tarjeta.", delete_card_label: "Eliminar tarjeta", delete_card_confirm: "¿Eliminar esta tarjeta?", delete_card_confirm_action: "Eliminar", delete_card_cancel_label: "Cancelar", delete_card_error: "No se pudo eliminar la tarjeta. Inténtalo de nuevo." }, es = {
|
|
3292
|
+
}, translation$1 = { additional_information: "Información adicional", almost_done: "Casi listo...", already_paid: "Ya pagaste?", astro_express_checkout: "Pago express", check_payment_status: "Ver estado del pago", checkout_method: "Método de pago", or: "O", email: "Correo electrónico", enter_country_code: "Introduce el país o código del país", enter_your_email: "Ingrese su correo electrónico", enter_your_document_number: "Ingrese su número de documento", enter_your_document_type: "Seleccione un tipo de documento", enter_your_first_name: "Ingrese su nombre", enter_your_last_name: "Ingrese su apellido", enter_your_phone: "Introduzca su número de teléfono", continue: "Continuar", copied: "Copiado!", copy_payment_link: "Copiar enlace de pago", document_number: "Número de documento", document_type: "Tipo de documento", do_not_close_window: "Por favor, no cierres esta ventana.", didnt_receive: "No lo recibiste?", first_name: "Nombre", generic_error: "Ocurrió un error. Por favor, inténtelo de nuevo.", hold_on: "¡Un instante...!", invalid_field: "Campo inválido", last_name: "Apellido", loading_wait: "Cargando, aguantá un toque...", pay_amount: "Pagar {{amount}}", payment_amount: "Monto a pagar", payment_method_unavailable: "Método de pago no disponible.", push_notification_sent: "Enviamos una notificación push a tu app", qr_code: "código QR", required_field: "Campo Requerido", scan_qr_copy_link: "Escaneá el código QR con la cámara de tu teléfono o copia el enlace.", select: "Seleccionar", select_item: "Selecciona una opción", time_up: "Se acabó el tiempo!", try_again: "Inténtalo de nuevo", waiting_confirmation: "Esperando confirmación...", card_holder_label: "Nombre del titular", card_holder_placeholder: "Nombre completo en la tarjeta", card_number: "Número de tarjeta", card_exp_date: "Fecha de vencimiento", card_tokenization_error: "No pudimos procesar tu pago con tarjeta. Verificá los datos y volvé a intentarlo.", payment_processing: "Procesando tu pago...", payment_still_processing: "Está tardando un poco más de lo habitual, estamos verificando su estado.", save_card_title: "Guardar esta tarjeta", save_card_subtitle: "Para pagar más rápido la próxima vez", saved_cards_title: "Tarjetas guardadas", pay_with_new_card: "Usar otra tarjeta", credit: "Crédito", debit: "Débito", expires: "Vence", cvv_security_hint: "Lo pedimos cada vez por seguridad. Son los 3 dígitos al dorso de tu tarjeta.", delete_card_label: "Eliminar tarjeta", delete_card_confirm: "¿Eliminar esta tarjeta?", delete_card_confirm_action: "Eliminar", delete_card_cancel_label: "Cancelar", delete_card_error: "No se pudo eliminar la tarjeta. Inténtalo de nuevo." }, es = {
|
|
3293
3293
|
translation: translation$1
|
|
3294
|
-
}, translation = { additional_information: "Informações adicionais", almost_done: "Finalizando...", already_paid: "Já pagou?", astro_express_checkout: "Pagamento expresso", check_payment_status: "Verificar status do pagamento", checkout_method: "Método de pagamento", or: "OU", email: "E-mail", enter_country_code: "Informe um país ou código", enter_your_email: "Digite seu e-mail", enter_your_document_number: "Digite seu número de documento", enter_your_document_type: "Selecione um tipo de documento", enter_your_first_name: "Digite seu primeiro nome", enter_your_last_name: "Digite seu sobrenome", enter_your_phone: "Digite seu número de telefone", continue: "Continuar", copied: "Copiado!", copy_payment_link: "Copiar link de pagamento", document_number: "Número do documento", document_type: "Tipo de documento", do_not_close_window: "Por favor, não feche esta janela.", didnt_receive: "Não recebeu?", first_name: "Primeiro nome", generic_error: "Ocorreu um erro. Por favor, tente novamente.", hold_on: "Só um instante!", invalid_field: "Campo inválido", last_name: "Sobrenome", loading_wait: "Carregando, por favor aguarde...", pay_amount: "Pagar {{amount}}", payment_amount: "Valor do pagamento", push_notification_sent: "Enviamos uma notificação push para seu app", qr_code: "QR code", required_field: "Campo Obrigatório", scan_qr_copy_link: "Escaneie o QR código com a câmera do seu celular ou copie o link.", select: "Selecione", select_item: "Selecione um item", time_up: "Tempo esgotado!", try_again: "Tente novamente", waiting_confirmation: "Aguardando confirmação...", card_holder_label: "Nome do titular", card_holder_placeholder: "Nome completo no cartão", card_number: "Número do cartão", card_exp_date: "Data de validade", card_tokenization_error: "Não foi possível processar seu pagamento com o cartão. Verifique os dados e tente novamente.", payment_processing: "Processando seu pagamento...", payment_still_processing: "Está demorando um pouco mais que o usual, por favor aguarde...", save_card_title: "Salvar este cartão", save_card_subtitle: "Para pagar mais rápido na próxima vez", saved_cards_title: "Cartões salvos", pay_with_new_card: "Usar outro cartão", credit: "Crédito", debit: "Débito", expires: "Vence", cvv_security_hint: "Pedimos sempre por segurança. São os 3 dígitos no verso do cartão.", delete_card_label: "Remover cartão", delete_card_confirm: "Remover este cartão?", delete_card_confirm_action: "Remover", delete_card_cancel_label: "Cancelar", delete_card_error: "Não foi possível remover o cartão. Tente novamente." }, pt$1 = {
|
|
3294
|
+
}, translation = { additional_information: "Informações adicionais", almost_done: "Finalizando...", already_paid: "Já pagou?", astro_express_checkout: "Pagamento expresso", check_payment_status: "Verificar status do pagamento", checkout_method: "Método de pagamento", or: "OU", email: "E-mail", enter_country_code: "Informe um país ou código", enter_your_email: "Digite seu e-mail", enter_your_document_number: "Digite seu número de documento", enter_your_document_type: "Selecione um tipo de documento", enter_your_first_name: "Digite seu primeiro nome", enter_your_last_name: "Digite seu sobrenome", enter_your_phone: "Digite seu número de telefone", continue: "Continuar", copied: "Copiado!", copy_payment_link: "Copiar link de pagamento", document_number: "Número do documento", document_type: "Tipo de documento", do_not_close_window: "Por favor, não feche esta janela.", didnt_receive: "Não recebeu?", first_name: "Primeiro nome", generic_error: "Ocorreu um erro. Por favor, tente novamente.", hold_on: "Só um instante!", invalid_field: "Campo inválido", last_name: "Sobrenome", loading_wait: "Carregando, por favor aguarde...", pay_amount: "Pagar {{amount}}", payment_amount: "Valor do pagamento", payment_method_unavailable: "Método de pagamento não disponível.", push_notification_sent: "Enviamos uma notificação push para seu app", qr_code: "QR code", required_field: "Campo Obrigatório", scan_qr_copy_link: "Escaneie o QR código com a câmera do seu celular ou copie o link.", select: "Selecione", select_item: "Selecione um item", time_up: "Tempo esgotado!", try_again: "Tente novamente", waiting_confirmation: "Aguardando confirmação...", card_holder_label: "Nome do titular", card_holder_placeholder: "Nome completo no cartão", card_number: "Número do cartão", card_exp_date: "Data de validade", card_tokenization_error: "Não foi possível processar seu pagamento com o cartão. Verifique os dados e tente novamente.", payment_processing: "Processando seu pagamento...", payment_still_processing: "Está demorando um pouco mais que o usual, por favor aguarde...", save_card_title: "Salvar este cartão", save_card_subtitle: "Para pagar mais rápido na próxima vez", saved_cards_title: "Cartões salvos", pay_with_new_card: "Usar outro cartão", credit: "Crédito", debit: "Débito", expires: "Vence", cvv_security_hint: "Pedimos sempre por segurança. São os 3 dígitos no verso do cartão.", delete_card_label: "Remover cartão", delete_card_confirm: "Remover este cartão?", delete_card_confirm_action: "Remover", delete_card_cancel_label: "Cancelar", delete_card_error: "Não foi possível remover o cartão. Tente novamente." }, pt$1 = {
|
|
3295
3295
|
translation
|
|
3296
3296
|
}, LOCAL_TRANSLATIONS = {
|
|
3297
3297
|
en: en$1,
|
|
@@ -3342,7 +3342,7 @@ class LoadingSuccess extends Component {
|
|
|
3342
3342
|
const RUNTIME_CONFIG = {
|
|
3343
3343
|
test: {
|
|
3344
3344
|
NAME: "@astropay/payments-lib",
|
|
3345
|
-
VERSION: "2.0.
|
|
3345
|
+
VERSION: "2.0.23",
|
|
3346
3346
|
MODE: "test",
|
|
3347
3347
|
API_BASE_URL: "https://partners-api-tst.astropay.com/api",
|
|
3348
3348
|
RESOURCES_BUCKET: "https://rs-tst.astropay.com",
|
|
@@ -3352,7 +3352,7 @@ const RUNTIME_CONFIG = {
|
|
|
3352
3352
|
},
|
|
3353
3353
|
sandbox: {
|
|
3354
3354
|
NAME: "@astropay/payments-lib",
|
|
3355
|
-
VERSION: "2.0.
|
|
3355
|
+
VERSION: "2.0.23",
|
|
3356
3356
|
MODE: "staging",
|
|
3357
3357
|
API_BASE_URL: "https://partners-api-sandbox.astropay.com/api",
|
|
3358
3358
|
RESOURCES_BUCKET: "https://rs-tst.astropay.com",
|
|
@@ -3362,7 +3362,7 @@ const RUNTIME_CONFIG = {
|
|
|
3362
3362
|
},
|
|
3363
3363
|
production: {
|
|
3364
3364
|
NAME: "@astropay/payments-lib",
|
|
3365
|
-
VERSION: "2.0.
|
|
3365
|
+
VERSION: "2.0.23",
|
|
3366
3366
|
MODE: "production",
|
|
3367
3367
|
API_BASE_URL: "https://partners-api.astropay.com/api",
|
|
3368
3368
|
RESOURCES_BUCKET: "https://rs.astropay.com",
|
|
@@ -9641,7 +9641,7 @@ async function lazyLoadRecorder(ee = importRecorder) {
|
|
|
9641
9641
|
async function importRecorder() {
|
|
9642
9642
|
return (await import(
|
|
9643
9643
|
/* webpackChunkName: "recorder" */
|
|
9644
|
-
"./startRecording-
|
|
9644
|
+
"./startRecording-CKEF3p21.js"
|
|
9645
9645
|
)).startRecording;
|
|
9646
9646
|
}
|
|
9647
9647
|
function isProfilingSupported() {
|
|
@@ -9661,7 +9661,7 @@ async function lazyLoadProfiler(ee = importProfiler) {
|
|
|
9661
9661
|
async function importProfiler() {
|
|
9662
9662
|
return (await import(
|
|
9663
9663
|
/* webpackChunkName: "profiler" */
|
|
9664
|
-
"./profiler-
|
|
9664
|
+
"./profiler-BftqmTdG.js"
|
|
9665
9665
|
)).createRumProfiler;
|
|
9666
9666
|
}
|
|
9667
9667
|
function makeProfilerApi() {
|
|
@@ -34375,7 +34375,8 @@ class PaymentMethod extends Component {
|
|
|
34375
34375
|
text: `${te.text} ${formatAmountCurrency(te.amount, te.currency, AstroPayConfig.getCurrencyMode())}`,
|
|
34376
34376
|
size: "medium",
|
|
34377
34377
|
lineHeight: 24,
|
|
34378
|
-
weight: 600
|
|
34378
|
+
weight: 600,
|
|
34379
|
+
align: "center"
|
|
34379
34380
|
}).element;
|
|
34380
34381
|
this.element.append(ne);
|
|
34381
34382
|
}
|
|
@@ -34953,6 +34954,173 @@ class AstroPayPayment extends Component {
|
|
|
34953
34954
|
this.element.remove(), AstroPayCore.unregisterComponent(this);
|
|
34954
34955
|
}
|
|
34955
34956
|
}
|
|
34957
|
+
const EXCLUDED_METHOD_CODES = [...CARDS_METHOD, EPaymentCode.AP], isSupportedSinglePaymentMethodCode = (ee) => typeof ee == "string" && ee.trim() !== "" && !EXCLUDED_METHOD_CODES.some((re) => re === ee), findRequestedPaymentMethod = (ee, re) => ee == null ? void 0 : ee.find((te) => te.code === re && te.enabled), getAstroPaySinglePaymentMethodStyles = (ee) => css`
|
|
34958
|
+
background-color: ${ee.backgroundColor};
|
|
34959
|
+
|
|
34960
|
+
display: flex;
|
|
34961
|
+
flex-direction: column;
|
|
34962
|
+
gap: 12px;
|
|
34963
|
+
|
|
34964
|
+
max-width: ${typeof ee.width == "number" ? `${ee.width}px` : ee.width};
|
|
34965
|
+
padding: ${typeof ee.paddingWrapper == "number" ? `${ee.paddingWrapper}px` : ee.paddingWrapper};
|
|
34966
|
+
border-radius: ${typeof ee.borderRadiusWrapper == "number" ? `${ee.borderRadiusWrapper}px` : ee.borderRadiusWrapper};
|
|
34967
|
+
|
|
34968
|
+
.ap-single-payment-method-loading {
|
|
34969
|
+
display: flex;
|
|
34970
|
+
flex-direction: column;
|
|
34971
|
+
justify-content: center;
|
|
34972
|
+
align-items: center;
|
|
34973
|
+
width: 100%;
|
|
34974
|
+
gap: 8px;
|
|
34975
|
+
min-height: 250px;
|
|
34976
|
+
}
|
|
34977
|
+
`, INITIALIZER = "single_payment_method";
|
|
34978
|
+
class AstroPaySinglePaymentMethod extends Component {
|
|
34979
|
+
constructor(te) {
|
|
34980
|
+
super({
|
|
34981
|
+
tag: "div",
|
|
34982
|
+
styles: (ae) => getAstroPaySinglePaymentMethodStyles(ae)
|
|
34983
|
+
});
|
|
34984
|
+
Ie(this, "componentProps");
|
|
34985
|
+
Ie(this, "loadingWrapper", null);
|
|
34986
|
+
Ie(this, "paymentMethod", null);
|
|
34987
|
+
// Set by destroy(); async/queued work checks it so nothing renders or calls back afterwards.
|
|
34988
|
+
Ie(this, "isDestroyed", !1);
|
|
34989
|
+
const ne = te.showTitle ?? !0, ie = te.paymentMethodCode, oe = typeof ie == "string" ? ie.trim().toUpperCase() : ie;
|
|
34990
|
+
if (this.componentProps = te.paymentExternalId !== void 0 ? { ...te, showTitle: ne, paymentMethodCode: oe } : {
|
|
34991
|
+
...te,
|
|
34992
|
+
showTitle: ne,
|
|
34993
|
+
paymentMethodCode: oe,
|
|
34994
|
+
country: te.country.trim().toUpperCase(),
|
|
34995
|
+
currency: te.currency.trim().toUpperCase()
|
|
34996
|
+
}, AstroPayCore.registerComponent(this), AmplitudeAnalytics$1.astroPayPaymentImpression("AstroPaySinglePaymentMethod"), DataDogTracker.trackEvent("ap_cl_astropay_single_payment_method_init"), !isSupportedSinglePaymentMethodCode(this.componentProps.paymentMethodCode)) {
|
|
34997
|
+
this.showErrorMessage(AstroPayI18n.translate("payment_method_unavailable")), queueMicrotask(() => {
|
|
34998
|
+
var ae, ce;
|
|
34999
|
+
this.isDestroyed || (ce = (ae = this.componentProps).onError) == null || ce.call(ae);
|
|
35000
|
+
});
|
|
35001
|
+
return;
|
|
35002
|
+
}
|
|
35003
|
+
this.loadingWrapper = document.createElement("div"), this.loadingWrapper.classList.add("ap-single-payment-method-loading");
|
|
35004
|
+
const se = new Loading({
|
|
35005
|
+
size: 100,
|
|
35006
|
+
variant: "fetching",
|
|
35007
|
+
color: ThemeManager.getStyles().primaryColor
|
|
35008
|
+
}).element;
|
|
35009
|
+
this.loadingWrapper.append(se), this.element.appendChild(this.loadingWrapper), this.createPayment();
|
|
35010
|
+
}
|
|
35011
|
+
async createPayment() {
|
|
35012
|
+
var ne, ie;
|
|
35013
|
+
const te = this.componentProps;
|
|
35014
|
+
try {
|
|
35015
|
+
let oe;
|
|
35016
|
+
if (te.paymentExternalId !== void 0 ? oe = await PaymentService.getPaymentDetails(te.paymentExternalId, INITIALIZER) : oe = await PaymentService.postCreatePayment(
|
|
35017
|
+
{
|
|
35018
|
+
country: te.country,
|
|
35019
|
+
currency: te.currency,
|
|
35020
|
+
amount: te.amount,
|
|
35021
|
+
order: te.order,
|
|
35022
|
+
methodCode: te.paymentMethodCode
|
|
35023
|
+
},
|
|
35024
|
+
INITIALIZER
|
|
35025
|
+
), this.isDestroyed)
|
|
35026
|
+
return;
|
|
35027
|
+
this.renderPaymentMethod(oe);
|
|
35028
|
+
} catch (oe) {
|
|
35029
|
+
if (this.isDestroyed)
|
|
35030
|
+
return;
|
|
35031
|
+
const se = oe;
|
|
35032
|
+
(ne = te.onError) == null || ne.call(te), this.showErrorMessage(se.description ?? se.message);
|
|
35033
|
+
} finally {
|
|
35034
|
+
(ie = this.loadingWrapper) == null || ie.remove();
|
|
35035
|
+
}
|
|
35036
|
+
}
|
|
35037
|
+
renderPaymentMethod(te) {
|
|
35038
|
+
var ie, oe;
|
|
35039
|
+
const ne = findRequestedPaymentMethod(
|
|
35040
|
+
te.paymentMethods,
|
|
35041
|
+
this.componentProps.paymentMethodCode
|
|
35042
|
+
);
|
|
35043
|
+
if (ne === void 0) {
|
|
35044
|
+
(oe = (ie = this.componentProps).onError) == null || oe.call(ie), this.showErrorMessage(AstroPayI18n.translate("payment_method_unavailable"));
|
|
35045
|
+
return;
|
|
35046
|
+
}
|
|
35047
|
+
if (this.element.innerHTML = "", this.componentProps.showTitle === !0 && ne.label.trim() !== "") {
|
|
35048
|
+
const se = new Typography({
|
|
35049
|
+
text: ne.label,
|
|
35050
|
+
variant: "div",
|
|
35051
|
+
size: ThemeManager.getFontScale().small,
|
|
35052
|
+
weight: 600
|
|
35053
|
+
}).element;
|
|
35054
|
+
se.classList.add("ap-single-payment-method-title"), this.element.append(se);
|
|
35055
|
+
}
|
|
35056
|
+
this.paymentMethod = new PaymentMethod({
|
|
35057
|
+
paymentExternalId: te.paymentExternalId,
|
|
35058
|
+
paymentMethod: ne,
|
|
35059
|
+
onSuccess: (se) => this.showResultScreen(se, {
|
|
35060
|
+
type: "success",
|
|
35061
|
+
onSuccess: this.componentProps.onSuccess
|
|
35062
|
+
}),
|
|
35063
|
+
onError: (se) => this.showResultScreen(se, {
|
|
35064
|
+
type: "error",
|
|
35065
|
+
onError: this.componentProps.onError
|
|
35066
|
+
})
|
|
35067
|
+
}), this.element.append(this.paymentMethod.element);
|
|
35068
|
+
}
|
|
35069
|
+
showErrorMessage(te) {
|
|
35070
|
+
this.element.innerHTML = "";
|
|
35071
|
+
const ne = new Typography({
|
|
35072
|
+
text: te,
|
|
35073
|
+
size: ThemeManager.getFontScale().xSmall,
|
|
35074
|
+
color: ThemeManager.getStyles().messages.error.textColor
|
|
35075
|
+
}).element;
|
|
35076
|
+
this.element.append(ne);
|
|
35077
|
+
}
|
|
35078
|
+
showResultScreen(te, ne) {
|
|
35079
|
+
var oe;
|
|
35080
|
+
(oe = this.paymentMethod) == null || oe.destroy(), this.paymentMethod = null, this.element.innerHTML = "";
|
|
35081
|
+
const ie = new ResultScreen({
|
|
35082
|
+
type: ne.type,
|
|
35083
|
+
contentElements: te,
|
|
35084
|
+
onSuccess: ne.onSuccess,
|
|
35085
|
+
onError: ne.onError
|
|
35086
|
+
});
|
|
35087
|
+
this.element.append(ie.element);
|
|
35088
|
+
}
|
|
35089
|
+
/**
|
|
35090
|
+
* Renders the payment component into the specified DOM container.
|
|
35091
|
+
*
|
|
35092
|
+
* @example
|
|
35093
|
+
* ```ts
|
|
35094
|
+
* const paymentComponent = new AstroPaySinglePaymentMethod(paymentSettings);
|
|
35095
|
+
* paymentComponent.render(document.getElementById('payment-container'));
|
|
35096
|
+
* ```
|
|
35097
|
+
*
|
|
35098
|
+
* @param {HTMLElement} container - The DOM element to render the payment component into.
|
|
35099
|
+
*/
|
|
35100
|
+
render(te) {
|
|
35101
|
+
if (!te)
|
|
35102
|
+
throw new Error("Container element not found");
|
|
35103
|
+
te.appendChild(this.element);
|
|
35104
|
+
}
|
|
35105
|
+
/**
|
|
35106
|
+
* Destroys the payment component instance, cleaning up all DOM elements
|
|
35107
|
+
* and unregistering from the AstroPay Payments Library.
|
|
35108
|
+
*
|
|
35109
|
+
* @example
|
|
35110
|
+
* ```ts
|
|
35111
|
+
* // Initialize and render component
|
|
35112
|
+
* const paymentComponent = new AstroPaySinglePaymentMethod(paymentSettings);
|
|
35113
|
+
* paymentComponent.render(container);
|
|
35114
|
+
*
|
|
35115
|
+
* // Later cleanup
|
|
35116
|
+
* paymentComponent.destroy();
|
|
35117
|
+
* ```
|
|
35118
|
+
*/
|
|
35119
|
+
destroy() {
|
|
35120
|
+
var te;
|
|
35121
|
+
this.isDestroyed = !0, (te = this.paymentMethod) == null || te.destroy(), this.paymentMethod = null, this.element.remove(), AstroPayCore.unregisterComponent(this);
|
|
35122
|
+
}
|
|
35123
|
+
}
|
|
34956
35124
|
loadFonts();
|
|
34957
35125
|
export {
|
|
34958
35126
|
AstroPayCore as $,
|
|
@@ -34986,6 +35154,7 @@ export {
|
|
|
34986
35154
|
CENSORED_IMG_MARK as a,
|
|
34987
35155
|
AstroPayFullCheckout as a0,
|
|
34988
35156
|
AstroPayPayment as a1,
|
|
35157
|
+
AstroPaySinglePaymentMethod as a2,
|
|
34989
35158
|
buildUrl as b,
|
|
34990
35159
|
isLongDataUrl as c,
|
|
34991
35160
|
sanitizeDataUrl as d,
|
package/dist/main.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import { AstroPayCardPayment } from './public/AstroPayCardPayment';
|
|
|
2
2
|
import { AstroPayCore } from './public/AstroPayCore';
|
|
3
3
|
import { AstroPayFullCheckout } from './public/AstroPayFullCheckout';
|
|
4
4
|
import { AstroPayPayment } from './public/AstroPayPayment';
|
|
5
|
-
|
|
5
|
+
import { AstroPaySinglePaymentMethod } from './public/AstroPaySinglePaymentMethod';
|
|
6
|
+
export { AstroPayCardPayment, AstroPayCore, AstroPayCore as Core, AstroPayFullCheckout, AstroPayPayment, AstroPaySinglePaymentMethod, };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Component } from '../../components/templates/Component';
|
|
2
|
+
import { APSinglePaymentMethod } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* AstroPaySinglePaymentMethod renders exactly one generic payment method selected by
|
|
5
|
+
* `paymentMethodCode` (e.g. QR Code `QA`). Card methods and the AstroPay wallet
|
|
6
|
+
* are not supported here — use `AstroPayCardPayment` / `AstroPayPayment` instead.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const payment = new AstroPaySinglePaymentMethod({
|
|
11
|
+
* amount: 100,
|
|
12
|
+
* currency: 'USD',
|
|
13
|
+
* country: 'AR',
|
|
14
|
+
* paymentMethodCode: 'QA',
|
|
15
|
+
* // Optional props
|
|
16
|
+
* showTitle: true,
|
|
17
|
+
* onSuccess: () => console.log('Payment successful'),
|
|
18
|
+
* onError: () => console.error('Payment failed')
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @see {@link APSinglePaymentMethod} for all available configuration options
|
|
23
|
+
*/
|
|
24
|
+
export declare class AstroPaySinglePaymentMethod extends Component<HTMLDivElement> {
|
|
25
|
+
private readonly componentProps;
|
|
26
|
+
private loadingWrapper;
|
|
27
|
+
private paymentMethod;
|
|
28
|
+
private isDestroyed;
|
|
29
|
+
constructor(params: APSinglePaymentMethod);
|
|
30
|
+
private createPayment;
|
|
31
|
+
private renderPaymentMethod;
|
|
32
|
+
private showErrorMessage;
|
|
33
|
+
private showResultScreen;
|
|
34
|
+
/**
|
|
35
|
+
* Renders the payment component into the specified DOM container.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const paymentComponent = new AstroPaySinglePaymentMethod(paymentSettings);
|
|
40
|
+
* paymentComponent.render(document.getElementById('payment-container'));
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @param {HTMLElement} container - The DOM element to render the payment component into.
|
|
44
|
+
*/
|
|
45
|
+
render(container: HTMLElement): void;
|
|
46
|
+
/**
|
|
47
|
+
* Destroys the payment component instance, cleaning up all DOM elements
|
|
48
|
+
* and unregistering from the AstroPay Payments Library.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* // Initialize and render component
|
|
53
|
+
* const paymentComponent = new AstroPaySinglePaymentMethod(paymentSettings);
|
|
54
|
+
* paymentComponent.render(container);
|
|
55
|
+
*
|
|
56
|
+
* // Later cleanup
|
|
57
|
+
* paymentComponent.destroy();
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
destroy(): void;
|
|
61
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as A, C, b as ft, i as Y, g as V, N as h, P as X, S as pt, a as B, c as ht, d as mt, e as St, f as q, r as gt, h as Et, j as yt, k as Tt, l as j, m as J, t as _, n as x, o as M, p as K, q as N, u as Q, v as Z, w as Nt, x as vt, y as b, z as D, A as R, B as wt, D as Mt, E as It, F as Rt, G as Ct, H as bt, I as _t, J as Lt, K as Dt, L as xt, M as Ot, O as At, Q as Vt, R as Pt, T as kt, U as zt } from "./main-
|
|
1
|
+
import { s as A, C, b as ft, i as Y, g as V, N as h, P as X, S as pt, a as B, c as ht, d as mt, e as St, f as q, r as gt, h as Et, j as yt, k as Tt, l as j, m as J, t as _, n as x, o as M, p as K, q as N, u as Q, v as Z, w as Nt, x as vt, y as b, z as D, A as R, B as wt, D as Mt, E as It, F as Rt, G as Ct, H as bt, I as _t, J as Lt, K as Dt, L as xt, M as Ot, O as At, Q as Vt, R as Pt, T as kt, U as zt } from "./main-D6KiGA5-.js";
|
|
2
2
|
const P = /* @__PURE__ */ new WeakMap();
|
|
3
3
|
function T(t) {
|
|
4
4
|
return P.has(t);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -331,4 +331,11 @@ type APCardPayment = TPaymentIdentity & {
|
|
|
331
331
|
onSuccess?: () => void;
|
|
332
332
|
onError?: () => void;
|
|
333
333
|
};
|
|
334
|
-
|
|
334
|
+
type APSinglePaymentMethod = TPaymentIdentity & {
|
|
335
|
+
paymentMethodCode: string;
|
|
336
|
+
showTitle?: boolean;
|
|
337
|
+
order?: TOrderProps | undefined;
|
|
338
|
+
onSuccess?: () => void;
|
|
339
|
+
onError?: () => void;
|
|
340
|
+
};
|
|
341
|
+
export type { APEnvironment, APAvailableTheme, APAvailableLanguages, APAvailableCurrencyMode, APAvailableFontScale, APComponentStyles, APCore, APFullCheckout, APPayment, APCardPayment, APSinglePaymentMethod, TNewPayment, };
|
package/package.json
CHANGED