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

Properly validate direct debit fields #57

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions includes/wf_crm_webform_postprocess.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1562,16 +1562,24 @@ class wf_crm_webform_postprocess extends wf_crm_webform_base {
$billing_fields['credit_card_number'] = FALSE;
$billing_fields['cvv2'] = FALSE;
}
if (!empty($_POST['bank_account_type'])) {
if (isset($_POST['bank_account_type'])) {
Copy link
Collaborator

@KarinG KarinG Feb 21, 2017

Choose a reason for hiding this comment

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

I had followed the lead for the Stripe implementation: that's why it's an !empty
if (!empty($_POST['stripe_token'])) {

// unset/bypass the CC validation if we're doing Direct Debit (ACHEFT) - in that case we have a Bank Account Type
$billing_fields['credit_card_number'] = FALSE;
$billing_fields['cvv2'] = FALSE;
$billing_fields['credit_card_type'] = FALSE;
$_POST['credit_card_exp_date']['M'] = '12';
$_POST['credit_card_exp_date']['Y'] = '2099';
// now make sure debit fields get checked
$billing_fields = array_merge($billing_fields, array(
'account_holder' => ts('Name on Account'),
'bank_account_number' => ts('Account Number'),
'bank_identification_number' => ts('Routing Number'),
'bank_name' => ts('Bank Name'),
'bank_account_type' => ts('Account Type'),
));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes sense - same reasoning as above for CC

}
foreach ($billing_fields as $field => $label) {
if (empty($_POST[$field]) && $label !== FALSE) {
if (isset($_POST[$field]) && empty($_POST[$field]) && $label !== FALSE) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is needed - I can transact iATS ACHEFT without this.

form_set_error($field, t('!name field is required.', array('!name' => check_plain($label))));
$valid = FALSE;
}
Expand Down