Skip to content

Commit

Permalink
refs #40509, do not generate receipt id and send receipt when auto sy…
Browse files Browse the repository at this point in the history
…nc not the same day with process date
  • Loading branch information
jimyhuang committed Sep 5, 2024
1 parent 3681126 commit 71d32c8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions CRM/Core/Payment/SPGATEWAY.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,8 @@ public static function doRecurUpdate($id, $idType = 'contribution', $form = NULL
}
}

$result = self::recurSyncTransaction($trxn_id, TRUE);
// this must be manually triggered
$result = self::recurSyncTransaction($trxn_id, TRUE, NULL, TRUE);
$session = CRM_Core_Session::singleton();
if (!empty($result)) {
if ($isAddedNewContribution) {
Expand Down Expand Up @@ -1282,7 +1283,7 @@ public static function recurSync($recurId) {
* @param string $order
* @return object|bool
*/
public static function recurSyncTransaction($trxnId, $createContribution = FALSE, $order = NULL) {
public static function recurSyncTransaction($trxnId, $createContribution = FALSE, $order = NULL, $manually = FALSE) {
$parentTrxnId = 0;
$paymentProcessorId = 0;
if (strstr($trxnId, '_')) {
Expand Down Expand Up @@ -1387,6 +1388,17 @@ public static function recurSyncTransaction($trxnId, $createContribution = FALSE
if (preg_match('/^r_/', $trxnId)) {
$ipnResult->Result->OrderNo = $trxnId;
}
$processDate = NULL;
if (isset($ipnResult->Result->AuthDate)) {
$processDate = $ipnResult->Result->AuthDate;
}
elseif (isset($ipnResult->Result->AuthTime)) {
$processDate = $ipnResult->Result->AuthTime;
}
if (!empty($processDate) && strtotime($processDate) < strtotime('today')) {
$ipnResult->Result->do_not_email = 1;
$ipnResult->Result->do_not_receipt = 1;
}
$ipnResult = json_encode($ipnResult);
$ipnPost = array('Period' => CRM_Core_Payment_SPGATEWAYAPI::recurEncrypt($ipnResult, $paymentProcessor));

Expand Down

0 comments on commit 71d32c8

Please sign in to comment.