Skip to content
Snippets Groups Projects
Commit 3dd8c1f0 authored by mattwire's avatar mattwire
Browse files

Support recording full refunds from Stripe

parent c53420c2
No related branches found
No related tags found
1 merge request!686.1.5
...@@ -252,7 +252,7 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN { ...@@ -252,7 +252,7 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
$refunds = \Stripe\Refund::all(['charge' => $this->charge_id, 'limit' => 1]); $refunds = \Stripe\Refund::all(['charge' => $this->charge_id, 'limit' => 1]);
$params = [ $params = [
'id' => $this->contribution['id'], 'id' => $this->contribution['id'],
'total_amount' => $this->retrieve('amount_refunded', 'Float'), 'payment_trxn_id' => $this->charge_id,
'cancel_reason' => $refunds->data[0]->reason, 'cancel_reason' => $refunds->data[0]->reason,
'cancel_date' => date('YmdHis', $refunds->data[0]->created), 'cancel_date' => date('YmdHis', $refunds->data[0]->created),
]; ];
...@@ -367,11 +367,22 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN { ...@@ -367,11 +367,22 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
} }
} }
$contributionParamsToReturn = [
'id',
'trxn_id',
'contribution_status_id',
'total_amount',
'fee_amount',
'net_amount',
'tax_amount',
];
if ($this->charge_id) { if ($this->charge_id) {
try { try {
$this->contribution = civicrm_api3('Contribution', 'getsingle', [ $this->contribution = civicrm_api3('Contribution', 'getsingle', [
'trxn_id' => $this->charge_id, 'trxn_id' => $this->charge_id,
'contribution_test' => $this->_paymentProcessor->getIsTestMode(), 'contribution_test' => $this->_paymentProcessor->getIsTestMode(),
'return' => $contributionParamsToReturn,
]); ]);
} }
catch (Exception $e) { catch (Exception $e) {
...@@ -383,6 +394,7 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN { ...@@ -383,6 +394,7 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
$this->contribution = civicrm_api3('Contribution', 'getsingle', [ $this->contribution = civicrm_api3('Contribution', 'getsingle', [
'trxn_id' => $this->invoice_id, 'trxn_id' => $this->invoice_id,
'contribution_test' => $this->_paymentProcessor->getIsTestMode(), 'contribution_test' => $this->_paymentProcessor->getIsTestMode(),
'return' => $contributionParamsToReturn,
]); ]);
} }
catch (Exception $e) { catch (Exception $e) {
...@@ -397,6 +409,7 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN { ...@@ -397,6 +409,7 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
'return' => ['id', 'contribution_status_id', 'total_amount', 'trxn_id'], 'return' => ['id', 'contribution_status_id', 'total_amount', 'trxn_id'],
'contribution_recur_id' => $this->contribution_recur_id, 'contribution_recur_id' => $this->contribution_recur_id,
'contribution_test' => $this->_paymentProcessor->getIsTestMode(), 'contribution_test' => $this->_paymentProcessor->getIsTestMode(),
'return' => $contributionParamsToReturn,
'options' => ['limit' => 1, 'sort' => 'id DESC'], 'options' => ['limit' => 1, 'sort' => 'id DESC'],
]); ]);
} }
......
...@@ -10,7 +10,7 @@ use CRM_Stripe_ExtensionUtil as E; ...@@ -10,7 +10,7 @@ use CRM_Stripe_ExtensionUtil as E;
*/ */
class CRM_Stripe_Check { class CRM_Stripe_Check {
const MIN_VERSION_MJWSHARED = '0.4.3'; const MIN_VERSION_MJWSHARED = '0.4.4';
public static function checkRequirements(&$messages) { public static function checkRequirements(&$messages) {
$extensions = civicrm_api3('Extension', 'get', [ $extensions = civicrm_api3('Extension', 'get', [
......
...@@ -5,6 +5,15 @@ Integrates the Stripe payment processor (for Credit/Debit cards) into CiviCRM so ...@@ -5,6 +5,15 @@ Integrates the Stripe payment processor (for Credit/Debit cards) into CiviCRM so
View/Download this extension in the [Extension Directory](https://civicrm.org/extensions/stripe-payment-processor). View/Download this extension in the [Extension Directory](https://civicrm.org/extensions/stripe-payment-processor).
## Supports
* PSD2 / SCA payments on one-off payments, partial support for recurring payments (may not be able to authorise card in some cases).
* Cancellation of subscriptions from Stripe / CiviCRM.
* Full refund of payments from Stripe.
### Does not support
* Partial refunds (they will not be processed by CiviCRM correctly and will be recorded as a full refund of a contribution).
* Updating Stripe subscriptions from CiviCRM.
## Compatibility / Requirements ## Compatibility / Requirements
* CiviCRM 5.13+ * CiviCRM 5.13+
* PHP 7.1+ * PHP 7.1+
......
## Release 6.1.5 ## Release 6.1.5
* Send email receipts from Stripe by default (as this was what 5.x did). Add a setting under Administer->CiviContribute->Stripe Settings to enable/disable receipts from Stripe. * Send email receipts from Stripe by default (as this was what 5.x did). Add a setting under Administer->CiviContribute->Stripe Settings to enable/disable receipts from Stripe.
* Support recording full refunds from Stripe.
## Release 6.1.4 ## Release 6.1.4
**This release fixes a MAJOR issue that caused duplicate payments to be taken when a new recurring contribution (subscription) was setup. All users of 6.x should upgrade.** **This release fixes a MAJOR issue that caused duplicate payments to be taken when a new recurring contribution (subscription) was setup. All users of 6.x should upgrade.**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment