Index: branches/fundraising/extensions/DonationInterface/gateway_common/GatewayForm.php |
— | — | @@ -48,79 +48,6 @@ |
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Checks posted form data for errors and returns array of messages |
52 | | - */ |
53 | | - protected function fnValidateForm( &$data, &$error ) { |
54 | | - // begin with no errors |
55 | | - $error_result = '0'; |
56 | | - |
57 | | - // create the human-speak message for required fields |
58 | | - // does not include fields that are not required |
59 | | - $gateway_identifier = $this->adapter->getIdentifier(); |
60 | | - $msg = array( |
61 | | - 'amount' => wfMsg( $gateway_identifier . '_gateway-error-msg-amount' ), |
62 | | - 'emailAdd' => wfMsg( $gateway_identifier . '_gateway-error-msg-emailAdd' ), |
63 | | - 'fname' => wfMsg( $gateway_identifier . '_gateway-error-msg-fname' ), |
64 | | - 'lname' => wfMsg( $gateway_identifier . '_gateway-error-msg-lname' ), |
65 | | - 'street' => wfMsg( $gateway_identifier . '_gateway-error-msg-street' ), |
66 | | - 'city' => wfMsg( $gateway_identifier . '_gateway-error-msg-city' ), |
67 | | - 'state' => wfMsg( $gateway_identifier . '_gateway-error-msg-state' ), |
68 | | - 'zip' => wfMsg( $gateway_identifier . '_gateway-error-msg-zip' ), |
69 | | - 'card_num' => wfMsg( $gateway_identifier . '_gateway-error-msg-card_num' ), |
70 | | - 'expiration' => wfMsg( $gateway_identifier . '_gateway-error-msg-expiration' ), |
71 | | - 'cvv' => wfMsg( $gateway_identifier . '_gateway-error-msg-cvv' ), |
72 | | - ); |
73 | | - |
74 | | - // find all empty fields and create message |
75 | | - foreach ( $data as $key => $value ) { |
76 | | - if ( $value == '' || ($key == 'state' && $value == 'YY' ) ) { |
77 | | - // ignore fields that are not required |
78 | | - if ( isset( $msg[$key] ) ) { |
79 | | - $error[$key] = "**" . wfMsg( $gateway_identifier . '_gateway-error-msg', $msg[$key] ) . "**<br />"; |
80 | | - $error_result = '1'; |
81 | | - } |
82 | | - } |
83 | | - } |
84 | | - |
85 | | - // check amount |
86 | | - $priceFloor = $this->adapter->getGlobal( 'PriceFloor' ); |
87 | | - $priceCeiling = $this->adapter->getGlobal( 'PriceCeiling' ); |
88 | | - if ( !preg_match( '/^\d+(\.(\d+)?)?$/', $data['amount'] ) || |
89 | | - ( ( float ) $this->convert_to_usd( $data['currency'], $data['amount'] ) < ( float ) $priceFloor || |
90 | | - ( float ) $this->convert_to_usd( $data['currency'], $data['amount'] ) > ( float ) $priceCeiling ) ) { |
91 | | - $error['invalidamount'] = wfMsg( $gateway_identifier . '_gateway-error-msg-invalid-amount' ); |
92 | | - $error_result = '1'; |
93 | | - } |
94 | | - |
95 | | - // is email address valid? |
96 | | - $isEmail = User::isValidEmailAddr( $data['email'] ); |
97 | | - |
98 | | - // create error message (supercedes empty field message) |
99 | | - if ( !$isEmail ) { |
100 | | - $error['emailAdd'] = wfMsg( $gateway_identifier . '_gateway-error-msg-email' ); |
101 | | - $error_result = '1'; |
102 | | - } |
103 | | - |
104 | | - // validate that credit card number entered is correct and set the card type |
105 | | - if ( preg_match( '/^3[47][0-9]{13}$/', $data['card_num'] ) ) { // american express |
106 | | - $data['card'] = 'american'; |
107 | | - } elseif ( preg_match( '/^5[1-5][0-9]{14}$/', $data['card_num'] ) ) { // mastercard |
108 | | - $data['card'] = 'mastercard'; |
109 | | - } elseif ( preg_match( '/^4[0-9]{12}(?:[0-9]{3})?$/', $data['card_num'] ) ) {// visa |
110 | | - $data['card'] = 'visa'; |
111 | | - } elseif ( preg_match( '/^6(?:011|5[0-9]{2})[0-9]{12}$/', $data['card_num'] ) ) { // discover |
112 | | - $data['card'] = 'discover'; |
113 | | - } else { // an invalid credit card number was entered |
114 | | - //TODO: Make sure this is uncommented when you commit for reals! |
115 | | - //$error_result = '1'; |
116 | | - //$error[ 'card_num' ] = wfMsg( $gateway_identifier . '_gateway-error-msg-card-num' ); |
117 | | - } |
118 | | - |
119 | | - $this->adapter->setValidationErrors( $error ); |
120 | | - return $error_result; |
121 | | - } |
122 | | - |
123 | | - /** |
124 | | - * Checks posted form data for errors and returns array of messages |
125 | 52 | * |
126 | 53 | * This is update to GatewayForm::fnValidateForm(). |
127 | 54 | * |