static function paypal($paymentProcessor, $paymentMode, $start, $end)
 {
     $url = "{$paymentProcessor['url_api']}nvp";
     $keyArgs = array('user' => $paymentProcessor['user_name'], 'pwd' => $paymentProcessor['password'], 'signature' => $paymentProcessor['signature'], 'version' => 3.0);
     $args = $keyArgs;
     $args += array('method' => 'TransactionSearch', 'startdate' => $start, 'enddate' => $end);
     require_once 'CRM/Core/Payment/PayPalImpl.php';
     $result = CRM_Core_Payment_PayPalImpl::invokeAPI($args, $url);
     require_once "CRM/Contribute/BAO/Contribution/Utils.php";
     $keyArgs['method'] = 'GetTransactionDetails';
     foreach ($result as $name => $value) {
         if (substr($name, 0, 15) == 'l_transactionid') {
             // We don't/can't process subscription notifications, which appear
             // to be identified by transaction ids beginning with S-
             if (substr($value, 0, 2) == 'S-') {
                 continue;
             }
             $keyArgs['transactionid'] = $value;
             $trxnDetails = CRM_Core_Payment_PayPalImpl::invokeAPI($keyArgs, $url);
             if (is_a($trxnDetails, 'CRM_Core_Error')) {
                 echo "PAYPAL ERROR: Skipping transaction id: {$value}<p>";
                 continue;
             }
             // only process completed payments
             if (strtolower($trxnDetails['paymentstatus']) != 'completed') {
                 continue;
             }
             // only process receipts, not payments
             if (strtolower($trxnDetails['transactiontype']) == 'sendmoney') {
                 continue;
             }
             $params = CRM_Contribute_BAO_Contribution_Utils::formatAPIParams($trxnDetails, self::$_paypalParamsMapper, 'paypal');
             if ($paymentMode == 'test') {
                 $params['is_test'] = 1;
             } else {
                 $params['is_test'] = 0;
             }
             if (CRM_Contribute_BAO_Contribution_Utils::processAPIContribution($params)) {
                 CRM_Core_Error::debug_log_message("Processed - {$trxnDetails['email']}, {$trxnDetails['amt']}, {$value} ..<p>", true);
             } else {
                 CRM_Core_Error::debug_log_message("Skipped - {$trxnDetails['email']}, {$trxnDetails['amt']}, {$value} ..<p>", true);
             }
         }
     }
 }
 /**
  * @param $paymentProcessor
  * @param $paymentMode
  * @param $start
  * @param $end
  */
 public static function paypal($paymentProcessor, $paymentMode, $start, $end)
 {
     $url = "{$paymentProcessor['url_api']}nvp";
     $keyArgs = array('user' => $paymentProcessor['user_name'], 'pwd' => $paymentProcessor['password'], 'signature' => $paymentProcessor['signature'], 'version' => 3.0);
     $args = $keyArgs;
     $args += array('method' => 'TransactionSearch', 'startdate' => $start, 'enddate' => $end);
     require_once 'CRM/Core/Payment/PayPalImpl.php';
     // as invokeAPI fetch only last 100 transactions.
     // we should require recursive calls to process more than 100.
     // first fetch transactions w/ give date intervals.
     // if we get error code w/ result, which means we do have more than 100
     // manipulate date interval accordingly and fetch again.
     do {
         $result = CRM_Core_Payment_PayPalImpl::invokeAPI($args, $url);
         require_once "CRM/Contribute/BAO/Contribution/Utils.php";
         $keyArgs['method'] = 'GetTransactionDetails';
         foreach ($result as $name => $value) {
             if (substr($name, 0, 15) == 'l_transactionid') {
                 // We don't/can't process subscription notifications, which appear
                 // to be identified by transaction ids beginning with S-
                 if (substr($value, 0, 2) == 'S-') {
                     continue;
                 }
                 // Before we bother making a remote API call to PayPal to lookup
                 // details about a transaction, let's make sure that it doesn't
                 // already exist in the database.
                 require_once 'CRM/Contribute/DAO/Contribution.php';
                 $dao = new CRM_Contribute_DAO_Contribution();
                 $dao->trxn_id = $value;
                 if ($dao->find(TRUE)) {
                     preg_match('/(\\d+)$/', $name, $matches);
                     $seq = $matches[1];
                     $email = $result["l_email{$seq}"];
                     $amt = $result["l_amt{$seq}"];
                     CRM_Core_Error::debug_log_message("Skipped (already recorded) - {$email}, {$amt}, {$value} ..<p>", TRUE);
                     continue;
                 }
                 $keyArgs['transactionid'] = $value;
                 $trxnDetails = CRM_Core_Payment_PayPalImpl::invokeAPI($keyArgs, $url);
                 if (is_a($trxnDetails, 'CRM_Core_Error')) {
                     echo "PAYPAL ERROR: Skipping transaction id: {$value}<p>";
                     continue;
                 }
                 // only process completed payments
                 if (strtolower($trxnDetails['paymentstatus']) != 'completed') {
                     continue;
                 }
                 // only process receipts, not payments
                 if (strtolower($trxnDetails['transactiontype']) == 'sendmoney') {
                     continue;
                 }
                 $params = self::formatAPIParams($trxnDetails, self::$_paypalParamsMapper, 'paypal');
                 if ($paymentMode == 'test') {
                     $params['transaction']['is_test'] = 1;
                 } else {
                     $params['transaction']['is_test'] = 0;
                 }
                 if (self::processAPIContribution($params)) {
                     CRM_Core_Error::debug_log_message("Processed - {$trxnDetails['email']}, {$trxnDetails['amt']}, {$value} ..<p>", TRUE);
                 } else {
                     CRM_Core_Error::debug_log_message("Skipped - {$trxnDetails['email']}, {$trxnDetails['amt']}, {$value} ..<p>", TRUE);
                 }
             }
         }
         if ($result['l_errorcode0'] == '11002') {
             $end = $result['l_timestamp99'];
             $end_time = strtotime("{$end}", time());
             $end_date = date('Y-m-d\\T00:00:00.00\\Z', $end_time);
             $args['enddate'] = $end_date;
         }
     } while ($result['l_errorcode0'] == '11002');
 }
Exemple #3
0
 function doTransferCheckout(&$params)
 {
     parent::doTransferCheckout($params, 'event');
 }
Exemple #4
0
 function doTransferCheckout(&$params)
 {
     parent::doTransferCheckout($params, 'contribute');
 }