First upload

This commit is contained in:
Nikolai Fesenko
2025-02-02 13:37:56 +01:00
commit 8d227c9191
3281 changed files with 362319 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
<?php
/**
* This file is part of O3-Shop Paypal module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\PayPalModule\Model\Response;
/**
* Abstract PayPal Response class
*/
abstract class Response
{
/**
* PayPal response data
*
* @var array
*/
protected $data = null;
/**
* Set response data
*
* @param array $responseData Response data from PayPal
*/
public function setData($responseData)
{
$this->data = $responseData;
}
/**
* Return response data
*
* @return array
*/
public function getData()
{
return $this->data;
}
/**
* Return value from data by given key
*
* @param string $key key of data value
*
* @return string
*/
protected function getValue($key)
{
$data = $this->getData();
return $data[$key];
}
}

View File

@@ -0,0 +1,77 @@
<?php
/**
* This file is part of O3-Shop Paypal module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\PayPalModule\Model\Response;
/**
* PayPal response class for do capture
*/
class ResponseDoCapture extends \OxidEsales\PayPalModule\Model\Response\Response
{
/**
* Return transaction id
*
* @return string
*/
public function getTransactionId()
{
return $this->getValue('TRANSACTIONID');
}
/**
* Return transaction id
*
* @return string
*/
public function getCorrelationId()
{
return $this->getValue('CORRELATIONID');
}
/**
* Return payment status
*
* @return string
*/
public function getPaymentStatus()
{
return $this->getValue('PAYMENTSTATUS');
}
/**
* Return payment status
*
* @return string
*/
public function getCapturedAmount()
{
return $this->getValue('AMT');
}
/**
* Return currency
*
* @return string
*/
public function getCurrency()
{
return $this->getValue('CURRENCYCODE');
}
}

View File

@@ -0,0 +1,77 @@
<?php
/**
* This file is part of O3-Shop Paypal module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\PayPalModule\Model\Response;
/**
* PayPal response class for do express checkout payment
*/
class ResponseDoExpressCheckoutPayment extends \OxidEsales\PayPalModule\Model\Response\Response
{
/**
* Return transaction id.
*
* @return string
*/
public function getTransactionId()
{
return $this->getValue('PAYMENTINFO_0_TRANSACTIONID');
}
/**
* Return transaction id.
*
* @return string
*/
public function getCorrelationId()
{
return $this->getValue('CORRELATIONID');
}
/**
* Return payment status.
*
* @return string
*/
public function getPaymentStatus()
{
return $this->getValue('PAYMENTINFO_0_PAYMENTSTATUS');
}
/**
* Return price amount.
*
* @return string
*/
public function getAmount()
{
return ( float ) $this->getValue('PAYMENTINFO_0_AMT');
}
/**
* Return currency code.
*
* @return string
*/
public function getCurrencyCode()
{
return $this->getValue('PAYMENTINFO_0_CURRENCYCODE');
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* This file is part of O3-Shop Paypal module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\PayPalModule\Model\Response;
/**
* PayPal response class for do reauthorize
*/
class ResponseDoReAuthorize extends \OxidEsales\PayPalModule\Model\Response\Response
{
/**
* Return authorization id.
*
* @return string
*/
public function getAuthorizationId()
{
return $this->getValue('AUTHORIZATIONID');
}
/**
* Return payment status.
*
* @return string
*/
public function getPaymentStatus()
{
return $this->getValue('PAYMENTSTATUS');
}
/**
* Return transaction id.
*
* @return string
*/
public function getCorrelationId()
{
return $this->getValue('CORRELATIONID');
}
}

View File

@@ -0,0 +1,77 @@
<?php
/**
* This file is part of O3-Shop Paypal module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\PayPalModule\Model\Response;
/**
* PayPal response class for do refund
*/
class ResponseDoRefund extends \OxidEsales\PayPalModule\Model\Response\Response
{
/**
* Return transaction id.
*
* @return string
*/
public function getTransactionId()
{
return $this->getValue('REFUNDTRANSACTIONID');
}
/**
* Return transaction id.
*
* @return string
*/
public function getCorrelationId()
{
return $this->getValue('CORRELATIONID');
}
/**
* Return payment status.
*
* @return string
*/
public function getPaymentStatus()
{
return $this->getValue('REFUNDSTATUS');
}
/**
* Return payment status.
*
* @return string
*/
public function getRefundAmount()
{
return $this->getValue('GROSSREFUNDAMT');
}
/**
* Return currency.
*
* @return string
*/
public function getCurrency()
{
return $this->getValue('CURRENCYCODE');
}
}

View File

@@ -0,0 +1,138 @@
<?php
/**
* This file is part of O3-Shop Paypal module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\PayPalModule\Model\Response;
/**
* PayPal response class for do verify with PayPal
*/
class ResponseDoVerifyWithPayPal extends \OxidEsales\PayPalModule\Model\Response\Response
{
/**
* String PayPal sends if all is ok.
*
* @var string
*/
const PAYPAL_ACK = 'VERIFIED';
/**
* String PayPal receiver email. It should be same as shop owner credential for PayPal.
*
* @var string
*/
const RECEIVER_EMAIL = 'receiver_email';
/**
* Sandbox mode parameter name.
*
* @var string
*/
const PAYPAL_SANDBOX = 'test_ipn';
/**
* String PayPal payment status parameter name.
*
* @var string
*/
const PAYPAL_PAYMENT_STATUS = 'payment_status';
/**
* String PayPal transaction id.
*
* @var string
*/
const PAYPAL_TRANSACTION_ID = 'txn_id';
/**
* String PayPal whole price including payment and shipment.
*
* @var string
*/
const MC_GROSS = 'mc_gross';
/**
* String PayPal payment currency.
*
* @var string
*/
const MC_CURRENCY = 'mc_currency';
/**
* Return if response verified as ACK from PayPal.
*
* @return boolean
*/
public function isPayPalAck()
{
$response = $this->getData();
return isset($response[self::PAYPAL_ACK]);
}
/**
* Return if response verified as ACK from PayPal.
*
* @return string
*/
public function getReceiverEmail()
{
return $this->getValue(self::RECEIVER_EMAIL);
}
/**
* Return payment status.
*
* @return string
*/
public function getPaymentStatus()
{
return $this->getValue(self::PAYPAL_PAYMENT_STATUS);
}
/**
* Return payment transaction id.
*
* @return string
*/
public function getTransactionId()
{
return $this->getValue(self::PAYPAL_TRANSACTION_ID);
}
/**
* Return payment currency.
*
* @return string
*/
public function getCurrency()
{
return $this->getValue(self::MC_CURRENCY);
}
/**
* Return payment amount.
*
* @return string
*/
public function getAmount()
{
return $this->getValue(self::MC_GROSS);
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* This file is part of O3-Shop Paypal module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\PayPalModule\Model\Response;
/**
* PayPal response class for do valid
*/
class ResponseDoVoid extends \OxidEsales\PayPalModule\Model\Response\Response
{
/**
* Return authorization id.
*
* @return string
*/
public function getAuthorizationId()
{
return $this->getValue('AUTHORIZATIONID');
}
/**
* Return transaction id.
*
* @return string
*/
public function getCorrelationId()
{
return $this->getValue('CORRELATIONID');
}
}

View File

@@ -0,0 +1,196 @@
<?php
/**
* This file is part of O3-Shop Paypal module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\PayPalModule\Model\Response;
/**
* PayPal response class for get express checkout details
*/
class ResponseGetExpressCheckoutDetails extends \OxidEsales\PayPalModule\Model\Response\Response
{
/**
* Return internal/system name of a shipping option.
*
* @return string
*/
public function getShippingOptionName()
{
return $this->getValue('SHIPPINGOPTIONNAME');
}
/**
* Return price amount.
*
* @return string
*/
public function getAmount()
{
return ( float ) $this->getValue('PAYMENTREQUEST_0_AMT');
}
/**
* Return payer id.
*
* @return string
*/
public function getPayerId()
{
return (string) $this->getValue('PAYERID');
}
/**
* Return email.
*
* @return string
*/
public function getEmail()
{
return $this->getValue('EMAIL');
}
/**
* Return first name.
*
* @return string
*/
public function getFirstName()
{
return $this->getValue('FIRSTNAME');
}
/**
* Return last name.
*
* @return string
*/
public function getLastName()
{
return $this->getValue('LASTNAME');
}
/**
* Return shipping street.
*
* @return string
*/
public function getShipToStreet()
{
return $this->getValue('PAYMENTREQUEST_0_SHIPTOSTREET');
}
/**
* Return shipping city.
*
* @return string
*/
public function getShipToCity()
{
return $this->getValue('PAYMENTREQUEST_0_SHIPTOCITY');
}
/**
* Return name.
*
* @return string
*/
public function getShipToName()
{
return $this->getValue('PAYMENTREQUEST_0_SHIPTONAME');
}
/**
* Return shipping country.
*
* @return string
*/
public function getShipToCountryCode()
{
return $this->getValue('PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE');
}
/**
* Return shipping state.
*
* @return string
*/
public function getShipToState()
{
return $this->getValue('PAYMENTREQUEST_0_SHIPTOSTATE');
}
/**
* Return shipping zip code.
*
* @return string
*/
public function getShipToZip()
{
return $this->getValue('PAYMENTREQUEST_0_SHIPTOZIP');
}
/**
* Return phone number.
* Note: PayPal returns a contact phone number only if your
* Merchant Account Profile settings require that the buyer enter one.
*
* @return string
*/
public function getShipToPhoneNumber()
{
$value = $this->getValue('PAYMENTREQUEST_0_SHIPTOPHONENUM');
$requiredAddressFields = oxNew(\OxidEsales\Eshop\Application\Model\RequiredAddressFields::class);
if (in_array('oxuser__oxfon', $requiredAddressFields->getRequiredFields())) {
$phone = $this->getValue('PHONENUM');
$value = !empty($phone) ? $phone : $value;
}
return $value;
}
/**
* Return second shipping street.
*
* @return string
*/
public function getShipToStreet2()
{
return $this->getValue('PAYMENTREQUEST_0_SHIPTOSTREET2');
}
/**
* Return salutation.
*
* @return string
*/
public function getSalutation()
{
return $this->getValue('SALUTATION');
}
/**
* Returns company.
*
* @return string
*/
public function getBusiness()
{
return $this->getValue('BUSINESS');
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* This file is part of O3-Shop Paypal module.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\PayPalModule\Model\Response;
/**
* PayPal response class for set express checkout
*/
class ResponseSetExpressCheckout extends \OxidEsales\PayPalModule\Model\Response\Response
{
/**
* Return token.
*
* @return string
*/
public function getToken()
{
return $this->getValue('TOKEN');
}
}