Skip to content

Commit

Permalink
Convert event cart to use standard payment forms
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Jul 19, 2020
1 parent 92383a1 commit 447501f
Show file tree
Hide file tree
Showing 8 changed files with 308 additions and 490 deletions.
24 changes: 24 additions & 0 deletions ext/eventcart/CRM/Event/Cart/BAO/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,4 +343,28 @@ public function adopt_participants($from_cart_id) {
CRM_Core_DAO::executeQuery($sql, $params);
}

/**
* Get payment processors.
*
* This differs from the option value in that we append description for disambiguation.
*
* @return array
* @throws \CiviCRM_API3_Exception
*/
public static function getPaymentProcessors(): array {
$results = civicrm_api3('PaymentProcessor', 'get', [
'is_test' => 0,
'return' => ['id', 'name', 'description', 'domain_id'],
]);

$processors = [];
foreach ($results['values'] as $processorID => $details) {
$processors[$processorID] = $details['name'];
if (!empty($details['description'])) {
$processors[$processorID] .= ' : ' . $details['description'];
}
}
return $processors;
}

}
19 changes: 0 additions & 19 deletions ext/eventcart/CRM/Event/Cart/BAO/MerParticipant.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,25 +153,6 @@ public function get_participant_index() {
return $index + 1;
}

/**
* @param $contact
*
* @return null
*/
public static function billing_address_from_contact($contact) {
foreach ($contact->address as $loc) {
if ($loc['is_billing']) {
return $loc;
}
}
foreach ($contact->address as $loc) {
if ($loc['is_primary']) {
return $loc;
}
}
return NULL;
}

/**
* @return CRM_Event_Cart_Form_MerParticipant
*/
Expand Down
25 changes: 0 additions & 25 deletions ext/eventcart/CRM/Event/Cart/Form/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ class CRM_Event_Cart_Form_Cart extends CRM_Core_Form {
*/
public $cart;

public $_action;
public $contact;
public $event_cart_id = NULL;
public $_mode;
public $participants;

public function preProcess() {
$this->_action = CRM_Utils_Request::retrieveValue('action', 'String');
$this->_mode = 'live';
$this->loadCart();

$this->checkWaitingList();
Expand Down Expand Up @@ -96,28 +93,6 @@ public function checkEventCapacity($event_id) {
}
}

/**
* @return int
* @throws \CRM_Core_Exception
*/
public function getContactID() {
$tempID = CRM_Utils_Request::retrieveValue('cid', 'Positive');

//check if this is a checksum authentication
$userChecksum = CRM_Utils_Request::retrieveValue('cs', 'String');
if ($userChecksum) {
//check for anonymous user.
$validUser = CRM_Contact_BAO_Contact_Utils::validChecksum($tempID, $userChecksum);
if ($validUser) {
return $tempID;
}
}

// check if the user is registered and we have a contact ID
$session = CRM_Core_Session::singleton();
return $session->get('userID');
}

/**
* @param $fields
*
Expand Down
Loading

0 comments on commit 447501f

Please sign in to comment.