-
Notifications
You must be signed in to change notification settings - Fork 69
[v4] Create ACH Transfer #11862
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
Open
thedev132
wants to merge
10
commits into
main
Choose a base branch
from
thedev132-v4-ach
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[v4] Create ACH Transfer #11862
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f96a7fc
[v4] Create ACH Transfer
thedev132 a08d69b
Don't expose ach show
thedev132 5078ace
Merge branch 'main' into thedev132-v4-ach
thedev132 4ae38dd
remove unused variable
thedev132 a02e597
Apply suggestion from @github-actions[bot]
thedev132 fb0b2fa
Apply suggestion from @github-actions[bot]
thedev132 9ae9629
remove unused show function
thedev132 9d03b5d
Use `render_money`
garyhtou 0b87993
Add `ActiveRecord::RecordInvalid` rescue
Luke-Oldenburg 8fe8168
Merge branch 'main' into thedev132-v4-ach
Luke-Oldenburg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Api | ||
| module V4 | ||
| class AchTransfersController < ApplicationController | ||
| include SetEvent | ||
|
|
||
| before_action :set_api_event, only: [:create] | ||
|
|
||
| def create | ||
| permitted_params = [ | ||
| :routing_number, | ||
| :account_number, | ||
| :recipient_email, | ||
| :bank_name, | ||
| :recipient_name, | ||
| :amount_money, | ||
| :payment_for, | ||
| :send_email_notification, | ||
| :invoiced_at, | ||
| :file, | ||
| ] | ||
|
|
||
| if current_user&.admin? | ||
| permitted_params << :scheduled_on | ||
| end | ||
|
|
||
| ach_transfer_params = params.require(:ach_transfer).permit(*permitted_params) | ||
|
|
||
| @ach_transfer = @event.ach_transfers.build(ach_transfer_params.merge(creator: current_user)) | ||
|
|
||
| authorize @ach_transfer | ||
|
|
||
| if @ach_transfer.amount > SudoModeHandler::THRESHOLD_CENTS | ||
| # Don't let API submit ACH transfers above sudo mode threshold | ||
| return render json: { error: "invalid_operation", messages: ["ACH transfers above the sudo mode threshold of #{ApplicationController.helpers.render_money(SudoModeHandler::THRESHOLD_CENTS)} are not allowed."] }, status: :bad_request | ||
| end | ||
|
|
||
|
|
||
| begin | ||
| @ach_transfer.save! | ||
| if ach_transfer_params[:file] | ||
| ::ReceiptService::Create.new( | ||
| uploader: current_user, | ||
| attachments: ach_transfer_params[:file], | ||
| upload_method: :ach_transfer_api, | ||
| receiptable: @ach_transfer.local_hcb_code | ||
| ).run! | ||
| end | ||
| rescue ArgumentError => e | ||
| render json: { error: "invalid_operation", messages: [e.message] }, status: :bad_request | ||
| end | ||
|
|
||
| render :show, status: :created | ||
| end | ||
|
|
||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| json.partial! "api/v4/transactions/ach_transfer", ach_transfer: @ach_transfer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.