billingProfile == 'billing') { // @todo - use profile api to retrieve this - either as pseudo-profile or (better) set up billing // as a reserved profile in the DB and (even better) allow the profile to be selected // on the form instead of just 'billing for pay=later bool' return array( 'first_name' => 'billing_first_name', 'middle_name' => 'billing_middle_name', 'last_name' => 'billing_last_name', 'street_address' => "billing_street_address-{$billingLocationID}", 'city' => "billing_city-{$billingLocationID}", 'country' => "billing_country_id-{$billingLocationID}", 'state_province' => "billing_state_province_id-{$billingLocationID}", 'postal_code' => "billing_postal_code-{$billingLocationID}", ); } else { return array(); } } /** * Get array of fields that should be displayed on the payment form. * * @return array */ public function getPaymentFormFields() { return array(); } /** * Process payment. * * The function ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms * more agnostic. * * @param array $params * * @param string $component * * @return array * Result array * * @throws \Civi\Payment\Exception\PaymentProcessorException */ public function doPayment(&$params, $component = 'contribute') { $params['payment_status_id'] = $this->getResult(); return $params; } /** * Get the result of the payment. * * Usually this will be pending but the calling layer has a chance to set the result. * * This would apply in particular when the form accepts status id. * * Note that currently this payment class is only being used to manage the 'billing block' aspect * of pay later. However, a longer term idea is that by treating 'pay-later' as 'just another processor' * will allow code simplification. * * @return int */ protected function getResult() { if (!$this->result) { $this->setResult(CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'status_id', 'Pending')); } return $this->result; } /** * Set the result to be returned. * * This would be set from outside the function where we want to pass on the status from the form. * * @param int $result */ public function setResult($result) { $this->result = $result; } /** * Get the name of the payment type. * * @return string */ public function getPaymentTypeName() { return 'pay-later'; } /** * Get the name of the payment type. * * @return string */ public function getPaymentTypeLabel() { return ''; } /** * Declare that more than one payment can be processed at once. * * @return bool */ protected function supportsMultipleConcurrentPayments() { return TRUE; } /** * Checks if backoffice recurring edit is allowed * * @return bool */ public function supportsEditRecurringContribution() { return TRUE; } /** * Submit a manual payment. * * @param array $params * Assoc array of input parameters for this transaction. * * @return array */ public function doDirectPayment(&$params) { $statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id'); if ($params['is_pay_later']) { $result['payment_status_id'] = array_search('Pending', $statuses); } else { $result['payment_status_id'] = array_search('Completed', $statuses); } return $result; } /** * Should a receipt be sent out for a pending payment. * * e.g for traditional pay later & ones with a delayed settlement a pending receipt makes sense. */ public function isSendReceiptForPending() { return TRUE; } }