-
Notifications
You must be signed in to change notification settings - Fork 0
Payinvoice notifications test #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
017895e
8f29fc2
763f00e
7633dcd
84ac90a
21d32a0
9d26352
007c96b
cd583a1
9d5a9e6
452a3fe
05d195d
660d53c
0c0072e
4f23542
8168d97
ad2c164
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ def set_current | |
| if user && cookies["invitation_token"].present? | ||
| invite_link = CompanyInviteLink.find_by(token: cookies["invitation_token"]) | ||
| invited_company = invite_link&.company | ||
| user.update!(signup_invite_link: invite_link) if invite_link | ||
| AcceptCompanyInviteLink.new(user:, token: invite_link.token).perform if invite_link | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The result of AcceptCompanyInviteLink#perform (which signals success or failure) is discarded, so any validation or persistence errors are silently ignored and the request continues as if the invite were accepted. Prompt for AI agents |
||
| cookies.delete("invitation_token") | ||
| end | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -77,6 +77,17 @@ def payment_failed_reenter_bank_details(payment_id, amount, currency) | |||||
| mail(to: user.email, reply_to: company.email, subject: "🔴 Payment failed: re-enter your bank details") | ||||||
| end | ||||||
|
|
||||||
| def payment_failed(payment_id, amount, currency) | ||||||
| @payment = Payment.find(payment_id) | ||||||
| @invoice = @payment.invoice | ||||||
| @currency = currency | ||||||
| @amount = amount | ||||||
| company = @invoice.company | ||||||
| user = @invoice.user | ||||||
|
|
||||||
| mail(to: user.email, reply_to: company.email, subject: "🔴 Payment failed: payment failure for invoice ##{@invoice.id}") | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Email subject exposes the raw database id; use the public-facing invoice_number instead Prompt for AI agents
Suggested change
|
||||||
| end | ||||||
|
|
||||||
| def equity_percent_selection(company_worker_id) | ||||||
| company_worker = CompanyWorker.find(company_worker_id) | ||||||
| @company = company_worker.company | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,6 @@ def process | |
| account = payout_service.get_recipient_account(recipient_id: bank_account.recipient_id) | ||
| unless account["active"] | ||
| bank_account.mark_deleted! | ||
| CompanyWorkerMailer.payment_failed_reenter_bank_details(payment.id, amount, target_currency).deliver_later | ||
| raise WiseError, "Bank account is no longer active for payment #{payment.id}" | ||
| end | ||
| quote = payout_service.create_quote(target_currency:, amount:, recipient_id: bank_account.recipient_id) | ||
|
|
@@ -68,6 +67,16 @@ def process | |
| rescue WiseError => e | ||
| payment.update!(status: Payment::FAILED) | ||
| invoice.update!(status: Invoice::FAILED) | ||
|
|
||
| target_currency = payment.wise_recipient&.currency || "USD" | ||
| amount = payment.cash_amount_in_usd | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Email shows a USD amount even when the currency argument is non-USD, because Prompt for AI agents |
||
|
|
||
| if e.message.include?("Bank account is no longer active") | ||
| CompanyWorkerMailer.payment_failed_reenter_bank_details(payment.id, amount, target_currency).deliver_later | ||
| else | ||
| CompanyWorkerMailer.payment_failed(payment.id, amount, target_currency).deliver_later | ||
| end | ||
|
|
||
| raise e | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,11 @@ def perform(params) | |
| if payment.is_a?(Payment) | ||
| amount_cents = api_service.get_transfer(transfer_id:)["sourceValue"] * -100 | ||
| payment.balance_transactions.create!(company: payment.company, amount_cents:, transaction_type: BalanceTransaction::PAYMENT_FAILED) | ||
|
|
||
| transfer_details = api_service.get_transfer(transfer_id:) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Second consecutive call to api_service.get_transfer duplicates a network request that was already performed above, causing unnecessary external API traffic and latency. Prompt for AI agents |
||
| amount = transfer_details["targetValue"] | ||
| currency = transfer_details["targetCurrency"] | ||
| CompanyWorkerMailer.payment_failed(payment.id, amount, currency).deliver_later | ||
| end | ||
| end | ||
| invoice.update!(status: Invoice::FAILED) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <h1> | ||
| There was an issue processing your payment of <%= Money.from_amount(@amount, @currency).format(with_currency: true, symbol: false, no_cents_if_whole: true) %> | ||
| </h1> | ||
| <dl> | ||
| <dt>Invoice ID</dt> | ||
| <dd> | ||
| <%= @invoice.invoice_number %> | ||
| </dd> | ||
| <dt>Invoice amount</dt> | ||
| <dd> | ||
| <%= cents_format(@invoice.total_amount_in_usd_cents, with_currency: true, symbol: false) %> | ||
| </dd> | ||
| <dt>Bank account</dt> | ||
| <dd> | ||
| ****<%= @payment.recipient_last4 %> | ||
| </dd> | ||
| </dl> | ||
| <p> | ||
| Unfortunately, there was an issue processing your payment through Wise. This could be due to: | ||
| </p> | ||
| <ul> | ||
| <li>Incorrect bank account information</li> | ||
| <li>Bank transfer restrictions</li> | ||
| <li>Compliance or verification issues</li> | ||
| <li>Processing errors at the banking institution</li> | ||
| </ul> | ||
|
|
||
| <p> | ||
| Please log into your account to verify your bank details are correct and up-to-date. If your bank details appear correct, please contact support for assistance. | ||
| </p> | ||
|
|
||
| <p> | ||
| We'll attempt to process your payment again once the issue is resolved. | ||
| </p> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,3 @@ | ||
| <h1>Your verification code</h1> | ||
|
|
||
| <p>Your verification code is: <strong><%= @otp_code %></strong></p> | ||
| <h1>Your verification code is <%= @otp_code %></h1> | ||
|
|
||
| <p>This code will expire in 10 minutes. If you didn't request this code, please ignore this email.</p> | ||
|
|
||
| <p>If you're having trouble, contact us at <a href="mailto:<%= ApplicationMailer::SUPPORT_EMAIL %>"><%= ApplicationMailer::SUPPORT_EMAIL %></a>.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sensitive secret is exposed to every step by defining it in the top-level env block; limit it to only the job or step that actually needs it.
Prompt for AI agents