_type = $type; } else { $form->_type = CRM_Utils_Request::retrieve('type', 'String', $form); } if ($form->_type) { $form->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($form->_type, $form->_mode); } $form->set('paymentProcessor', $form->_paymentProcessor); // also set cancel subscription url if (!empty($form->_paymentProcessor['is_recur']) && !empty($form->_values['is_recur'])) { $form->_paymentObject = &CRM_Core_Payment::singleton($mode, $form->_paymentProcessor, $form); $form->_values['cancelSubscriptionUrl'] = $form->_paymentObject->subscriptionURL(); } //checks after setting $form->_paymentProcessor // we do this outside of the above conditional to avoid // saving the country/state list in the session (which could be huge) CRM_Core_Payment_Form::setPaymentFieldsByProcessor($form, $form->_paymentProcessor); $form->assign_by_ref('paymentProcessor', $form->_paymentProcessor); // check if this is a paypal auto return and redirect accordingly if (CRM_Core_Payment::paypalRedirect($form->_paymentProcessor)) { $url = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_ThankYou_display=1&qfKey={$form->controller->_key}" ); CRM_Utils_System::redirect($url); } // make sure we have a valid payment class, else abort if (!empty($form->_values['is_monetary']) && !$form->_paymentProcessor['class_name'] && empty($form->_values['is_pay_later'])) { CRM_Core_Error::fatal(ts('Payment processor is not set for this page')); } if (!empty($form->_membershipBlock) && !empty($form->_membershipBlock['is_separate_payment']) && (!empty($form->_paymentProcessor['class_name']) && !(CRM_Utils_Array::value('billing_mode', $form->_paymentProcessor) & CRM_Core_Payment::BILLING_MODE_FORM) ) ) { CRM_Core_Error::fatal(ts('This contribution page is configured to support separate contribution and membership payments. This %1 plugin does not currently support multiple simultaneous payments, or the option to "Execute real-time monetary transactions" is disabled. Please contact the site administrator and notify them of this error', array(1 => $form->_paymentProcessor['payment_processor_type']) ) ); } } /** * @param $form */ static function buildQuickform(&$form) { $form->addElement('hidden', 'hidden_processor', 1); $profileAddressFields = $form->get('profileAddressFields'); if (!empty($profileAddressFields)) { $form->assign('profileAddressFields', $profileAddressFields); } // check if show billing setting is enabled if ($form->getVar( '_ppType' ) == 0 && $form->_isBillingAddressRequiredForPayLater) { CRM_Core_Payment_Form::buildAddressBlock($form); return; } // before we do this lets see if the payment processor has implemented a buildForm method if (method_exists($form->_paymentProcessor['instance'], 'buildForm') && is_callable(array($form->_paymentProcessor['instance'], 'buildForm'))) { // the payment processor implements the buildForm function, let the payment // processor do the work $form->_paymentProcessor['instance']->buildForm($form); return; } if (($form->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT)) { CRM_Core_Payment_Form::buildDirectDebit($form, TRUE); } elseif (($form->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_CREDIT_CARD)) { CRM_Core_Payment_Form::buildCreditCard($form, TRUE); } } }