Commit 5b65185f authored by eileen's avatar eileen

Add Omnipay extension

parent 1baede9c

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

# CiviCRM editor configuration normalization
# @see http://editorconfig.org/
# This is the top-most .editorconfig file; do not search in parent directories.
root = true
# All files.
[*]
end_of_line = LF
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
<?php
/**
* Payment page class.
*
* This had to be done as a page to 'keep quickform from tampering'
* (e.g with the submit).
*
* But this means we lose a lot of quickform's html generation.
*/
class CRM_Core_Page_PaymentPage extends CRM_Core_Page {
/**
* Page run function.
*
* @return string
* @throws \CiviCRM_API3_Exception
*/
public function run() {
$formData = $this->getTransparentRedirectFormData(CRM_Utils_Request::retrieve('key', 'String', CRM_Core_DAO::$_nullObject, TRUE));
$paymentProcessorID = $formData['payment_processor_id'];
$paymentProcessor = civicrm_api3('payment_processor', 'getsingle', array('id' => $paymentProcessorID));
$contactID = $formData['contact_id'];
/** @var \CRM_Core_Payment_OmnipayMultiProcessor $processor */
$processor = Civi\Payment\System::singleton()->getByProcessor($paymentProcessor);
$displayFields = $processor->getTransparentDirectDisplayFields();
foreach ($displayFields as $fieldName => $displayField) {
if ($displayField['htmlType'] == 'date') {
$displayFields[$fieldName]['options']['year'] = $this->getDateFieldsYearOptions($displayField);
}
if (!empty($displayField['contact_api']) && !empty($contactID)) {
$contact = civicrm_api3('Contact', 'get', array('id' => $contactID, 'sequential' => 1, 'options' => array('limit' => 1)));
$displayFields[$fieldName]['options']['value'] = !empty($contact['values'][0]['display_name']) ? $contact['values'][0]['display_name'] : '';
}
}
if (!empty($displayFields)) {
CRM_Utils_System::setTitle(ts('Enter your payment details'));
}
$this->assign('hidden_fields', array_diff_key($formData, $displayFields));
$this->assign('display_fields', $displayFields);
$this->assign('post_url', $formData['post_submit_url']);
return parent::run();
}
/**
* Get the data required on the payment form.
*
* @param string $key
*
* @return array
*/
protected function getTransparentRedirectFormData($key) {
return json_decode(CRM_Core_Session::singleton()->get("transparent_redirect_data" . $key), TRUE);
}
/**
* Get year options for date fields.
*
* Quickform would normally do this but we are operating as a page
* to get around the off-site submit.
*
* @param array $field
* Metadata for the field.
*
* @return array
*/
protected function getDateFieldsYearOptions($field) {
$options = array();
$defaults = ['minYear' => date('Y'), 'maxYear' => date('Y') + 10];
$attributes = array_merge($defaults, CRM_Utils_Array::value('attributes', $field, []));
$field['options']['year'] = array();
$digits = CRM_Utils_Array::value('year_digits', $field, 4);
$year = $attributes['minYear'];
while ($year <= $attributes['maxYear']) {
$options[substr($year, -$digits)] = $year;
$year++;
}
return $options;
}
}
<?php
/**
* Created by IntelliJ IDEA.
* User: emcnaughton
* Date: 7/2/18
* Time: 7:38 PM
*/
<?php
// This file declares a managed database record of type "ReportTemplate".
// The record will be automatically inserted, updated, or deleted from the
// database as appropriate. For more details, see "hook_civicrm_managed" at:
// http://wiki.civicrm.org/confluence/display/CRMDOC42/Hook+Reference
$extensions = civicrm_api3('Extension', 'get', ['key' => 'nz.co.fuzion.extendedreport', 'status' => 'installed']);
if (!$extensions['count']) {
return [];
}
return [
[
'name' => 'CRM_Omnipaymultiprocessor_Form_Report_Omnilog',
'entity' => 'ReportTemplate',
'params' => [
'version' => 3,
'label' => 'Omnilog',
'description' => 'Debug log for omnipay - requires extended reports',
'class_name' => 'CRM_Omnipaymultiprocessor_Form_Report_Omnilog',
'report_url' => 'nz.co.fuzion.omnipaymultiprocessor/omnilog',
'component' => 'CiviContribute',
],
],
];
<?php
use CRM_Omnipaymultiprocessor_ExtensionUtil as E;
class CRM_Omnipaymultiprocessor_Form_Report_Omnilog extends CRM_Extendedreport_Form_Report_ExtendedReport {
public $_baseTable = 'civicrm_system_log';
public function __construct() {
if (!CRM_Core_Permission::check('administer payment processors')) {
throw new CRM_Core_Exception(E::ts('Report only accessible with administer Payment Processors permission, may contain credentials'));
}
$this->_columns = $this->getColumns('SystemLog', [
'fields' => TRUE,
'fields_defaults' => ['message', 'context', 'timestamp'],
'order_bys' => TRUE,
'order_by_defaulys' => ['id DESC'],
]);
parent::__construct();
}
protected function getSystemLogColumns($options) {
$specs = [
'id' => [
'name' => 'id',
'title' => E::ts('System log ID'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => TRUE,
'type' => CRM_Utils_Type::T_INT,
],
'message' => [
'name' => 'message',
'title' => E::ts('Message'),
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => FALSE,
'type' => CRM_Utils_Type::T_STRING,
],
'context' => [
'name' => 'context',
'title' => E::ts('Detail'),
'is_fields' => TRUE,