Skip to content
Snippets Groups Projects
Commit 2a29046a authored by mattwire's avatar mattwire
Browse files

More library update fixes

parent aed2cef1
Branches
Tags
1 merge request!1246.5
......@@ -1125,10 +1125,13 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
* @throws \CiviCRM_API3_Exception
* @throws \Stripe\Exception\UnknownApiErrorException
*/
public static function processPaymentNotification($paymentProcessorID, $rawData, $verifyRequest = TRUE) {
public static function processPaymentNotification($paymentProcessorID, $rawData, $verifyRequest = TRUE, $emailReceipt = NULL) {
$_GET['processor_id'] = $paymentProcessorID;
$ipnClass = new CRM_Core_Payment_StripeIPN($rawData, $verifyRequest);
$ipnClass->setExceptionMode(FALSE);
if (isset($emailReceipt)) {
$ipnClass->setSendEmailReceipt($emailReceipt);
}
return $ipnClass->main();
}
......
......@@ -404,8 +404,6 @@ class CRM_Core_Payment_StripeIPN {
* @throws \CRM_Core_Exception
*/
public function setInfo() {
$stripeObjectName = get_class($this->_inputParameters->data->object);
if (!$this->getCustomer()) {
if ((bool)\Civi::settings()->get('stripe_ipndebug')) {
$message = $this->_paymentProcessor->getPaymentProcessorLabel() . ': ' . CRM_Stripe_Api::getParam('id', $this->_inputParameters) . ': Missing customer_id';
......@@ -427,7 +425,7 @@ class CRM_Core_Payment_StripeIPN {
$this->plan_start = $this->retrieve('plan_start', 'String', FALSE);
$this->amount = $this->retrieve('amount', 'String', FALSE);
if (($stripeObjectName !== 'Stripe\Charge') && ($this->charge_id !== NULL)) {
if (($this->_inputParameters->data->object->object !== 'charge') && ($this->charge_id !== NULL)) {
$charge = \Stripe\Charge::retrieve($this->charge_id);
$balanceTransactionID = CRM_Stripe_Api::getObjectParam('balance_transaction', $charge);
}
......
......@@ -47,7 +47,7 @@ function civicrm_api3_stripe_Ipn($params) {
$object = NULL;
$ppid = NULL;
if (array_key_exists('id', $params)) {
$data = civicrm_api3('SystemLog', 'getsingle', array('id' => $params['id'], 'return' => array('message', 'context')));
$data = civicrm_api3('SystemLog', 'getsingle', ['id' => $params['id'], 'return' => ['message', 'context']]);
if (empty($data)) {
throw new API_Exception('Failed to find that entry in the system log', 3234);
}
......@@ -64,8 +64,8 @@ function civicrm_api3_stripe_Ipn($params) {
throw new API_Exception('Please pass the payment processor id (ppid) if using evtid.', 3236);
}
$ppid = $params['ppid'];
$processor = new CRM_Core_Payment_Stripe('', civicrm_api3('PaymentProcessor', 'getsingle', ['id' => $ppid]));
$processor->setAPIParams();
$paymentProcessor = new CRM_Core_Payment_Stripe('', civicrm_api3('PaymentProcessor', 'getsingle', ['id' => $ppid]));
$paymentProcessor->setAPIParams();
$object = \Stripe\Event::retrieve($params['evtid']);
}
......@@ -97,16 +97,8 @@ function civicrm_api3_stripe_Ipn($params) {
}
if (class_exists('CRM_Core_Payment_StripeIPN')) {
// The $_GET['processor_id'] value is normally set by
// CRM_Core_Payment::handlePaymentMethod
$_GET['processor_id'] = $ppid;
$ipnClass = new CRM_Core_Payment_StripeIPN($object);
$ipnClass->setExceptionMode(FALSE);
if ($params['noreceipt'] == 1) {
$ipnClass->setSendEmailReceipt(0);
}
try {
$ipnClass->main();
$paymentProcessor->processPaymentNotification($ppid, $object, TRUE, ($params['noreceipt'] == 1) ? 0 : NULL);
} catch(Throwable $e) {
return civicrm_api3_create_error($e->getMessage());
}
......@@ -114,5 +106,5 @@ function civicrm_api3_stripe_Ipn($params) {
else {
trigger_error("The api depends on CRM_Core_Payment_StripeIPN");
}
return civicrm_api3_create_success(array());
return civicrm_api3_create_success([]);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment