From b8c29324b8af3df96881a1937b3a299a3a64b707 Mon Sep 17 00:00:00 2001 From: Alex Turchyn Date: Tue, 28 Jul 2026 19:27:25 +0300 Subject: [PATCH] paypal configs Co-authored-by: Pete Matsyburka --- app/controllers/account_configs_controller.rb | 6 +- .../templates_form_preview_controller.rb | 2 +- app/javascript/application.js | 5 +- app/javascript/form.js | 1 + app/javascript/submission_form/form.vue | 6 + app/javascript/submission_form/i18n.js | 14 ++ .../submission_form/payment_step.vue | 66 +++++++-- app/javascript/template_builder/builder.vue | 26 +++- .../template_builder/field_context_menu.vue | 13 +- .../template_builder/payment_settings.vue | 140 +++++++++++------- config/locales/i18n.yml | 127 ++++++++++++++++ 11 files changed, 334 insertions(+), 72 deletions(-) diff --git a/app/controllers/account_configs_controller.rb b/app/controllers/account_configs_controller.rb index 079866d7..23d82d94 100644 --- a/app/controllers/account_configs_controller.rb +++ b/app/controllers/account_configs_controller.rb @@ -37,7 +37,7 @@ class AccountConfigsController < ApplicationController end def destroy - raise InvalidKey unless allowed_keys.include?(@account_config.key) + raise InvalidKey unless allowed_destroy_keys.include?(@account_config.key) @account_config.destroy! @@ -50,6 +50,10 @@ class AccountConfigsController < ApplicationController ALLOWED_KEYS end + def allowed_destroy_keys + ALLOWED_KEYS + end + def load_account_config raise InvalidKey unless allowed_keys.include?(account_config_params[:key]) diff --git a/app/controllers/templates_form_preview_controller.rb b/app/controllers/templates_form_preview_controller.rb index 5c4f23c6..f5c1d7a6 100644 --- a/app/controllers/templates_form_preview_controller.rb +++ b/app/controllers/templates_form_preview_controller.rb @@ -18,6 +18,6 @@ class TemplatesFormPreviewController < ApplicationController @attachments_index = ActiveStorage::Attachment.where(record: @submitter.submission.submitters, name: :attachments) .preload(:blob).index_by(&:uuid) - @form_configs = Submitters::FormConfigs.call(@submitter) + @form_configs = Submitters::FormConfigs.call(@submitter, SubmitFormController::CONFIG_KEYS) end end diff --git a/app/javascript/application.js b/app/javascript/application.js index 458a7a4e..d834182a 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -181,7 +181,10 @@ safeRegisterElement('template-builder', class extends HTMLElement { authenticityToken: document.querySelector('meta[name="csrf-token"]')?.content, withCustomFields: true, withPayment: this.dataset.withPayment === 'true', - isPaymentConnected: this.dataset.isPaymentConnected === 'true', + isStripeConnected: this.dataset.isPaymentConnected === 'true' || this.dataset.isStripeConnected === 'true', + withStripe: this.dataset.withStripe !== 'false', + withPaypal: this.dataset.withPaypal === 'true', + isPaypalConnected: this.dataset.isPaypalConnected === 'true', withFormula: this.dataset.withFormula === 'true', withSendButton: this.dataset.withSendButton !== 'false', withSignYourselfButton: this.dataset.withSignYourselfButton !== 'false', diff --git a/app/javascript/form.js b/app/javascript/form.js index 75158250..ab9535ca 100644 --- a/app/javascript/form.js +++ b/app/javascript/form.js @@ -35,6 +35,7 @@ safeRegisterElement('submission-form', class extends HTMLElement { scrollPadding: this.dataset.scrollPadding || '-80px', signatureText: this.dataset.signatureText, language: this.dataset.language, + paymentProvider: this.dataset.paymentProvider, dryRun: this.dataset.dryRun === 'true', expand: ['true', 'false'].includes(this.dataset.expand) ? this.dataset.expand === 'true' : null, withSignatureId: this.dataset.withSignatureId === 'true', diff --git a/app/javascript/submission_form/form.vue b/app/javascript/submission_form/form.vue index e61feae5..882d7d08 100644 --- a/app/javascript/submission_form/form.vue +++ b/app/javascript/submission_form/form.vue @@ -560,6 +560,7 @@ :fields="formulaFields" :values="values" :readonly-values="readonlyFieldValues" + :provider="paymentProvider" @attached="attachments.push($event)" @focus="scrollIntoField(currentField)" @submit="!isSubmitting && submitStep()" @@ -1000,6 +1001,11 @@ export default { required: false, default: '' }, + paymentProvider: { + type: String, + required: false, + default: '' + }, values: { type: Object, required: false, diff --git a/app/javascript/submission_form/i18n.js b/app/javascript/submission_form/i18n.js index 71f73125..1da0bd06 100644 --- a/app/javascript/submission_form/i18n.js +++ b/app/javascript/submission_form/i18n.js @@ -107,6 +107,7 @@ const en = { email_has_been_sent: 'Email has been sent', processing: 'Processing', pay_with_stripe: 'Pay with Stripe', + pay_with_paypal: 'Pay with PayPal', reupload: 'Reupload', upload: 'Upload', files: 'Files', @@ -225,6 +226,7 @@ const es = { email_has_been_sent: 'El correo electrónico ha sido enviado', processing: 'Procesando', pay_with_stripe: 'Pagar con Stripe', + pay_with_paypal: 'Pagar con PayPal', reupload: 'Volver a subir', upload: 'Subir', files: 'Archivos', @@ -343,6 +345,7 @@ const it = { email_has_been_sent: "L'email è stata inviata", processing: 'Elaborazione', pay_with_stripe: 'Paga con Stripe', + pay_with_paypal: 'Paga con PayPal', reupload: 'Ricarica', upload: 'Carica', files: 'File', @@ -461,6 +464,7 @@ const de = { email_has_been_sent: 'E-Mail wurde gesendet', processing: 'Verarbeitung', pay_with_stripe: 'Mit Stripe bezahlen', + pay_with_paypal: 'Mit PayPal bezahlen', reupload: 'Erneut hochladen', upload: 'Hochladen', files: 'Dateien', @@ -579,6 +583,7 @@ const fr = { email_has_been_sent: "L'e-mail a été envoyé", processing: 'Traitement en cours', pay_with_stripe: 'Payer avec Stripe', + pay_with_paypal: 'Payer avec PayPal', reupload: 'Retéléverser', upload: 'Téléverser', files: 'Fichiers', @@ -697,6 +702,7 @@ const pl = { email_has_been_sent: 'E-mail został wysłany', processing: 'Przetwarzanie', pay_with_stripe: 'Zapłać za pomocą Stripe', + pay_with_paypal: 'Zapłać za pomocą PayPal', reupload: 'Ponowne przesłanie', upload: 'Przesyłanie', files: 'Pliki', @@ -815,6 +821,7 @@ const uk = { email_has_been_sent: 'Електронний лист був відправлений', processing: 'Обробка', pay_with_stripe: 'Сплатити за допомогою Stripe', + pay_with_paypal: 'Сплатити за допомогою PayPal', reupload: 'Перезавантажити', upload: 'Завантажити', files: 'Файли', @@ -933,6 +940,7 @@ const cs = { email_has_been_sent: 'E-mail byl odeslán', processing: 'Zpracování', pay_with_stripe: 'Zaplatit přes Stripe', + pay_with_paypal: 'Zaplatit přes PayPal', reupload: 'Znovu nahrát', upload: 'Nahrát', files: 'Soubory', @@ -1051,6 +1059,7 @@ const pt = { email_has_been_sent: 'Email enviado', processing: 'Processamento', pay_with_stripe: 'Pagar com Stripe', + pay_with_paypal: 'Pagar com PayPal', reupload: 'Recarregar', upload: 'Carregar', files: 'Arquivos', @@ -1169,6 +1178,7 @@ const he = { email_has_been_sent: 'האימייל נשלח', processing: 'מעבד', pay_with_stripe: 'שלם עם סטרייפ', + pay_with_paypal: 'שלם עם פייפאל', reupload: 'העלה שוב', upload: 'העלאה', files: 'קבצים', @@ -1287,6 +1297,7 @@ const nl = { email_has_been_sent: 'E-mail is verzonden', processing: 'Verwerken', pay_with_stripe: 'Betalen met Stripe', + pay_with_paypal: 'Betalen met PayPal', reupload: 'Opnieuw uploaden', upload: 'Uploaden', files: 'Bestanden', @@ -1405,6 +1416,7 @@ const ar = { email_has_been_sent: 'تم إرسال البريد الإلكتروني', processing: 'جارٍ المعالجة', pay_with_stripe: 'الدفع بواسطة Stripe', + pay_with_paypal: 'الدفع بواسطة PayPal', reupload: 'إعادة التحميل', upload: 'تحميل', files: 'الملفات', @@ -1523,6 +1535,7 @@ const ko = { email_has_been_sent: '이메일이 전송되었습니다', processing: '처리 중', pay_with_stripe: '스트라이프로 결제', + pay_with_paypal: 'PayPal로 결제', reupload: '다시 업로드', upload: '업로드', files: '파일', @@ -1641,6 +1654,7 @@ const ja = { email_has_been_sent: 'メールが送信されました', processing: '処理中', pay_with_stripe: 'Stripeで支払う', + pay_with_paypal: 'PayPalで支払う', reupload: '再アップロード', upload: 'アップロード', files: 'ファイル', diff --git a/app/javascript/submission_form/payment_step.vue b/app/javascript/submission_form/payment_step.vue index e1afbf40..f1ebabcc 100644 --- a/app/javascript/submission_form/payment_step.vue +++ b/app/javascript/submission_form/payment_step.vue @@ -1,6 +1,6 @@