$session->set('userID', NULL);
$tablesToTruncate = array('civicrm_contact');
$this->quickCleanup($tablesToTruncate);
+ $this->createDomainContacts();
$this->cleanTempDirs();
$this->unsetExtensionSystem();
+ CRM_Core_Transaction::forceRollbackIfEnabled();
+ \Civi\Core\Transaction\Manager::singleton(TRUE);
+ $this->clearOutputBuffer();
}
/**
$this->callAPISuccess('price_field_value', 'create', array_merge($priceFieldValue, array('price_field_id' => $newPriceField['id'])));
}
- /**
- * Create an instance of the paypal processor
- * @todo this isn't a great place to put it - but really it belongs on a class that extends
- * this parent class & we don't have a structure for that yet
- * There is another function to this effect on the PaypalPro test but it appears to be silently failing
- * & the best protection agains that is the functions this class affords
- */
- function paymentProcessorCreate($params = array()) {
- $params = array_merge(array(
- 'name' => 'demo',
- 'domain_id' => CRM_Core_Config::domainID(),
- 'payment_processor_type_id' => 'PayPal',
- 'is_active' => 1,
- 'is_default' => 0,
- 'is_test' => 1,
- 'user_name' => 'sunil._1183377782_biz_api1.webaccess.co.in',
- 'password' => '1183377788',
- 'signature' => 'APixCoQ-Zsaj-u3IH7mD5Do-7HUqA9loGnLSzsZga9Zr-aNmaJa3WGPH',
- 'url_site' => 'https://www.sandbox.paypal.com/',
- 'url_api' => 'https://api-3t.sandbox.paypal.com/',
- 'url_button' => 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif',
- 'class_name' => 'Payment_PayPalImpl',
- 'billing_mode' => 3,
- 'financial_type_id' => 1,
- ),
- $params);
- if(!is_numeric($params['payment_processor_type_id'])) {
- // really the api should handle this through getoptions but it's not exactly api call so lets just sort it
- //here
- $params['payment_processor_type_id'] = $this->callAPISuccess('payment_processor_type', 'getvalue', array(
- 'name' => $params['payment_processor_type_id'],
- 'return' => 'id',
- ), 'integer');
- }
- $result = $this->callAPISuccess('payment_processor', 'create', $params);
- return $result['id'];
- }
+ /**
+ * Create an instance of the paypal processor
+ * @todo this isn't a great place to put it - but really it belongs on a class that extends
+ * this parent class & we don't have a structure for that yet
+ * There is another function to this effect on the PaypalPro test but it appears to be silently failing
+ * & the best protection agains that is the functions this class affords
+ */
+ function paymentProcessorCreate($params = array()) {
+ $params = array_merge(array(
+ 'name' => 'demo',
+ 'domain_id' => CRM_Core_Config::domainID(),
+ 'payment_processor_type_id' => 'PayPal',
+ 'is_active' => 1,
+ 'is_default' => 0,
+ 'is_test' => 1,
+ 'user_name' => 'sunil._1183377782_biz_api1.webaccess.co.in',
+ 'password' => '1183377788',
+ 'signature' => 'APixCoQ-Zsaj-u3IH7mD5Do-7HUqA9loGnLSzsZga9Zr-aNmaJa3WGPH',
+ 'url_site' => 'https://www.sandbox.paypal.com/',
+ 'url_api' => 'https://api-3t.sandbox.paypal.com/',
+ 'url_button' => 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif',
+ 'class_name' => 'Payment_PayPalImpl',
+ 'billing_mode' => 3,
+ 'financial_type_id' => 1,
+ ),
+ $params);
+ if(!is_numeric($params['payment_processor_type_id'])) {
+ // really the api should handle this through getoptions but it's not exactly api call so lets just sort it
+ //here
+ $params['payment_processor_type_id'] = $this->callAPISuccess('payment_processor_type', 'getvalue', array(
+ 'name' => $params['payment_processor_type_id'],
+ 'return' => 'id',
+ ), 'integer');
+ }
+ $result = $this->callAPISuccess('payment_processor', 'create', $params);
+ return $result['id'];
+ }
+ /**
+ * Set up initial recurring payment allowing subsequent IPN payments
+ */
+ function setupRecurringPaymentProcessorTransaction() {
+ $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array(
+ 'contact_id' => $this->_contactID,
+ 'amount' => 1000,
+ 'sequential' => 1,
+ 'installments' => 5,
+ 'frequency_unit' => 'Month',
+ 'frequency_interval' => 1,
+ 'invoice_id' => $this->_invoiceID,
+ 'contribution_status_id' => 2,
+ 'processor_id' => $this->_paymentProcessorID,
+ 'api.contribution.create' => array(
+ 'total_amount' => '200',
+ 'invoice_id' => $this->_invoiceID,
+ 'financial_type_id' => 1,
+ 'contribution_status_id' => 'Pending',
+ 'contact_id' => $this->_contactID,
+ 'contribution_page_id' => $this->_contributionPageID,
+ 'payment_processor_id' => $this->_paymentProcessorID,
+ )
+ ));
+ $this->_contributionRecurID = $contributionRecur['id'];
+ $this->_contributionID = $contributionRecur['values']['0']['api.contribution.create']['id'];
+ }
+
+ /**
+ * We don't have a good way to set up a recurring contribution with a membership so let's just do one then alter it
+ */
+ function setupMembershipRecurringPaymentProcessorTransaction() {
+ $this->ids['membership_type'] = $this->membershipTypeCreate();
+ //create a contribution so our membership & contribution don't both have id = 1
+ $this->contributionCreate($this->_contactID, 1, 'abcd', '345j');
+ $this->setupRecurringPaymentProcessorTransaction();
+
+ $this->ids['membership'] = $this->callAPISuccess('membership', 'create', array(
+ 'contact_id' => $this->_contactID,
+ 'membership_type_id' => $this->ids['membership_type'],
+ 'contribution_recur_id' => $this->_contributionRecurID,
+ 'format.only_id' => TRUE,
+ ));
+ //CRM-15055 creates line items we don't want so get rid of them so we can set up our own line items
+ CRM_Core_DAO::executeQuery("TRUNCATE civicrm_line_item");
+
+ $this->callAPISuccess('line_item', 'create', array(
+ 'entity_table' => 'civicrm_membership',
+ 'entity_id' => $this->ids['membership'],
+ 'contribution_id' => $this->_contributionID,
+ 'label' => 'General',
+ 'qty' => 1,
+ 'unit_price' => 200,
+ 'line_total' => 200,
+ 'financial_type_id' => 1,
+ 'price_field_id' => $this->callAPISuccess('price_field', 'getvalue', array('return' => 'id', 'label' => 'Membership Amount')),
+ 'price_field_value_id' => $this->callAPISuccess('price_field_value', 'getvalue', array('return' => 'id', 'label' => 'General')),
+ ));
+ $this->callAPISuccess('membership_payment', 'create', array('contribution_id' => $this->_contributionID, 'membership_id' => $this->ids['membership']));
+ }
/**
* @param $message