3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
33 class CRM_Core_Payment_Manual
extends CRM_Core_Payment
{
38 * This function checks to see if we have the right config values.
40 public function checkConfig() {}
43 * Get billing fields required for this processor.
45 * We apply the existing default of returning fields only for payment processor type 1. Processors can override to
48 * @param int $billingLocationID
52 public function getBillingAddressFields($billingLocationID = NULL) {
53 if (!$billingLocationID) {
54 // Note that although the billing id is passed around the forms the idea that it would be anything other than
55 // the result of the function below doesn't seem to have eventuated.
56 // So taking this as a param is possibly something to be removed in favour of the standard default.
57 $billingLocationID = CRM_Core_BAO_LocationType
::getBilling();
60 // Only handle pseudo-profile billing for now.
61 if ($this->billingProfile
== 'billing') {
62 // @todo - use profile api to retrieve this - either as pseudo-profile or (better) set up billing
63 // as a reserved profile in the DB and (even better) allow the profile to be selected
64 // on the form instead of just 'billing for pay=later bool'
66 'first_name' => 'billing_first_name',
67 'middle_name' => 'billing_middle_name',
68 'last_name' => 'billing_last_name',
69 'street_address' => "billing_street_address-{$billingLocationID}",
70 'city' => "billing_city-{$billingLocationID}",
71 'country' => "billing_country_id-{$billingLocationID}",
72 'state_province' => "billing_state_province_id-{$billingLocationID}",
73 'postal_code' => "billing_postal_code-{$billingLocationID}",
82 * Get array of fields that should be displayed on the payment form.
86 public function getPaymentFormFields() {
92 * The function ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms
95 * @param array $params
97 * @param string $component
102 * @throws \Civi\Payment\Exception\PaymentProcessorException
104 public function doPayment(&$params, $component = 'contribute') {
105 $params['payment_status_id'] = $this->getResult();
110 * Get the result of the payment.
112 * Usually this will be pending but the calling layer has a chance to set the result.
114 * This would apply in particular when the form accepts status id.
116 * Note that currently this payment class is only being used to manage the 'billing block' aspect
117 * of pay later. However, a longer term idea is that by treating 'pay-later' as 'just another processor'
118 * will allow code simplification.
122 protected function getResult() {
123 if (!$this->result
) {
124 $this->setResult(CRM_Core_PseudoConstant
::getKey('CRM_Contribute_BAO_Contribution', 'status_id', 'Pending'));
126 return $this->result
;
130 * Set the result to be returned.
132 * This would be set from outside the function where we want to pass on the status from the form.
136 public function setResult($result) {
137 $this->result
= $result;
141 * Get the name of the payment type.
145 public function getPaymentTypeName() {
150 * Get the name of the payment type.
154 public function getPaymentTypeLabel() {
159 * Declare that more than one payment can be processed at once.
163 protected function supportsMultipleConcurrentPayments() {
168 * Checks if backoffice recurring edit is allowed
172 public function supportsEditRecurringContribution() {
177 * Submit a manual payment.
179 * @param array $params
180 * Assoc array of input parameters for this transaction.
184 public function doDirectPayment(&$params) {
185 $statuses = CRM_Contribute_BAO_Contribution
::buildOptions('contribution_status_id');
186 if ($params['is_pay_later']) {
187 $result['payment_status_id'] = array_search('Pending', $statuses);
190 $result['payment_status_id'] = array_search('Completed', $statuses);