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

Add validate api action for ContributionPage.submit #12829

Merged
merged 1 commit into from
Oct 7, 2018

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Extends existing validate action to provide specific support for the ContributionPage.submit action

Before

calling

civicrm_api3('ContributionPage', 'validate', array_merge($params, ['action' => 'submit']))

does not check if the parameters are valid for the form

After

The above checks the parameters are valid for the form

Technical Details

@colemanw @mattwire the intent of this is to be able to support a flow like the new paypal method where the user is redirected offsite to authorise the order before the form is submitted. It's important to check the data is valid first - e.g they haven't entered as amount below the minimum and if they have entered yes to recurring they have also entered other details.

This is a first step. It seems to me that in order to be able to validate at the js level we need to be able to test the input against the formRule function. I can see quite a lot of appropriate extension & tidy up work but have kept this to the minimum

Comments

I am open to doing this on the api v4 rather than v3 if it makes sense.

@@ -951,7 +951,7 @@ public static function formRule($fields, $files, $self) {
return $errors;
}

if (CRM_Utils_Array::value('payment_processor_id', $fields) == NULL) {
if (CRM_Utils_Array::value('payment_processor_id', $fields) === NULL) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the form passes '0' as a string & the test passes 0 as an integer. I fixed to support both as I think it would be easy for it to be cast at some point & both indicate payment processor 0 - ie. pay later

@seamuslee001
Copy link
Contributor

@eileenmcnaughton the api test failure looks legit

@eileenmcnaughton
Copy link
Contributor Author

test this please

@eileenmcnaughton
Copy link
Contributor Author

@mattwire this is a start on one of the challenges for the paypal jsv4 - basically we need a way to validate with Civi before calling the external processor - this is a small start on being able to call that

@mattwire
Copy link
Contributor

mattwire commented Oct 7, 2018

This is "new" functionality with a unit test. It doesn't affect existing behaviour but allows access to the "formrule" validation via the API and means we don't have to use core functions from extensions (which is not supported). I have not "run" this but looking at the code I think it is good to merge.

@eileenmcnaughton eileenmcnaughton merged commit a16d88d into civicrm:master Oct 7, 2018
@eileenmcnaughton eileenmcnaughton deleted the validate branch October 7, 2018 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants