Commit 1212b577 authored by mattwire's avatar mattwire

Update stripe API compatibility, cleanup some code

parent ee4bfa86
......@@ -9,12 +9,10 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
use CRM_Core_Payment_StripeTrait;
/**
* We only need one instance of this object. So we use the singleton
* pattern and cache the instance in this variable
*
* @var object
* @var string
*/
private static $_singleton = NULL;
protected $_stripeAPIVersion = '2019-02-19';
/**
* Mode of operation: live or test.
......@@ -23,13 +21,6 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
*/
protected $_mode = NULL;
/**
* TRUE if we are dealing with a live transaction
*
* @var boolean
*/
private $_islive = FALSE;
/**
* Constructor
*
......@@ -40,7 +31,6 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
*/
public function __construct($mode, &$paymentProcessor) {
$this->_mode = $mode;
$this->_islive = ($mode == 'live' ? 1 : 0);
$this->_paymentProcessor = $paymentProcessor;
$this->_processorName = ts('Stripe');
}
......@@ -178,7 +168,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$planId = $params['membership_type_tag'] . $planId;
}
if (!$this->_islive) {
if ($this->_paymentProcessor['is_test']) {
$planId .= '-test';
}
......@@ -192,7 +182,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
if ($err['code'] == 'resource_missing') {
$formatted_amount = number_format(($amount / 100), 2);
$productName = "CiviCRM " . (isset($params['membership_name']) ? $params['membership_name'] . ' ' : '') . "every {$params['frequency_interval']} {$params['frequency_unit']}(s) {$formatted_amount}{$currency}";
if (!$this->_islive) {
if ($this->_paymentProcessor['is_test']) {
$productName .= '-test';
}
$product = \Stripe\Product::create(array(
......@@ -452,7 +442,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$customerParams = [
'contact_id' => $contactId,
'card_token' => $card_token,
'is_live' => $this->_islive,
'is_live' => !$this->_paymentProcessor['is_test'],
'processor_id' => $this->_paymentProcessor['id'],
'email' => $email,
];
......@@ -858,7 +848,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
}
/**
* Process incoming notification.
* Process incoming payment notification (IPN).
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
......
......@@ -20,7 +20,7 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
*
* @var int
*/
protected $is_email_receipt = 1;
public $is_email_receipt = 1;
// By default, always retrieve the event from stripe to ensure we are
// not being fed garbage. However, allow an override so when we are
......@@ -53,14 +53,14 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
/**
* CRM_Core_Payment_StripeIPN constructor.
*
* @param $inputData
* @param $ipnData
* @param bool $verify
*
* @throws \CRM_Core_Exception
*/
public function __construct($inputData, $verify = TRUE) {
public function __construct($ipnData, $verify = TRUE) {
$this->verify_event = $verify;
$this->setInputParameters($inputData);
$this->setInputParameters($ipnData);
parent::__construct();
}
......
......@@ -8,11 +8,11 @@ Latest releases can be found here: https://civicrm.org/extensions/stripe-payment
View this extension in the [Extension Directory](https://civicrm.org/extensions/stripe-payment-processor).
## Compatibility / Requirements
* CiviCRM 5.3+
* PHP 5.6+
* CiviCRM 5.10+
* PHP 7.0+
* Jquery 1.10 (Use jquery_update module on Drupal).
* Drupal 7 / Joomla / Wordpress (latest supported release). *Not currently tested with other CMS but it may work.*
* Stripe API version: 2018-11-08
* Stripe API version: 2019-02-19
* Drupal webform_civicrm 7.x-4.22+ (if using webform integration)
## Credits
......
## Release 5.3
There are no database changes in this release but you should update your Stripe webhook API version to 2019-02-19.
## Release 5.2
*This release introduces a number of new features, standardises the behaviour of recurring contributions/memberships to match standard CiviCRM functionality and does a major cleanup of the backend code to improve stability and allow for new features.*
......
......@@ -16,7 +16,7 @@
<version>5.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.3</ver>
<ver>5.10.3</ver>
</compatibility>
<comments>Original Author: Joshua Walker (drastik) - Drastik by Design.
Jamie Mcclelland (ProgressiveTech) did a lot of the 5.x compatibility work.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment