Skip to content
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

Improve ContributionPage.validate api #13798

Merged
merged 2 commits into from
Mar 22, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Mar 11, 2019

Overview

This api mostly exists to support payment processors that take an action via js on the Main page during the submit process. Generally they like to abort if the page has not been correctly filled in.

The PR fixes it so the validate api can be called during POST (which would be the case with something like Paypal Checkout which calls a Promise we provide to determine whether to proceed after their button is pushed

Before

Funny key weird handling means in POST request the api cannot be called

After

POST request api validation supported, test added

Technical Details

Comments

I also marked 'id' as required

@civibot
Copy link

civibot bot commented Mar 11, 2019

(Standard links)

@civibot civibot bot added the master label Mar 11, 2019
Because the validation data is buried deep within the form we need to load the form
in order to validate - but currently the validKey check borks in post requests.

Note the validity of credit card details is not checked when submitting this form,
other than possibly the luhn validation.

 A likely use case for the validation is when the is being submitted and some handling is
 to be done before processing but the validity of input needs to be checked first.

 For example Paypal Checkout will replace the confirm button with it's own but we are able to validate
before paypal launches it's modal. In this case the  is post but we need validation to succeed.
@eileenmcnaughton
Copy link
Contributor Author

test this please

@colemanw
Copy link
Member

I have to say it looks strange to see an api accessing $_REQUEST directly - feels like breaking the compartmentalization of the api (same feeling I get when I see a BAO function setting a status message).

@eileenmcnaughton
Copy link
Contributor Author

It's awful - but there is a deeper awfulness we don't want to mess with... so I can't see another choice

@colemanw colemanw merged commit 8767e00 into civicrm:master Mar 22, 2019
@colemanw
Copy link
Member

Merging based on mutually-agreed awfulness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants