-
Notifications
You must be signed in to change notification settings - Fork 195
Add a Manual External Payment Integration #11299
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?
Conversation
(for the record: I had a lengthy discussion with Finn during our regular call, there are gonna be major reworks on this PR) |
you had a typo there :P |
@thewca-bot deploy staging |
I just noticed that we need to implement showing the payment reference in the admin table again |
flash[:error] = 'PayPal is not yet available in production environments' | ||
return redirect_to competitions_payment_setup_path(competition) | ||
end | ||
|
||
connector = CompetitionPaymentIntegration::AVAILABLE_INTEGRATIONS[payment_integration.to_sym].safe_constantize | ||
account_reference = connector&.connect_account(params) | ||
if CompetitionPaymentIntegration::AVAILABLE_INTEGRATIONS[payment_integration].nil? |
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.
We need to check for the validity of the integration here, before we try and assign it to a variable. Old-line 284 actually fails if the integration is unrecognized because safe_constantize
can't be called on nil
|
||
competition.competition_payment_integrations.new(connected_account: account_reference) | ||
raise ActionController::RoutingError.new("No integration reference submitted") if integration_reference.blank? |
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.
Wording on the old message was incorrect - it wasn't checking for the payment integration type, it was checking for the presence of the account reference
Had inconsistent behaviour when trying to use this via the UI (sometimes the payment amount was showing 2x the competition's fees, other times it was failing outright), so adding tests to assert the backend behaviour |
Two related notes on the implementation here:
|
app/models/manual_payment_record.rb
Outdated
has_one :payment_intent, as: :payment_record | ||
|
||
def determine_wca_status | ||
WCA_TO_MANUAL_PAYMENT_STATUS_MAP[status.to_sym] |
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.
This used to have the same contents as status
- I've changed it to pull the wca_status from the defined mapping
errors.add(:wca_status, "#{wca_status} is not compatible with PaypalRecord status: #{payment_record.paypal_status}") unless | ||
PaypalRecord::WCA_TO_PAYPAL_STATUS_MAP[wca_status.to_sym].include?(payment_record.paypal_status) | ||
when 'ManualPaymentRecord' | ||
errors.add(:wca_status, "#{wca_status} is not compatible with ManualPaymentRecord status: #{payment_record.status}") unless | ||
ManualPaymentRecord::WCA_TO_MANUAL_PAYMENT_STATUS_MAP[wca_status.to_sym].include?(payment_record.status) |
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.
Previously this was calling payment_record.paypal_status
- updated to just call status
of the payment_record itself
get api_v1_registrations_payment_ticket_path(competition_id: competition.id), headers: headers | ||
expect(response).to be_successful | ||
end | ||
context 'stripe connect payment integration' do |
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.
I moved everything that was here into this context block, and added a new context block for manual payment integrations - this makes the diff appear larger/more significant than it is
…rldcubeassociation.org into manual-payment-integration
Replacement for #9737
This is still WIP because I didn't add any DB changes yet. I would like to have some feedback on this before.
I could not use the already existing
connect_payment_integration
method because that requires a redirect, which doesn't work in react world. I also think it doesn't really make sense, because there are no accounts to save.I added a new page to input the payment information text and needed payment reference instead.