51 \
Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory,
56 $this->_curlFactory = $curlFactory;
57 $this->_ipnRequest =
$data;
71 return isset($this->_ipnRequest[$key]) ? $this->_ipnRequest[$key] :
null;
83 $httpAdapter = $this->_curlFactory->create();
84 $postbackQuery = http_build_query($this->
getRequestData()) .
'&cmd=_notify-validate';
85 $postbackUrl = $this->_config->getPayPalIpnUrl();
88 $httpAdapter->setConfig([
'verifypeer' => $this->_config->getValue(
'verifyPeer')]);
91 $postbackResult = $httpAdapter->read();
93 $this->
_addDebugData(
'http_error', [
'error' => $e->getMessage(),
'code' => $e->getCode()]);
101 if (empty($postbackResult) || in_array($responseCode, [
'500',
'502',
'503'])) {
102 if (empty($postbackResult)) {
103 $reason =
'Empty response.';
105 $reason =
'Response code: ' . $responseCode .
'.';
107 $this->_debugData[
'exception'] =
'PayPal IPN postback failure. ' . $reason;
111 $response = preg_split(
'/^\r?$/m', $postbackResult, 2);
116 throw new \Exception(
'PayPal IPN postback failure. See system.log for details.');
129 switch ($ipnPaymentStatus) {
146 case 'Canceled_Reversal':
168 if ($this->_config && $this->_config->getValue(
'debug')) {
169 $this->logger->debug(var_export($this->_debugData,
true));
180 $this->_debugData[$key] =
$value;
const PAYMENTSTATUS_COMPLETED
const PAYMENTSTATUS_PENDING
const PAYMENTSTATUS_PROCESSED
const PAYMENTSTATUS_FAILED
const PAYMENTSTATUS_DENIED
getRequestData($key=null)
_filterPaymentStatus($ipnPaymentStatus)
const PAYMENTSTATUS_UNREVERSED
__construct(\Magento\Paypal\Model\ConfigFactory $configFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory, array $data=[])
const PAYMENTSTATUS_VOIDED
const PAYMENTSTATUS_REFUNDED
const PAYMENTSTATUS_REVERSED
const PAYMENTSTATUS_EXPIRED
_addDebugData($key, $value)
static extractCode($response_str)