diff -Naur -x '*.po' -x'*.mo' -x translation_fix_de.php -x DrupalDirectDebit.php -x ContributionTotals.tpl -x DashBoard.tpl -x addDirectDebitPaymentProcessor.php civicrm-2.1.4-drupal/CRM/Admin/Form/PaymentProcessor.php civicrm-custom-20080217/CRM/Admin/Form/PaymentProcessor.php --- civicrm-2.1.4-drupal/CRM/Admin/Form/PaymentProcessor.php 2008-05-30 10:23:01.000000000 -0400 +++ civicrm-custom-20080217/CRM/Admin/Form/PaymentProcessor.php 2009-01-22 14:25:58.000000000 -0300 @@ -323,6 +323,7 @@ $dao->is_recur = $this->_ppDAO->is_recur; $dao->billing_mode = $this->_ppDAO->billing_mode; $dao->class_name = $this->_ppDAO->class_name; + $dao->payment_type = $this->_ppDAO->payment_type; $dao->save( ); } diff -Naur -x '*.po' -x'*.mo' -x translation_fix_de.php -x DrupalDirectDebit.php -x ContributionTotals.tpl -x DashBoard.tpl -x addDirectDebitPaymentProcessor.php civicrm-2.1.4-drupal/CRM/Contribute/BAO/Contribution/Utils.php civicrm-custom-20080217/CRM/Contribute/BAO/Contribution/Utils.php --- civicrm-2.1.4-drupal/CRM/Contribute/BAO/Contribution/Utils.php 2008-08-07 08:31:30.000000000 -0400 +++ civicrm-custom-20080217/CRM/Contribute/BAO/Contribution/Utils.php 2009-02-13 00:42:19.000000000 -0300 @@ -187,11 +187,17 @@ $form->_params['source'] = $paymentParams['contribution_source']; } + // check if pending was set to true by payment processor + $pending = false; + if (isset($form->_params['contribution_status_pending']) && $form->_params['contribution_state_pending']) { + $pending = true; + } + $contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution( $form, $form->_params, $result, $contactID, $contributionType, - true, false, true ); + true, $pending, true ); $form->postProcessPremium( $premiumParams, $contribution ); diff -Naur -x '*.po' -x'*.mo' -x translation_fix_de.php -x DrupalDirectDebit.php -x ContributionTotals.tpl -x DashBoard.tpl -x addDirectDebitPaymentProcessor.php civicrm-2.1.4-drupal/CRM/Contribute/Form/Contribution/Main.php civicrm-custom-20080217/CRM/Contribute/Form/Contribution/Main.php --- civicrm-2.1.4-drupal/CRM/Contribute/Form/Contribution/Main.php 2008-11-27 13:30:55.000000000 -0300 +++ civicrm-custom-20080217/CRM/Contribute/Form/Contribution/Main.php 2009-02-14 19:39:16.000000000 -0300 @@ -165,6 +165,12 @@ // $this->_defaults['cvv2'] = '000'; // $this->_defaults['credit_card_exp_date'] = array( 'Y' => '2009', 'M' => '01' ); + // hack to simplify direct debit entry for testing + // $this->_defaults['account_holder'] = 'Max Müller'; + // $this->_defaults['bank_account_number'] = '12345678'; + // $this->_defaults['bank_identification_number'] = '12030000'; + // $this->_defaults['bank_name'] = 'Bankname'; + //build set default for pledge overdue payment. if ( CRM_Utils_Array::value( 'pledge_id', $this->_values ) ) { //get all payment statuses. @@ -275,7 +281,12 @@ // doing this later since the express button type depends if there is an upload or not if ( $this->_values['is_monetary'] ) { require_once 'CRM/Core/Payment/Form.php'; - CRM_Core_Payment_Form::buildCreditCard( $this ); + // CRM_Core_Error::debug('CRM_Contribute_Form_Contribution._paymentProcessor', $this->_paymentProcessor); + if ( $this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD) { + CRM_Core_Payment_Form::buildCreditCard( $this ); + } else if ( $this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT){ + CRM_Core_Payment_Form::buildDirectDebit( $this ); + } } //to create an cms user diff -Naur -x '*.po' -x'*.mo' -x translation_fix_de.php -x DrupalDirectDebit.php -x ContributionTotals.tpl -x DashBoard.tpl -x addDirectDebitPaymentProcessor.php civicrm-2.1.4-drupal/CRM/Contribute/Form/Contribution.php civicrm-custom-20080217/CRM/Contribute/Form/Contribution.php --- civicrm-2.1.4-drupal/CRM/Contribute/Form/Contribution.php 2008-12-18 05:41:24.000000000 -0300 +++ civicrm-custom-20080217/CRM/Contribute/Form/Contribution.php 2009-02-13 00:42:19.000000000 -0300 @@ -233,7 +233,14 @@ $this->_fields = array( ); require_once 'CRM/Core/Payment/Form.php'; - CRM_Core_Payment_Form::setCreditCardFields( $this ); + require_once 'CRM/Core/Payment.php'; + // payment fields are depending on payment type + // CRM_Core_Error::debug('CRM_Contribute_Form_Contribution._processors', $this->_processors); + if ( $this->_processors['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD ) { + CRM_Core_Payment_Form::setCreditCardFields( $this ); + } else if ( $this->_processors['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT ){ + CRM_Core_Payment_Form::setDirectDebitFields( $this ); + } if ( $this->_action & CRM_Core_Action::DELETE ) { return; @@ -491,12 +498,15 @@ $paneNames['Premium Information'] = 'Premium'; } $ccPane = null; - - if ( $this->_mode ) { - $ccPane = array( 'Credit Card Information' => 'CreditCard' ); - } - if ( is_array( $ccPane ) ) { - $paneNames = array_merge( $ccPane, $paneNames ); + $ddPane = null; + if ( $this->_mode ) { + if ( $this->_processors['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD) { + $ccPane = array( ts('Credit Card Information') => 'CreditCard' ); + $paneNames = array_merge( $ccPane, $paneNames ); + } else if ( $this->_processors['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT){ + $ddPane = array( ts('Direct Debit Information') => 'DirectDebit' ); + $paneNames = array_merge( $ddPane, $paneNames ); + } } foreach ( $paneNames as $name => $type ) { @@ -506,7 +516,7 @@ } $open = 'false'; - if ( $type == 'CreditCard' ) { + if ( $type == 'CreditCard' || $type == 'DirectDebit') { $open = 'true'; } @@ -524,6 +534,9 @@ if ( $type == 'CreditCard' ) { $this->add('hidden', 'hidden_CreditCard', 1 ); CRM_Core_Payment_Form::buildCreditCard( $this, true ); + } else if ( $type == 'DirectDebit' ) { + $this->add('hidden', 'hidden_DirectDebit', 1 ); + CRM_Core_Payment_Form::buildDirectDebit( $this, true ); } else { eval( 'CRM_Contribute_Form_AdditionalInfo::build' . $type . '( $this );' ); } @@ -769,8 +782,11 @@ $this->_params["country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode( $this->_params["country_id-{$this->_bltID}"] ); - $this->_params['year' ] = $this->_params['credit_card_exp_date']['Y']; - $this->_params['month' ] = $this->_params['credit_card_exp_date']['M']; + if ( $this->_processors['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD) { + $this->_params['year' ] = $this->_params['credit_card_exp_date']['Y']; + $this->_params['month' ] = $this->_params['credit_card_exp_date']['M']; + } + $this->_params['ip_address'] = CRM_Utils_System::ipAddress( ); $this->_params['amount' ] = $this->_params['total_amount']; $this->_params['amount_level' ] = 0; @@ -907,7 +923,7 @@ //submit credit card contribution ends. } else { //Offline Contribution. - $unsetParams = array( "payment_processor_id", "email-{$this->_bltID}", "hidden_buildCreditCard", + $unsetParams = array( "payment_processor_id", "email-{$this->_bltID}", "hidden_buildCreditCard", "hidden_buildDirectDebit", "billing_first_name","billing_middle_name","billing_last_name", "street_address-5", "city-{$this->_bltID}","state_province_id-{$this->_bltID}","postal_code-{$this->_bltID}", "country_id-{$this->_bltID}","credit_card_number", "cvv2","credit_card_exp_date","credit_card_type",); diff -Naur -x '*.po' -x'*.mo' -x translation_fix_de.php -x DrupalDirectDebit.php -x ContributionTotals.tpl -x DashBoard.tpl -x addDirectDebitPaymentProcessor.php civicrm-2.1.4-drupal/CRM/Contribute/Form/ContributionBase.php civicrm-custom-20080217/CRM/Contribute/Form/ContributionBase.php --- civicrm-2.1.4-drupal/CRM/Contribute/Form/ContributionBase.php 2008-12-16 02:48:12.000000000 -0300 +++ civicrm-custom-20080217/CRM/Contribute/Form/ContributionBase.php 2009-02-13 00:42:19.000000000 -0300 @@ -327,7 +327,13 @@ if ( ( $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM ) && CRM_Utils_Array::value('is_monetary', $this->_values) ) { require_once 'CRM/Core/Payment/Form.php'; - CRM_Core_Payment_Form::setCreditCardFields( $this ); + require_once 'CRM/Core/Payment.php'; + // payment fields are depending on payment type + if ( $this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD) { + CRM_Core_Payment_Form::setCreditCardFields( $this ); + } else if ( $this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT){ + CRM_Core_Payment_Form::setDirectDebitFields( $this ); + } } $this->assign_by_ref( 'paymentProcessor', $this->_paymentProcessor ); @@ -478,11 +484,21 @@ } if ( $this->_contributeMode == 'direct' && $assignCCInfo ) { - $date = CRM_Utils_Date::format( $this->_params['credit_card_exp_date'] ); - $date = CRM_Utils_Date::mysqlToIso( $date ); - $this->assign( 'credit_card_exp_date', $date ); - $this->assign( 'credit_card_number', - CRM_Utils_System::mungeCreditCard( $this->_params['credit_card_number'] ) ); + // CRM_Core_Error::debug('CRM_Contribute_Form_Contribution._paymentProcessor', $this->_paymentProcessor); + if ( $this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD ) { + $this->assign( 'payment_type', $this->_paymentProcessor['payment_type']); + $date = CRM_Utils_Date::format( $this->_params['credit_card_exp_date'] ); + $date = CRM_Utils_Date::mysqlToIso( $date ); + $this->assign( 'credit_card_exp_date', $date ); + $this->assign( 'credit_card_number', + CRM_Utils_System::mungeCreditCard( $this->_params['credit_card_number'] ) ); + } else if ( $this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT ){ + $this->assign( 'payment_type', $this->_paymentProcessor['payment_type']); + $this->assign( 'account_holder', $this->_params['account_holder'] ); + $this->assign( 'bank_identification_number', $this->_params['bank_identification_number'] ); + $this->assign( 'bank_name', $this->_params['bank_name'] ); + $this->assign( 'bank_account_number', $this->_params['bank_account_number'] ); + } } $this->assign( 'email', diff -Naur -x '*.po' -x'*.mo' -x translation_fix_de.php -x DrupalDirectDebit.php -x ContributionTotals.tpl -x DashBoard.tpl -x addDirectDebitPaymentProcessor.php civicrm-2.1.4-drupal/CRM/Core/BAO/PaymentProcessor.php civicrm-custom-20080217/CRM/Core/BAO/PaymentProcessor.php --- civicrm-2.1.4-drupal/CRM/Core/BAO/PaymentProcessor.php 2008-05-30 10:23:01.000000000 -0400 +++ civicrm-custom-20080217/CRM/Core/BAO/PaymentProcessor.php 2009-01-22 14:25:58.000000000 -0300 @@ -189,7 +189,7 @@ { $fields = array( 'name', 'payment_processor_type', 'user_name', 'password', 'signature', 'url_site', 'url_api', 'url_recur', 'url_button', - 'subject', 'class_name', 'is_recur', 'billing_mode'); + 'subject', 'class_name', 'is_recur', 'billing_mode', 'payment_type'); $result = array( ); foreach ( $fields as $name ) { $result[$name] = $dao->$name; diff -Naur -x '*.po' -x'*.mo' -x translation_fix_de.php -x DrupalDirectDebit.php -x ContributionTotals.tpl -x DashBoard.tpl -x addDirectDebitPaymentProcessor.php civicrm-2.1.4-drupal/CRM/Core/DAO/PaymentProcessor.php civicrm-custom-20080217/CRM/Core/DAO/PaymentProcessor.php --- civicrm-2.1.4-drupal/CRM/Core/DAO/PaymentProcessor.php 2008-12-19 06:34:03.000000000 -0300 +++ civicrm-custom-20080217/CRM/Core/DAO/PaymentProcessor.php 2009-01-22 14:25:58.000000000 -0300 @@ -179,6 +179,13 @@ */ public $is_recur; /** + * type of payment + * + * @var int unsigned + */ + public $payment_type; + + /** * class constructor * * @access public @@ -309,6 +316,13 @@ 'name' => 'is_recur', 'type' => CRM_Utils_Type::T_BOOLEAN, ) , + 'payment_type' => array( + 'name' => 'payment_type', + 'type' => CRM_Utils_Type::T_INT, + 'title' => ts('Payment Type') , + 'required' => true, + ) , + ); } return self::$_fields; diff -Naur -x '*.po' -x'*.mo' -x translation_fix_de.php -x DrupalDirectDebit.php -x ContributionTotals.tpl -x DashBoard.tpl -x addDirectDebitPaymentProcessor.php civicrm-2.1.4-drupal/CRM/Core/DAO/PaymentProcessorType.php civicrm-custom-20080217/CRM/Core/DAO/PaymentProcessorType.php --- civicrm-2.1.4-drupal/CRM/Core/DAO/PaymentProcessorType.php 2008-12-19 06:34:03.000000000 -0300 +++ civicrm-custom-20080217/CRM/Core/DAO/PaymentProcessorType.php 2009-01-22 14:25:58.000000000 -0300 @@ -193,6 +193,12 @@ */ public $is_recur; /** + * type of payment + * + * @var int unsigned + */ + public $payment_type; + /** * class constructor * * @access public @@ -347,6 +353,12 @@ 'name' => 'is_recur', 'type' => CRM_Utils_Type::T_BOOLEAN, ) , + 'payment_type' => array( + 'name' => 'payment_type', + 'type' => CRM_Utils_Type::T_INT, + 'title' => ts('Payment Type') , + 'required' => true, + ) , ); } return self::$_fields; diff -Naur -x '*.po' -x'*.mo' -x translation_fix_de.php -x DrupalDirectDebit.php -x ContributionTotals.tpl -x DashBoard.tpl -x addDirectDebitPaymentProcessor.php civicrm-2.1.4-drupal/CRM/Core/Payment/Form.php civicrm-custom-20080217/CRM/Core/Payment/Form.php --- civicrm-2.1.4-drupal/CRM/Core/Payment/Form.php 2008-08-06 06:07:47.000000000 -0400 +++ civicrm-custom-20080217/CRM/Core/Payment/Form.php 2009-02-13 00:42:19.000000000 -0300 @@ -35,14 +35,14 @@ class CRM_Core_Payment_Form { /** - * create all fields needed for a credit card transaction + * create all common fields needed for a credit card or direct debit transaction * * @return void - * @access public + * @access protected */ - function setCreditCardFields( &$form ) { + protected function _setPaymentFields( &$form) { $bltID = $form->_bltID; - + $form->_fields['billing_first_name'] = array( 'htmlType' => 'text', 'name' => 'billing_first_name', 'title' => ts('Billing First Name'), @@ -100,7 +100,18 @@ 'attributes' => array( '' => ts( '- select -' ) ) + CRM_Core_PseudoConstant::country( ), 'is_required'=> true ); - + } + + + /** + * create all fields needed for a credit card transaction + * + * @return void + * @access public + */ + function setCreditCardFields( &$form ) { + CRM_Core_Payment_Form::_setPaymentFields( $form ); + $form->_fields['credit_card_number'] = array( 'htmlType' => 'text', 'name' => 'credit_card_number', 'title' => ts('Card Number'), @@ -132,6 +143,45 @@ 'is_required'=> true ); } + /** create all fields needed for direct debit transaction + * + * @return void + * @access public + */ + function setDirectDebitFields( &$form ) { + CRM_Core_Payment_Form::_setPaymentFields( $form ); + + $form->_fields['account_holder'] = array( 'htmlType' => 'text', + 'name' => 'account_holder', + 'title' => ts('Account Holder'), + 'cc_field' => true, + 'attributes' => array( 'size' => 20, 'maxlength' => 34, 'autocomplete' => 'on' ), + 'is_required'=> true ); + + //e.g. IBAN can have maxlength of 34 digits + $form->_fields['bank_account_number'] = array( 'htmlType' => 'text', + 'name' => 'bank_account_number', + 'title' => ts('Bank Account Number'), + 'cc_field' => true, + 'attributes' => array( 'size' => 20, 'maxlength' => 34, 'autocomplete' => 'off' ), + 'is_required'=> true ); + + //e.g. SWIFT-BIC can have maxlength of 11 digits + $form->_fields['bank_identification_number'] = array( 'htmlType' => 'text', + 'name' => 'bank_identification_number', + 'title' => ts('Bank Identification Number'), + 'cc_field' => true, + 'attributes' => array( 'size' => 20, 'maxlength' => 11, 'autocomplete' => 'off' ), + 'is_required'=> true ); + + $form->_fields['bank_name'] = array( 'htmlType' => 'text', + 'name' => 'bank_name', + 'title' => ts('Bank Name'), + 'cc_field' => true, + 'attributes' => array( 'size' => 20, 'maxlength' => 64, 'autocomplete' => 'off' ), + 'is_required'=> true ); + } + /** * Function to add all the credit card fields * @@ -171,6 +221,49 @@ } } + /** + * Function to add all the direct debit fields + * + * @return None + * @access public + */ + function buildDirectDebit( &$form, $useRequired = false ) { + require_once 'CRM/Core/Payment.php'; + + if ( $form->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM) { + foreach ( $form->_fields as $name => $field ) { + if ( isset( $field['cc_field'] ) && + $field['cc_field'] ) { + $form->add( $field['htmlType'], + $field['name'], + $field['title'], + $field['attributes'], + $useRequired ? $field['is_required'] : false ); + } + } + + // $form->addRule( 'account_holder', + // ts( 'Please enter a valid Name for the Account Holder (value must not contain punctuation characters).' ), + // 'regex', '/^[\d\w\.\ -_]*$/' ); + + $form->addRule( 'bank_identification_number', + ts( 'Please enter a valid Bank Identification Number (value must not contain punctuation characters).' ), + 'nopunctuation' ); + + $form->addRule( 'bank_account_number', + ts('Please enter a valid Bank Account Number (value must not contain punctuation characters).'), + 'nopunctuation' ); + } + + if ( $form->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON ) { + $form->_expressButtonName = $form->getButtonName( $form->buttonType( ), 'express' ); + $form->add('image', + $form->_expressButtonName, + $form->_paymentProcessor['url_button'], + array( 'class' => 'form-submit' ) ); + } + } + /** * function to map address fields * diff -Naur -x '*.po' -x'*.mo' -x translation_fix_de.php -x DrupalDirectDebit.php -x ContributionTotals.tpl -x DashBoard.tpl -x addDirectDebitPaymentProcessor.php civicrm-2.1.4-drupal/CRM/Core/Payment.php civicrm-custom-20080217/CRM/Core/Payment.php --- civicrm-2.1.4-drupal/CRM/Core/Payment.php 2008-04-25 06:43:11.000000000 -0400 +++ civicrm-custom-20080217/CRM/Core/Payment.php 2009-01-22 14:25:58.000000000 -0300 @@ -44,6 +44,19 @@ BILLING_MODE_BUTTON = 2, BILLING_MODE_NOTIFY = 4; + /** + * wich payment type(s) are we using? + * + * credit card + * direct debit + * or both + * + */ + const + PAYMENT_TYPE_CREDIT_CARD = 1, + PAYMENT_TYPE_DIRECT_DEBIT = 2; + // PAYMENT_TYPE_CREDIT_CARD_AND_DIRECT_DEBIT = 3; + /** * We only need one instance of this object. So we use the singleton * pattern and cache the instance in this variable diff -Naur -x '*.po' -x'*.mo' -x translation_fix_de.php -x DrupalDirectDebit.php -x ContributionTotals.tpl -x DashBoard.tpl -x addDirectDebitPaymentProcessor.php civicrm-2.1.4-drupal/settings_location.php civicrm-custom-20080217/settings_location.php --- civicrm-2.1.4-drupal/settings_location.php 1969-12-31 20:00:00.000000000 -0400 +++ civicrm-custom-20080217/settings_location.php 2009-01-22 14:25:58.000000000 -0300 @@ -0,0 +1,2 @@ + - {ts}Credit or Debit Card Information{/ts} + {if $paymentProcessor.payment_type & 1} + {ts}Credit or Debit Card Information{/ts} + {else if $paymentProcessor.payment_type & 2} + {ts}Direct Debit Information{/ts} + {/if}