3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_Core_Payment_Manual
extends CRM_Core_Payment
{
22 * This function checks to see if we have the right config values.
24 public function checkConfig() {}
29 public function __construct() {
30 $this->_paymentProcessor
= [
40 * Get billing fields required for this processor.
42 * We apply the existing default of returning fields only for payment processor type 1. Processors can override to
45 * @param int $billingLocationID
49 public function getBillingAddressFields($billingLocationID = NULL) {
50 if (!$billingLocationID) {
51 // Note that although the billing id is passed around the forms the idea that it would be anything other than
52 // the result of the function below doesn't seem to have eventuated.
53 // So taking this as a param is possibly something to be removed in favour of the standard default.
54 $billingLocationID = CRM_Core_BAO_LocationType
::getBilling();
57 // Only handle pseudo-profile billing for now.
58 if ($this->billingProfile
== 'billing') {
59 // @todo - use profile api to retrieve this - either as pseudo-profile or (better) set up billing
60 // as a reserved profile in the DB and (even better) allow the profile to be selected
61 // on the form instead of just 'billing for pay=later bool'
63 'first_name' => 'billing_first_name',
64 'middle_name' => 'billing_middle_name',
65 'last_name' => 'billing_last_name',
66 'street_address' => "billing_street_address-{$billingLocationID}",
67 'city' => "billing_city-{$billingLocationID}",
68 'country' => "billing_country_id-{$billingLocationID}",
69 'state_province' => "billing_state_province_id-{$billingLocationID}",
70 'postal_code' => "billing_postal_code-{$billingLocationID}",
79 * Get array of fields that should be displayed on the payment form.
83 public function getPaymentFormFields() {
84 if (!$this->isBackOffice()) {
88 $paymentInstrument = CRM_Core_PseudoConstant
::getName('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', $this->getPaymentInstrumentID());
89 if ($paymentInstrument === 'Credit Card') {
90 return ['credit_card_type', 'pan_truncation'];
92 elseif ($paymentInstrument === 'Check') {
93 return ['check_number'];
101 * The function ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms
104 * @param array $params
106 * @param string $component
111 * @throws \Civi\Payment\Exception\PaymentProcessorException
113 public function doPayment(&$params, $component = 'contribute') {
114 $params['payment_status_id'] = $this->getResult();
119 * Get the result of the payment.
121 * Usually this will be pending but the calling layer has a chance to set the result.
123 * This would apply in particular when the form accepts status id.
125 * Note that currently this payment class is only being used to manage the 'billing block' aspect
126 * of pay later. However, a longer term idea is that by treating 'pay-later' as 'just another processor'
127 * will allow code simplification.
131 protected function getResult() {
132 if (!$this->result
) {
133 $this->setResult(CRM_Core_PseudoConstant
::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending'));
135 return $this->result
;
139 * Set the result to be returned.
141 * This would be set from outside the function where we want to pass on the status from the form.
145 public function setResult($result) {
146 $this->result
= $result;
150 * Set payment instrument id.
152 * @param int $paymentInstrumentID
154 public function setPaymentInstrumentID($paymentInstrumentID) {
155 $this->paymentInstrumentID
= $paymentInstrumentID;
159 * Get the name of the payment type.
163 public function getPaymentTypeName() {
168 * Get the name of the payment type.
172 public function getPaymentTypeLabel() {
173 return CRM_Core_PseudoConstant
::getLabel('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', $this->getPaymentInstrumentID());
177 * Are live payments supported - e.g dummy doesn't support this.
181 protected function supportsLiveMode() {
186 * Are test payments supported.
190 protected function supportsTestMode() {
195 * Declare that more than one payment can be processed at once.
199 protected function supportsMultipleConcurrentPayments() {
204 * Checks if backoffice recurring edit is allowed
208 public function supportsEditRecurringContribution() {
213 * Does the processor support the user having a choice as to whether to cancel the recurring with the processor?
215 * If this returns TRUE then there will be an option to send a cancellation request in the cancellation form.
217 * This would normally be false for processors where CiviCRM maintains the schedule.
221 protected function supportsCancelRecurringNotifyOptional() {
226 * Are back office payments supported.
230 protected function supportsBackOffice() {
235 * Does the processor work without an email address?
237 protected function supportsNoEmailProvided() {
242 * Should a receipt be sent out for a pending payment.
244 * e.g for traditional pay later & ones with a delayed settlement a pending receipt makes sense.
246 public function isSendReceiptForPending() {
251 * Get help text information (help, description, etc.) about this payment,
252 * to display to the user.
254 * @param string $context
255 * Context of the text.
256 * Only explicitly supported contexts are handled without error.
257 * Currently supported:
258 * - contributionPageRecurringHelp (params: is_recur_installments, is_email_receipt)
260 * @param array $params
261 * Parameters for the field, context specific.
265 public function getText($context, $params) {
267 case 'contributionPageContinueText':
268 if ($params['amount'] <= 0) {
269 return ts('To complete this transaction, click the <strong>Continue</strong> button below.');
271 return ts('To complete your contribution, click the <strong>Continue</strong> button below.');