First upload
This commit is contained in:
@@ -0,0 +1,289 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OxidEsales\PayPalModule\Tests\Codeception\Acceptance;
|
||||
|
||||
use OxidEsales\Facts\Facts;
|
||||
use Codeception\Util\Fixtures;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Exception\ModuleSetupException;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\AcceptanceTester;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\Page\PayPalLogin;
|
||||
use OxidEsales\Codeception\Module\Translation\Translator;
|
||||
use OxidEsales\Codeception\Step\Basket;
|
||||
use OxidEsales\Codeception\Page\Checkout\ThankYou;
|
||||
use OxidEsales\Codeception\Page\Checkout\PaymentCheckout;
|
||||
use OxidEsales\Codeception\Page\Checkout\OrderCheckout;
|
||||
use OxidEsales\Codeception\Page\Checkout\Basket as BasketCheckout;
|
||||
|
||||
abstract class BaseCest
|
||||
{
|
||||
public function _before(AcceptanceTester $I): void
|
||||
{
|
||||
$this->activateModules();
|
||||
|
||||
$I->clearShopCache();
|
||||
$I->updateConfigInDatabase('blUseStock', false, 'bool');
|
||||
$I->updateConfigInDatabase('bl_perfLoadPrice', true, 'bool');
|
||||
$I->updateConfigInDatabase('iNewBasketItemMessage', false, 'bool');
|
||||
$I->updateConfigInDatabase('blOEPayPalFinalizeOrderOnPayPal', false, 'bool');
|
||||
$I->updateConfigInDatabase('sOEPayPalTransactionMode', 'Sale', 'str');
|
||||
|
||||
$I->haveInDatabase('oxobject2payment', Fixtures::get('paymentMethod'));
|
||||
$I->haveInDatabase('oxobject2payment', Fixtures::get('paymentCountry'));
|
||||
|
||||
$this->ensureShopUserData($I);
|
||||
}
|
||||
|
||||
public function _after(AcceptanceTester $I): void
|
||||
{
|
||||
$this->ensureShopUserData($I);
|
||||
$I->updateConfigInDatabase('blShowNetPrice', false, 'bool');
|
||||
|
||||
$I->deleteFromDatabase('oxorder', ['OXORDERNR >=' => '2']);
|
||||
$I->deleteFromDatabase('oxuserbaskets', ['OXTITLE >=' => 'savedbasket']);
|
||||
$I->resetCookie('sid');
|
||||
$I->resetCookie('sid_key');
|
||||
}
|
||||
|
||||
protected function getShopUrl(): string
|
||||
{
|
||||
$facts = new Facts();
|
||||
|
||||
return $facts->getShopUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates modules
|
||||
*/
|
||||
protected function activateModules(int $shopId = 1): void
|
||||
{
|
||||
$testConfig = new \OxidEsales\TestingLibrary\TestConfig();
|
||||
$modulesToActivate = $testConfig->getModulesToActivate();
|
||||
|
||||
if ($modulesToActivate) {
|
||||
$serviceCaller = new \OxidEsales\TestingLibrary\ServiceCaller();
|
||||
$serviceCaller->setParameter('modulestoactivate', $modulesToActivate);
|
||||
|
||||
try {
|
||||
$serviceCaller->callService('ModuleInstaller', $shopId);
|
||||
} catch (ModuleSetupException $e) {
|
||||
// this may happen if the module is already active,
|
||||
// we can ignore this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function ensureShopUserData(AcceptanceTester $I): void
|
||||
{
|
||||
$toBeUpdated = $_ENV['sBuyerLogin'];
|
||||
if (0 < $I->grabNumRecords('oxuser', ['oxusername' => Fixtures::get('userName')])) {
|
||||
$toBeUpdated = Fixtures::get('userName');
|
||||
$I->deleteFromDatabase('oxuser', ['oxusername' => $_ENV['sBuyerLogin']]);
|
||||
}
|
||||
if (0 < $I->grabNumRecords('oxnewssubscribed', ['oxemail' => $_ENV['sBuyerLogin']])) {
|
||||
$I->deleteFromDatabase('oxnewssubscribed', ['oxemail' => $_ENV['sBuyerLogin']]);
|
||||
}
|
||||
|
||||
$I->updateInDatabase(
|
||||
'oxuser',
|
||||
[
|
||||
'oxusername' => Fixtures::get('userName'),
|
||||
'oxcity' => Fixtures::get('details')['oxcity'],
|
||||
'oxstreet' => Fixtures::get('details')['oxstreet'],
|
||||
'oxstreetnr' => Fixtures::get('details')['oxstreetnr'],
|
||||
'oxzip' => Fixtures::get('details')['oxzip'],
|
||||
'oxfname' => Fixtures::get('details')['firstname'],
|
||||
'oxlname' => Fixtures::get('details')['lastname'],
|
||||
'oxcountryid' => 'a7c40f631fc920687.20179984' //DE
|
||||
],
|
||||
[
|
||||
'oxusername' => $toBeUpdated
|
||||
]
|
||||
);
|
||||
$I->updateInDatabase(
|
||||
'oxuser',
|
||||
[
|
||||
'oxpassword' => '$2y$10$b186f117054b700a89de9uXDzfahkizUucitfPov3C2cwF5eit2M2',
|
||||
'oxpasssalt' => 'b186f117054b700a89de929ce90c6aef'
|
||||
],
|
||||
[
|
||||
'oxusername' => Fixtures::get('userName')
|
||||
]
|
||||
);
|
||||
|
||||
$I->seeInDatabase('oxuser', ['oxusername' => Fixtures::get('userName')]);
|
||||
$I->dontSeeInDatabase('oxuser', ['oxusername' => $_ENV['sBuyerLogin']]);
|
||||
}
|
||||
|
||||
protected function setUserDataSameAsPayPal(AcceptanceTester $I, bool $removePassword = false): void
|
||||
{
|
||||
$I->updateInDatabase(
|
||||
'oxuser',
|
||||
[
|
||||
'oxusername' => $_ENV['sBuyerLogin'],
|
||||
'oxfname' => $_ENV['sBuyerFirstName'],
|
||||
'oxlname' => $_ENV['sBuyerLastName'],
|
||||
'oxstreet' => 'ESpachstr.',
|
||||
'oxstreetnr' => '1',
|
||||
'oxzip' => '79111',
|
||||
'oxcity' => 'Freiburg'
|
||||
],
|
||||
[
|
||||
'oxusername' => Fixtures::get('userName')
|
||||
]
|
||||
);
|
||||
|
||||
if ($removePassword) {
|
||||
$this->removePassword($I);
|
||||
}
|
||||
}
|
||||
|
||||
protected function removePassword(AcceptanceTester $I): void
|
||||
{
|
||||
$I->updateInDatabase(
|
||||
'oxuser',
|
||||
[
|
||||
'oxpassword' => '',
|
||||
'oxpasssalt' => ''
|
||||
],
|
||||
[
|
||||
'oxusername' => $_ENV['sBuyerLogin']
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected function setUserNameSameAsPayPal(AcceptanceTester $I): void
|
||||
{
|
||||
$I->updateInDatabase(
|
||||
'oxuser',
|
||||
[
|
||||
'oxusername' => $_ENV['sBuyerLogin'],
|
||||
],
|
||||
[
|
||||
'oxusername' => Fixtures::get('userName')
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected function proceedToPaymentStep(AcceptanceTester $I, string $userName = null): void
|
||||
{
|
||||
$userName = $userName ?: Fixtures::get('userName');
|
||||
|
||||
$home = $I->openShop()
|
||||
->loginUser($userName, Fixtures::get('userPassword'));
|
||||
$I->waitForText(Translator::translate('HOME'));
|
||||
|
||||
//add product to basket and start checkout
|
||||
$this->fillBasket($I);
|
||||
$this->fromBasketToPayment($I);
|
||||
}
|
||||
|
||||
protected function fromBasketToPayment(AcceptanceTester $I): void
|
||||
{
|
||||
$I->amOnPage('/en/cart');
|
||||
$basketPage = new BasketCheckout($I);
|
||||
$basketPage->goToNextStep()
|
||||
->goToNextStep();
|
||||
|
||||
$I->see(Translator::translate('PAYMENT_METHOD'));
|
||||
}
|
||||
|
||||
protected function proceedToBasketStep(AcceptanceTester $I, string $userName = null, bool $logMeIn = true): void
|
||||
{
|
||||
$userName = $userName ?: Fixtures::get('userName');
|
||||
|
||||
$home = $I->openShop();
|
||||
if ($logMeIn) {
|
||||
$home->loginUser($userName, Fixtures::get('userPassword'));
|
||||
}
|
||||
$I->waitForText(Translator::translate('HOME'));
|
||||
|
||||
//add product to basket and start checkout
|
||||
$this->fillBasket($I);
|
||||
$I->seeElement('//input[@name="paypalExpressCheckoutButtonECS"]');
|
||||
}
|
||||
|
||||
protected function fillBasket(AcceptanceTester $I): void
|
||||
{
|
||||
//add product to basket and start checkout
|
||||
$product = Fixtures::get('product');
|
||||
$basket = new Basket($I);
|
||||
$basket->addProductToBasketAndOpenBasket($product['id'], $product['amount'], 'basket');
|
||||
$I->see(Translator::translate('CONTINUE_TO_NEXT_STEP'));
|
||||
}
|
||||
|
||||
protected function finalizeOrder(AcceptanceTester $I): string
|
||||
{
|
||||
$paymentPage = new PaymentCheckout($I);
|
||||
$paymentPage->goToNextStep()
|
||||
->submitOrder();
|
||||
|
||||
$thankYouPage = new ThankYou($I);
|
||||
|
||||
return $thankYouPage->grabOrderNumber();
|
||||
}
|
||||
|
||||
protected function finalizeOrderInOrderStep(AcceptanceTester $I): string
|
||||
{
|
||||
$orderPage = new OrderCheckout($I);
|
||||
$orderPage->submitOrder();
|
||||
|
||||
$thankYouPage = new ThankYou($I);
|
||||
|
||||
return $thankYouPage->grabOrderNumber();
|
||||
}
|
||||
|
||||
protected function approvePayPalTransaction(AcceptanceTester $I, string $addParams = ''): string
|
||||
{
|
||||
//workaround to approve the transaction on PayPal side
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->openPayPalApprovalPage($I, $addParams);
|
||||
$token = $loginPage->getToken();
|
||||
$loginPage->approveStandardPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
protected function approveAnonymousPayPalTransaction(AcceptanceTester $I, string $addParams = ''): string
|
||||
{
|
||||
//workaround to approve the transaction on PayPal side
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->openPayPalApprovalPageAsAnonymousUser($I, $addParams);
|
||||
$token = $loginPage->getToken();
|
||||
$loginPage->approveStandardPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
protected function openOrderPayPal(AcceptanceTester $I, string $orderNumber): void
|
||||
{
|
||||
$adminPanel = $I->loginAdmin();
|
||||
$orders = $adminPanel->openOrders();
|
||||
$I->waitForDocumentReadyState();
|
||||
$orders->find($orders->orderNumberInput, $orderNumber);
|
||||
|
||||
$I->selectListFrame();
|
||||
$I->click("//a[contains(@href, '#oepaypalorder_paypal')]", 'edit');
|
||||
$I->selectEditFrame();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?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\Tests\Codeception\Acceptance;
|
||||
|
||||
use OxidEsales\Codeception\Step\ProductNavigation;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\AcceptanceTester;
|
||||
use Codeception\Util\Fixtures;
|
||||
use OxidEsales\Codeception\Module\Translation\Translator;
|
||||
|
||||
/**
|
||||
* @group oepaypal
|
||||
* @group oepaypal_standard
|
||||
* @group oepaypal_buttons
|
||||
*
|
||||
* Tests for checkout with regular payment method 'oxidpaypal'
|
||||
*/
|
||||
class ButtonPlacementCest extends BaseCest
|
||||
{
|
||||
public function _after(AcceptanceTester $I): void
|
||||
{
|
||||
$I->activatePaypalModule();
|
||||
|
||||
parent::_after($I);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group oepaypal_deactivated
|
||||
*/
|
||||
public function deactivatedModuleDoesNoHarm(AcceptanceTester $I): void
|
||||
{
|
||||
$I->wantToTest('that the shop is safe with installed but inactive PayPal Module');
|
||||
|
||||
$I->deactivatePaypalModule();
|
||||
|
||||
$I->openShop();
|
||||
$I->waitForText(Translator::translate('HOME'));
|
||||
|
||||
$productNavigation = new ProductNavigation($I);
|
||||
$productNavigation->openProductDetailsPage(Fixtures::get('product')['id']);
|
||||
$I->dontSeeElement("#paypalExpressCheckoutDetailsButton");
|
||||
|
||||
$home = $I->openShop()
|
||||
->loginUser(Fixtures::get('userName'), Fixtures::get('userPassword'));
|
||||
$I->waitForText(Translator::translate('HOME'));
|
||||
|
||||
$this->fillBasket($I);
|
||||
$I->dontSeeElement('//input[@name="paypalExpressCheckoutButtonECS"]');
|
||||
|
||||
$home->openMiniBasket();
|
||||
$I->dontSeeElement('#paypalExpressCheckoutMiniBasketImage');
|
||||
|
||||
$this->fromBasketToPayment($I);
|
||||
$I->dontSeeElement('#payment_oxidpaypal');
|
||||
}
|
||||
|
||||
public function seeButtonsInExpectedLocations(AcceptanceTester $I): void
|
||||
{
|
||||
$I->wantToTest('that all PayPal checkout buttons are shown');
|
||||
|
||||
$I->openShop();
|
||||
$I->waitForText(Translator::translate('HOME'));
|
||||
|
||||
$productNavigation = new ProductNavigation($I);
|
||||
$productNavigation->openProductDetailsPage(Fixtures::get('product')['id']);
|
||||
$I->seeElement("#paypalExpressCheckoutDetailsButton");
|
||||
|
||||
$home = $I->openShop()
|
||||
->loginUser(Fixtures::get('userName'), Fixtures::get('userPassword'));
|
||||
$I->waitForText(Translator::translate('HOME'));
|
||||
|
||||
//add product to basket and start checkout
|
||||
$this->fillBasket($I);
|
||||
$I->seeElement('//input[@name="paypalExpressCheckoutButtonECS"]');
|
||||
|
||||
$home->openMiniBasket();
|
||||
$I->seeElement('#paypalExpressCheckoutMiniBasketImage');
|
||||
|
||||
$this->fromBasketToPayment($I);
|
||||
$I->seeElement('#payment_oxidpaypal');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
<?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\Tests\Codeception\Acceptance;
|
||||
|
||||
use Codeception\Example;
|
||||
use Codeception\Util\Fixtures;
|
||||
use OxidEsales\Codeception\Page\Checkout\ThankYou;
|
||||
use OxidEsales\Codeception\Step\Basket;
|
||||
use OxidEsales\Codeception\Step\ProductNavigation;
|
||||
use OxidEsales\Codeception\Page\Checkout\PaymentCheckout;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\AcceptanceTester;
|
||||
use OxidEsales\Codeception\Module\Translation\Translator;
|
||||
|
||||
/**
|
||||
* @group oepaypal
|
||||
* @group oepaypal_standard
|
||||
* @group oepaypal_callback_controller
|
||||
*/
|
||||
class CallbackControllerCest extends BaseCest
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerCallBackTests
|
||||
*/
|
||||
public function testCallbackResponse(AcceptanceTester $I, Example $data): void
|
||||
{
|
||||
$I->wantToTest('callback response depending on session information');
|
||||
|
||||
$home = $I->openShop();
|
||||
$I->waitForText(Translator::translate('HOME'));
|
||||
|
||||
if ($data['doLogInUser']) {
|
||||
$home->loginUser(Fixtures::get('userName'), Fixtures::get('userPassword'));
|
||||
}
|
||||
|
||||
if ($data['doFillBasket']) {
|
||||
$this->fillBasket($I);
|
||||
}
|
||||
|
||||
$token = (string) $I->grabValueFrom('//input[@name="stoken"]');
|
||||
$sid = (string) $I->grabCookie('sid');
|
||||
|
||||
//Check callback
|
||||
$callbackUrl = $this->getCallbackUrl($I, $sid, $token, $data['payPalData']);
|
||||
$result = $this->getCallbackResponse($callbackUrl, $sid);
|
||||
$this->assertResults($I, $data['expected'], $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function providerCallBackTests()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
//Test case that callback is provided a session id but the basket related to that SID is empty and PP data empty.
|
||||
$data['CallbackEmptyBasketNoPayPalData'] = [
|
||||
'payPalData' => [],
|
||||
'expected' => [
|
||||
'METHOD' => 'CallbackResponse',
|
||||
'NO_SHIPPING_OPTION_DETAILS' => 1],
|
||||
'doLogInUser' => false,
|
||||
'doFillBasket' => true
|
||||
];
|
||||
|
||||
//Test case that callback data from PayPal is incomplete. Basket filled.
|
||||
$data['LoggedInUserEmptyBasketUnknownCountry'] = [
|
||||
'payPalData' => [
|
||||
'FIRSTNAME' => 'gerName',
|
||||
'LASTNAME' => 'gerlastname',
|
||||
'SHIPTONAME' => "Testuser",
|
||||
'SHIPTOSTREET' => 'Musterstr. 123',
|
||||
'SHIPTOCITY' => 'Musterstadt',
|
||||
'SHIPTOZIP' => '79098'
|
||||
],
|
||||
'expected' => [
|
||||
'METHOD' => 'CallbackResponse',
|
||||
'NO_SHIPPING_OPTION_DETAILS' => 1
|
||||
],
|
||||
'doLogInUser' => true,
|
||||
'doFillBasket' => true
|
||||
];
|
||||
|
||||
//Test case that user enters different address in PayPal for country that has PP attached in shop
|
||||
$data['CallbackOkForLoggedInUserGetDelSet'] = [
|
||||
'payPalData' => [
|
||||
'FIRSTNAME' => 'gerName',
|
||||
'LASTNAME' => 'gerlastname',
|
||||
'SHIPTONAME' => "Testuser",
|
||||
'SHIPTOSTREET' => 'Universitätsring 1',
|
||||
'SHIPTOCITY' => 'Wien',
|
||||
'SHIPTOZIP' => '1010',
|
||||
'SHIPTOCOUNTRY' => 'AT',
|
||||
'SHIPTOCOUNTRYCODE' => 'AT',
|
||||
'SHIPTOCOUNTRYNAME' => 'Austria'],
|
||||
'expected' => [
|
||||
'METHOD' => 'CallbackResponse',
|
||||
'L_SHIPPINGOPTIONNAME0' => 'Standard',
|
||||
'L_SHIPPINGOPTIONLABEL0' => 'Preis',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '6.90',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_TAXAMT0' => '0.00',
|
||||
'L_SHIPPINGOPTIONNAME1' => 'Beispiel+Set1%3A+UPS+48+Std.',
|
||||
'L_SHIPPINGOPTIONLABEL1' => 'Preis',
|
||||
'L_SHIPPINGOPTIONAMOUNT1' => '9.90',
|
||||
'L_SHIPPINGOPTIONISDEFAULT1' => 'false',
|
||||
'L_TAXAMT1' => '0.00',
|
||||
'L_SHIPPINGOPTIONNAME2' => 'Beispiel+Set1%3A+UPS+24+Std.+Express',
|
||||
'L_SHIPPINGOPTIONLABEL2' => 'Preis',
|
||||
'L_SHIPPINGOPTIONAMOUNT2' => '12.90',
|
||||
'L_SHIPPINGOPTIONISDEFAULT2' => 'false',
|
||||
'L_TAXAMT2' => '0.00',
|
||||
'OFFERINSURANCEOPTION' => 'false'],
|
||||
'doLogInUser' => true,
|
||||
'doFillBasket' => true
|
||||
];
|
||||
|
||||
//Test case that callback data from PayPal is complete. Basket empty.
|
||||
$data['LoggedInUserFilledBasketUnknownCountry'] = [
|
||||
'payPalData' => [
|
||||
'FIRSTNAME' => 'gerName',
|
||||
'LASTNAME' => 'gerlastname',
|
||||
'SHIPTONAME' => "Testuser",
|
||||
'SHIPTOSTREET' => 'Musterstr. 123',
|
||||
'SHIPTOCITY' => 'Musterstadt',
|
||||
'SHIPTOZIP' => '79098',
|
||||
'SHIPTOCOUNTRY' => 'DE',
|
||||
'SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'SHIPTOCOUNTRYNAME' => 'Germany'
|
||||
],
|
||||
'expected' => [
|
||||
'METHOD' => 'CallbackResponse',
|
||||
'L_SHIPPINGOPTIONNAME0' => 'Standard',
|
||||
'L_SHIPPINGOPTIONLABEL0' => 'Preis',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_TAXAMT0' => '0.00',
|
||||
'L_SHIPPINGOPTIONNAME1' => 'Beispiel+Set1%3A+UPS+48+Std.',
|
||||
'L_SHIPPINGOPTIONLABEL1' => 'Preis',
|
||||
'L_SHIPPINGOPTIONAMOUNT1' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT1' => 'false',
|
||||
'L_TAXAMT1' => '0.00',
|
||||
'OFFERINSURANCEOPTION' => 'false'
|
||||
],
|
||||
'doLogInUser' => true,
|
||||
'doFillBasket' => false
|
||||
];
|
||||
|
||||
//Test case that callback data from PayPal is complete. Basket filled.
|
||||
$data['CallbackOkForLoggedInUserGermany'] = [
|
||||
'payPalData' => [
|
||||
'FIRSTNAME' => 'gerName',
|
||||
'LASTNAME' => 'gerlastname',
|
||||
'SHIPTONAME' => "Testuser",
|
||||
'SHIPTOSTREET' => 'Musterstr. 123',
|
||||
'SHIPTOCITY' => 'Musterstadt',
|
||||
'SHIPTOZIP' => '79098',
|
||||
'SHIPTOCOUNTRY' => 'DE',
|
||||
'SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'SHIPTOCOUNTRYNAME' => 'Germany'
|
||||
],
|
||||
'expected' => [
|
||||
'METHOD' => 'CallbackResponse',
|
||||
'L_SHIPPINGOPTIONNAME0' => 'Standard',
|
||||
'L_SHIPPINGOPTIONLABEL0' => 'Preis',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_TAXAMT0' => '0.00',
|
||||
'L_SHIPPINGOPTIONNAME1' => 'Beispiel+Set1%3A+UPS+48+Std.',
|
||||
'L_SHIPPINGOPTIONLABEL1' => 'Preis',
|
||||
'L_SHIPPINGOPTIONAMOUNT1' => '9.90',
|
||||
'L_SHIPPINGOPTIONISDEFAULT1' => 'false',
|
||||
'L_TAXAMT1' => '0.00',
|
||||
'OFFERINSURANCEOPTION' => 'false'
|
||||
],
|
||||
'doLogInUser' => true,
|
||||
'doFillBasket' => true
|
||||
];
|
||||
|
||||
//Test case that user enters different address in PayPal for country that has no PP attached in shop
|
||||
$data['CallbackOkForLoggedInUserChange'] = [
|
||||
'payPalData' => [
|
||||
'FIRSTNAME' => 'gerName',
|
||||
'LASTNAME' => 'gerlastname',
|
||||
'SHIPTONAME' => "Testuser",
|
||||
'SHIPTOSTREET' => 'Musterstr. 123',
|
||||
'SHIPTOCITY' => 'Antwerp',
|
||||
'SHIPTOZIP' => '2000',
|
||||
'SHIPTOCOUNTRY' => 'BE',
|
||||
'SHIPTOCOUNTRYCODE' => 'BE',
|
||||
'SHIPTOCOUNTRYNAME' => 'Belgien'
|
||||
],
|
||||
'expected' => [
|
||||
'METHOD' => 'CallbackResponse',
|
||||
'NO_SHIPPING_OPTION_DETAILS' => 1
|
||||
],
|
||||
'doLogInUser' => true,
|
||||
'doFillBasket' => true
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test helper to assemble call back URl from PayPal to shop.
|
||||
*
|
||||
* @param string $sid Session id.
|
||||
* @param string $token Rtoken.
|
||||
* @param array $paypalData Optional paypal data.
|
||||
* @param int $language Optional language id.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getCallbackUrl(AcceptanceTester $I, $sid, $token, $paypalData = [], $language = 0)
|
||||
{
|
||||
$callbackUrl = $I->getShopUrl() . 'index.php?';
|
||||
|
||||
$data = [
|
||||
'lang' => $language,
|
||||
'sid' => $sid,
|
||||
'rtoken' => $token,
|
||||
'shp' => 1,
|
||||
'cl' => 'oepaypalexpresscheckoutdispatcher',
|
||||
'fnc' => 'processCallBack'
|
||||
];
|
||||
|
||||
$data = array_merge($data, $paypalData);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$callbackUrl .= '&' . $key . '=' . urlencode($value);
|
||||
}
|
||||
|
||||
return $callbackUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get response from callback as array.
|
||||
*
|
||||
* @param array $requestParameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getCallbackResponse($callbackUrl, $sid)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$curlHandler = oxNew(\OxidEsales\Eshop\Core\Curl::class);
|
||||
$curlHandler->setUrl($callbackUrl);
|
||||
$cookieString = 'sid=' . $sid . '; sid_key=oxid;';
|
||||
|
||||
$curlHandler->setOption('CURLOPT_COOKIE', $cookieString);
|
||||
$curlHandler->setOption('CURLOPT_COOKIESESSION', true);
|
||||
$curlHandler->setOption('CURLOPT_USERAGENT', 'test user agent');
|
||||
|
||||
$raw = $curlHandler->execute();
|
||||
|
||||
$tmp = explode('&', $raw);
|
||||
if (is_array($tmp) && !empty($tmp)) {
|
||||
foreach ($tmp as $keyValue) {
|
||||
$sub = explode('=', $keyValue);
|
||||
$result[$sub[0]] = $sub[1];
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test helper to check results.
|
||||
*
|
||||
* @param array $toBeAsserted
|
||||
* @param array $result
|
||||
*/
|
||||
private function assertResults(AcceptanceTester $I, $toBeAsserted, $result)
|
||||
{
|
||||
foreach ($toBeAsserted as $key => $expected) {
|
||||
$I->assertTrue(array_key_exists($key, $result), "Key '{$key}' missing in result array.");
|
||||
$I->assertEquals($expected, $result[$key], "Value '{$expected}' for key '{$key}' not as expected.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?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\Tests\Codeception\Acceptance;
|
||||
|
||||
use Codeception\Util\Fixtures;
|
||||
use OxidEsales\Codeception\Page\Checkout\ThankYou;
|
||||
use OxidEsales\Codeception\Step\Basket;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\AcceptanceTester;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\Page\PayPalLogin;
|
||||
use OxidEsales\Codeception\Module\Translation\Translator;
|
||||
|
||||
/**
|
||||
* @group oepaypal
|
||||
* @group oepaypal_standard
|
||||
* @group oepaypal_capture_and_refund
|
||||
*/
|
||||
class CaptureAndRefundCest extends BaseCest
|
||||
{
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
* @group paypal_captureandrefund
|
||||
*/
|
||||
public function orderCaptureAndRefundAmount(AcceptanceTester $I)
|
||||
{
|
||||
$I->updateConfigInDatabase('sOEPayPalTransactionMode', 'Authorization', 'str');
|
||||
$I->updateConfigInDatabase('blOEPayPalFinalizeOrderOnPayPal', true, 'bool');
|
||||
|
||||
$basket = new Basket($I);
|
||||
|
||||
$basketItem = Fixtures::get('product');
|
||||
|
||||
//add Product to basket
|
||||
$basket->addProductToBasket($basketItem['id'], $basketItem['amount']);
|
||||
$I->openShop()->seeMiniBasketContains([$basketItem], $basketItem['price'], (string) $basketItem['amount']);
|
||||
$I->waitForElementVisible("#paypalExpressCheckoutMiniBasketImage", 10);
|
||||
$I->click("#paypalExpressCheckoutMiniBasketImage");
|
||||
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->loginAndCheckout($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
$thankYouPage = new ThankYou($I);
|
||||
$orderNumber = $thankYouPage->grabOrderNumber();
|
||||
|
||||
$order = [
|
||||
'order_number' => (int) $orderNumber,
|
||||
'payment_method' => 'PayPal',
|
||||
'capture_amount' => '55,55',
|
||||
'capture_type' => 'NotComplete',
|
||||
'refund_amount' => '49,50',
|
||||
'refund_type' => 'Partial',
|
||||
];
|
||||
|
||||
$paypalOrder = $I->openAdminOrder((int) $orderNumber);
|
||||
|
||||
$paypalOrder->captureAmount($order['capture_amount'], $order['capture_type']);
|
||||
$I->dontSee($paypalOrder->captureErrorText, $paypalOrder->errorBox);
|
||||
$I->see(Translator::translate('OEPAYPAL_CAPTURE'), $paypalOrder->lastHistoryRowAction);
|
||||
$I->see('55.55', $paypalOrder->lastHistoryRowAmount);
|
||||
|
||||
$paypalOrder->refundAmount($order['refund_amount'], $order['refund_type']);
|
||||
$I->wait(1);
|
||||
$I->dontSee($paypalOrder->refundErrorText, $paypalOrder->errorBox);
|
||||
$I->see(Translator::translate('OEPAYPAL_REFUND'), $paypalOrder->lastHistoryRowAction);
|
||||
$I->see('49.50', $paypalOrder->lastHistoryRowAmount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace OxidEsales\PayPalModule\Tests\Codeception\Acceptance;
|
||||
|
||||
use Codeception\Example;
|
||||
use Codeception\Util\Fixtures;
|
||||
use OxidEsales\Codeception\Step\Basket;
|
||||
use OxidEsales\Codeception\Module\Translation\Translator;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\AcceptanceTester;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\Page\PayPalLogin;
|
||||
use \Codeception\Util\Locator;
|
||||
|
||||
/**
|
||||
* @group oepaypal
|
||||
* @group oepaypal_standard
|
||||
* @group oepaypal_checkout_redirect
|
||||
* @group oepaypal_checkout_finalizeonpaypal
|
||||
*/
|
||||
class CheckoutRedirectCest extends BaseCest
|
||||
{
|
||||
/**
|
||||
* @group checkoutFrontend
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
*
|
||||
* @example { "setting": false, "expectedEndText": "MESSAGE_SUBMIT_BOTTOM" }
|
||||
* @example { "setting": true, "expectedEndText": "THANK_YOU_FOR_ORDER" }
|
||||
*
|
||||
* @param AcceptanceTester $I
|
||||
*/
|
||||
public function checkRedirectOnCheckout(AcceptanceTester $I, Example $example)
|
||||
{
|
||||
$I->wantToTest('redirect to finalize order on successful PayPal checkout during express checkout');
|
||||
$I->updateConfigInDatabase('blOEPayPalFinalizeOrderOnPayPal', $example['setting'], 'bool');
|
||||
|
||||
$basket = new Basket($I);
|
||||
|
||||
$basketItem = Fixtures::get('product');
|
||||
|
||||
$basket->addProductToBasket($basketItem['id'], $basketItem['amount']);
|
||||
$I->openShop()->seeMiniBasketContains([$basketItem], $basketItem['price'], (string) $basketItem['amount']);
|
||||
|
||||
$I->openShop()->openMiniBasket();
|
||||
|
||||
$paypalButton = Locator::find(
|
||||
'input',
|
||||
['id' => 'paypalExpressCheckoutMiniBasketImage']
|
||||
);
|
||||
|
||||
$I->waitForElementVisible($paypalButton, 5);
|
||||
$I->click($paypalButton);
|
||||
|
||||
$paypalPage = new PaypalLogin($I);
|
||||
|
||||
$paypalUserEmail = $_ENV['sBuyerLogin'];
|
||||
$paypalUserPassword = $_ENV['sBuyerPassword'];
|
||||
$paypalPage->loginAndCheckout($paypalUserEmail, $paypalUserPassword);
|
||||
|
||||
$I->waitForText(Translator::translate($example['expectedEndText']), 10);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
<?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\Tests\Codeception\Acceptance;
|
||||
|
||||
use Codeception\Util\Fixtures;
|
||||
use OxidEsales\Codeception\Page\Checkout\ThankYou;
|
||||
use OxidEsales\Codeception\Step\Basket;
|
||||
use OxidEsales\Codeception\Step\ProductNavigation;
|
||||
use OxidEsales\Codeception\Page\Checkout\PaymentCheckout;
|
||||
use OxidEsales\Codeception\Page\Checkout\Basket as BasketCheckout;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\AcceptanceTester;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\Page\Checkout\OrderCheckout;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\Page\PayPalLogin;
|
||||
use OxidEsales\Codeception\Module\Translation\Translator;
|
||||
|
||||
/**
|
||||
* @group oepaypal
|
||||
* @group oepaypal_standard
|
||||
* @group oepaypal_express_checkout
|
||||
*
|
||||
* Tests for checkout with payment process started via paypal button
|
||||
*/
|
||||
class ExpressCheckoutCest extends BaseCest
|
||||
{
|
||||
/**
|
||||
* @group oepaypal_mandatory_test_with_graphql
|
||||
*/
|
||||
public function checkoutWithPaypalExpressWithNotYetExistingShopAccount(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('express checkout from minibasket button. Customer is not logged in and account does not exist in shop');
|
||||
|
||||
$I->updateConfigInDatabase('sOEPayPalTransactionMode', 'Authorization', 'str');
|
||||
$I->updateConfigInDatabase('blOEPayPalFinalizeOrderOnPayPal', true, 'bool');
|
||||
|
||||
$basket = new Basket($I);
|
||||
|
||||
$basketItem = Fixtures::get('product');
|
||||
|
||||
//add Product to basket
|
||||
$basket->addProductToBasket($basketItem['id'], $basketItem['amount']);
|
||||
$I->openShop()->seeMiniBasketContains([$basketItem], $basketItem['price'], (string) $basketItem['amount']);
|
||||
$I->waitForElementVisible("#paypalExpressCheckoutMiniBasketImage", 10);
|
||||
$I->click("#paypalExpressCheckoutMiniBasketImage");
|
||||
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->loginAndCheckout($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
$thankYouPage = new ThankYou($I);
|
||||
$orderNumber = $thankYouPage->grabOrderNumber();
|
||||
|
||||
$I->assertGreaterThan(1, $orderNumber);
|
||||
$I->seeInDataBase(
|
||||
'oxorder',
|
||||
[
|
||||
'OXORDERNR' => $orderNumber,
|
||||
'OXTOTALORDERSUM' => '119.6',
|
||||
'OXBILLFNAME' => $_ENV['sBuyerFirstName'],
|
||||
'OXBILLCITY' => 'Freiburg',
|
||||
'OXDELCITY' => ''
|
||||
]
|
||||
);
|
||||
|
||||
//Order was only authorized, so it should not yet be marked as paid
|
||||
$oxPaid = $I->grabFromDatabase('oxorder', 'oxpaid', ['OXORDERNR' => $orderNumber]);
|
||||
$I->assertStringStartsWith('0000-00-00', $oxPaid);
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTE: this test relies on the shipping cost callback NOT being accessible by PayPal
|
||||
*
|
||||
* @group oepaypal_will_fail_with_public_url
|
||||
*/
|
||||
public function testExpressCheckoutFromDetailsButtonWhenNotLoggedInWithExistingShopAccount(AcceptanceTester $I): void
|
||||
{
|
||||
$I->wantToTest('checkout from details page with empty cart. Customer is not logged in to existing account in shop.');
|
||||
|
||||
//Only use name will be same as PayPal. Addresses will be different.
|
||||
$this->setUserDataSameAsPayPal($I);
|
||||
|
||||
$I->openShop();
|
||||
$I->waitForText(Translator::translate('HOME'));
|
||||
|
||||
$productNavigation = new ProductNavigation($I);
|
||||
$productNavigation->openProductDetailsPage(Fixtures::get('product')['id']);
|
||||
$I->seeElement("#paypalExpressCheckoutDetailsButton");
|
||||
$I->click("#paypalExpressCheckoutDetailsButton");
|
||||
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->approveExpressPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
//we are below shipping cost free limit and did not enable callback
|
||||
//so we need to reapprove the order with PayPal
|
||||
$I->see(Translator::translate('OEPAYPAL_ORDER_TOTAL_HAS_CHANGED'));
|
||||
|
||||
$I->seeElement('//input[@name="paypalExpressCheckoutButtonECS"]');
|
||||
$I->click('//input[@name="paypalExpressCheckoutButtonECS"]');
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->approveExpressPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
$orderCheckout = new OrderCheckout($I);
|
||||
$orderCheckout->submitOrder();
|
||||
|
||||
$thankYouPage = new ThankYou($I);
|
||||
$orderNumber = $thankYouPage->grabOrderNumber();
|
||||
|
||||
$I->assertGreaterThan(1, $orderNumber);
|
||||
|
||||
$I->seeInDataBase(
|
||||
'oxorder',
|
||||
[
|
||||
'OXORDERNR' => $orderNumber,
|
||||
'OXTOTALORDERSUM' => Fixtures::get('totalordersum_ecswithshipping'),
|
||||
'OXBILLFNAME' => $_ENV['sBuyerFirstName'],
|
||||
'OXBILLCITY' => 'Freiburg',
|
||||
]
|
||||
);
|
||||
|
||||
//Order was captured, so it should be marked as paid
|
||||
$oxPaid = $I->grabFromDatabase('oxorder', 'oxpaid', ['OXORDERNR' => $orderNumber]);
|
||||
$I->assertStringStartsWith(date('Y-m-d'), $oxPaid);
|
||||
}
|
||||
|
||||
public function testExpressCheckoutFromDetailsButtonWhenNotLoggedInWithExistingSameDataShopAccount(AcceptanceTester $I): void
|
||||
{
|
||||
$I->wantToTest('checkout from details page with empty cart. Customer is not logged in to existing account in shop.');
|
||||
|
||||
//Only use name will be same as PayPal. Addresses will be different.
|
||||
$this->setUserNameSameAsPayPal($I);
|
||||
|
||||
$I->openShop();
|
||||
$I->waitForText(Translator::translate('HOME'));
|
||||
|
||||
$productNavigation = new ProductNavigation($I);
|
||||
$productNavigation->openProductDetailsPage(Fixtures::get('product')['id']);
|
||||
$I->seeElement("#paypalExpressCheckoutDetailsButton");
|
||||
$I->click("#paypalExpressCheckoutDetailsButton");
|
||||
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->approveExpressPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
//Only email address is found in shop but address does not match
|
||||
$I->see(Translator::translate('OEPAYPAL_ERROR_USER_ADDRESS'));
|
||||
|
||||
//So let's log in and try again
|
||||
$basketCheckout = new BasketCheckout($I);
|
||||
$basketCheckout->loginUser($_ENV['sBuyerLogin'], Fixtures::get('userPassword'));
|
||||
|
||||
$I->seeElement('//input[@name="paypalExpressCheckoutButtonECS"]');
|
||||
$I->click('//input[@name="paypalExpressCheckoutButtonECS"]');
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->approveExpressPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
$orderCheckout = new OrderCheckout($I);
|
||||
$orderCheckout->submitOrder();
|
||||
|
||||
$thankYouPage = new ThankYou($I);
|
||||
$orderNumber = $thankYouPage->grabOrderNumber();
|
||||
|
||||
$I->assertGreaterThan(1, $orderNumber);
|
||||
|
||||
$I->seeInDataBase(
|
||||
'oxorder',
|
||||
[
|
||||
'OXORDERNR' => $orderNumber,
|
||||
'OXTOTALORDERSUM' => Fixtures::get('totalordersum_ecswithshipping'),
|
||||
'OXBILLFNAME' => Fixtures::get('details')['firstname'],
|
||||
'OXBILLCITY' => Fixtures::get('details')['oxcity']
|
||||
]
|
||||
);
|
||||
|
||||
//Order was captured, so it should be marked as paid
|
||||
$oxPaid = $I->grabFromDatabase('oxorder', 'oxpaid', ['OXORDERNR' => $orderNumber]);
|
||||
$I->assertStringStartsWith(date('Y-m-d'), $oxPaid);
|
||||
}
|
||||
|
||||
public function testExpressCheckoutFromDetailsButton(AcceptanceTester $I): void
|
||||
{
|
||||
$I->wantToTest('checkout from details page with prefilled cart. Customer is logged in. PayPal and shop data are different.');
|
||||
|
||||
$this->proceedToBasketStep($I);
|
||||
|
||||
$productNavigation = new ProductNavigation($I);
|
||||
$productNavigation->openProductDetailsPage(Fixtures::get('product')['id']);
|
||||
$I->seeElement("#paypalExpressCheckoutDetailsButton");
|
||||
$I->click("#paypalExpressCheckoutDetailsButton");
|
||||
$I->see(substr(sprintf(Translator::translate('OEPAYPAL_SAME_ITEM_QUESTION'), 1), 0, 30));
|
||||
$I->seeElement("#actionAddToBasketAndGoToCheckout");
|
||||
$I->click("#actionAddToBasketAndGoToCheckout");
|
||||
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->approveExpressPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
$orderCheckout = new OrderCheckout($I);
|
||||
$orderCheckout->submitOrder();
|
||||
|
||||
$thankYouPage = new ThankYou($I);
|
||||
$orderNumber = $thankYouPage->grabOrderNumber();
|
||||
|
||||
$I->assertGreaterThan(1, $orderNumber);
|
||||
|
||||
$I->seeInDataBase(
|
||||
'oxorder',
|
||||
[
|
||||
'OXORDERNR' => $orderNumber,
|
||||
'OXTOTALORDERSUM' => Fixtures::get('totalordersum_ecsdetails'),
|
||||
'OXBILLFNAME' => Fixtures::get('details')['firstname'],
|
||||
'OXBILLCITY' => Fixtures::get('details')['oxcity'],
|
||||
'OXDELCITY' => ''
|
||||
]
|
||||
);
|
||||
|
||||
//Order was captured, so it should be marked as paid
|
||||
$oxPaid = $I->grabFromDatabase('oxorder', 'oxpaid', ['OXORDERNR' => $orderNumber]);
|
||||
$I->assertStringStartsWith(date('Y-m-d'), $oxPaid);
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTE: this test relies on the shipping cost callback NOT being accessible by PayPal
|
||||
*
|
||||
* @group oepaypal_will_fail_without_public_url
|
||||
* @group oepaypal_express_checkout_callback
|
||||
*/
|
||||
public function testExpressCheckoutWithCallback(AcceptanceTester $I): void
|
||||
{
|
||||
$I->wantToTest('checkout from details page with empty cart. Customer has no account in shop.');
|
||||
|
||||
$I->openShop();
|
||||
$I->waitForText(Translator::translate('HOME'));
|
||||
|
||||
$productNavigation = new ProductNavigation($I);
|
||||
$productNavigation->openProductDetailsPage(Fixtures::get('product')['id']);
|
||||
$I->seeElement("#paypalExpressCheckoutDetailsButton");
|
||||
$I->click("#paypalExpressCheckoutDetailsButton");
|
||||
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->approveExpressPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
$orderCheckout = new OrderCheckout($I);
|
||||
$orderCheckout->submitOrder();
|
||||
|
||||
$thankYouPage = new ThankYou($I);
|
||||
$orderNumber = $thankYouPage->grabOrderNumber();
|
||||
|
||||
$I->assertGreaterThan(1, $orderNumber);
|
||||
|
||||
$I->seeInDataBase(
|
||||
'oxorder',
|
||||
[
|
||||
'OXORDERNR' => $orderNumber,
|
||||
'OXTOTALORDERSUM' => Fixtures::get('totalordersum_ecswithshipping'),
|
||||
'OXBILLFNAME' => $_ENV['sBuyerFirstName'],
|
||||
'OXBILLCITY' => 'Freiburg',
|
||||
]
|
||||
);
|
||||
|
||||
//Order was captured, so it should be marked as paid
|
||||
$oxPaid = $I->grabFromDatabase('oxorder', 'oxpaid', ['OXORDERNR' => $orderNumber]);
|
||||
$I->assertStringStartsWith(date('Y-m-d'), $oxPaid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
<?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\Tests\Codeception\Acceptance\GraphQL;
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\Acceptance\BaseCest;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\AcceptanceTester;
|
||||
use Codeception\Util\Fixtures;
|
||||
|
||||
/**
|
||||
* @group oepaypal
|
||||
* @group oepaypal_graphql
|
||||
* @group oepaypal_graphql_basketpayment
|
||||
*/
|
||||
class BasketPaymentWithGraphqlCest extends BaseCest
|
||||
{
|
||||
use GraphqlCheckoutTrait;
|
||||
use GraphqlExpressCheckoutTrait;
|
||||
|
||||
public function _before(AcceptanceTester $I): void
|
||||
{
|
||||
if (!($I->checkGraphBaseActive() && $I->checkGraphStorefrontActive())) {
|
||||
$I->markTestSkipped('GraphQL modules are not active');
|
||||
}
|
||||
|
||||
parent::_before($I);
|
||||
|
||||
$I->updateInDatabase(
|
||||
'oxuser',
|
||||
[
|
||||
'oxpassword' => '$2y$10$b186f117054b700a89de9uXDzfahkizUucitfPov3C2cwF5eit2M2',
|
||||
'oxpasssalt' => 'b186f117054b700a89de929ce90c6aef'
|
||||
],
|
||||
[
|
||||
'oxusername' => $I->getDemoUserName()
|
||||
]
|
||||
);
|
||||
|
||||
$I->updateConfigInDatabase('blPerfNoBasketSaving', false, 'bool');
|
||||
$this->enablePayments();
|
||||
}
|
||||
|
||||
public function _after(AcceptanceTester $I): void
|
||||
{
|
||||
$this->enablePayments();
|
||||
|
||||
parent::_after($I);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
* @group paypal_graphql_express
|
||||
*/
|
||||
public function testPaypalBasketPayments(AcceptanceTester $I): void
|
||||
{
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare standard basket
|
||||
$basketId = $this->createBasket($I, 'pp_cart');
|
||||
$result = $this->getBasketPaymentIds($I, $basketId);
|
||||
|
||||
$I->assertSame(
|
||||
$this->getPaymentsArray(true),
|
||||
$result
|
||||
);
|
||||
|
||||
//prepare pp express basket
|
||||
$basketId = $this->prepareExpressBasket($I, 'pp_express_cart');
|
||||
$result = $this->getBasketPaymentIds($I, $basketId);
|
||||
|
||||
$I->assertSame(
|
||||
$this->getPaymentsArray(true),
|
||||
$result
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
* @group paypal_graphql_express
|
||||
*/
|
||||
public function testBasketPaymentsStandardPaymentTurnedOff(AcceptanceTester $I): void
|
||||
{
|
||||
$this->disableStandardPayment();
|
||||
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare standard basket
|
||||
$basketId = $this->createBasket($I, 'pp_cart_no_standart_payment');
|
||||
$result = $this->getBasketPaymentIds($I, $basketId);
|
||||
|
||||
$I->assertSame(
|
||||
$this->getPaymentsArray(),
|
||||
$result
|
||||
);
|
||||
|
||||
//prepare pp express basket
|
||||
$basketId = $this->prepareExpressBasket($I, 'pp_express_cart_no_standart_payment');
|
||||
$result = $this->getBasketPaymentIds($I, $basketId);
|
||||
|
||||
$I->assertSame(
|
||||
$this->getPaymentsArray(true),
|
||||
$result
|
||||
);
|
||||
|
||||
$this->enableStandardPayment();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
* @group paypal_graphql_express
|
||||
*/
|
||||
public function testBasketPaymentsExpressPaymentTurnedOff(AcceptanceTester $I): void
|
||||
{
|
||||
$this->disableExpressPayment();
|
||||
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword());
|
||||
|
||||
//prepare standard basket
|
||||
$basketId = $this->createBasket($I, 'pp_cart_no_express_payment');
|
||||
$result = $this->getBasketPaymentIds($I, $basketId);
|
||||
|
||||
$I->assertSame(
|
||||
$this->getPaymentsArray(true),
|
||||
$result
|
||||
);
|
||||
|
||||
//prepare pp express basket
|
||||
$result = $this->prepareExpressBasket($I, 'pp_express_cart_no_express_payments');
|
||||
|
||||
$I->assertSame("Payment method 'oxidpaypal' is unavailable!", $result);
|
||||
|
||||
$this->enableExpressPayment();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
* @group paypal_graphql_express
|
||||
*/
|
||||
public function testBasketPaymentsTurnedOff(AcceptanceTester $I): void
|
||||
{
|
||||
$this->disablePayments();
|
||||
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare standard basket
|
||||
$basketId = $this->createBasket($I, 'pp_cart_no_pp_payments');
|
||||
$result = $this->getBasketPaymentIds($I, $basketId);
|
||||
|
||||
$I->assertSame(
|
||||
$this->getPaymentsArray(),
|
||||
$result
|
||||
);
|
||||
|
||||
//prepare pp express basket
|
||||
$result = $this->prepareExpressBasket($I, 'pp_express_cart_no_express_payments');
|
||||
|
||||
$I->assertSame("Payment method 'oxidpaypal' is unavailable!", $result);
|
||||
|
||||
$this->enablePayments();
|
||||
}
|
||||
|
||||
private function prepareExpressBasket(AcceptanceTester $I, string $basketTitle): string
|
||||
{
|
||||
$basketId = $this->createBasket($I, $basketTitle);
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 4);
|
||||
|
||||
//Enable pp express process
|
||||
$result = $this->paypalExpressApprovalProcess(
|
||||
$I,
|
||||
$basketId
|
||||
);
|
||||
|
||||
if(isset($result['errors'])) {
|
||||
return $result['errors'][0]['message'];
|
||||
} else {
|
||||
return $basketId;
|
||||
}
|
||||
}
|
||||
|
||||
private function getPaymentsArray(bool $includePaypal = false): array
|
||||
{
|
||||
$availablePayments = [
|
||||
'oxidinvoice' => 'oxidinvoice',
|
||||
'oxidpayadvance' => 'oxidpayadvance',
|
||||
'oxiddebitnote' => 'oxiddebitnote',
|
||||
'oxidcashondel' => 'oxidcashondel',
|
||||
];
|
||||
|
||||
if ($includePaypal === true) {
|
||||
$availablePayments = ['oxidpaypal' => 'oxidpaypal'] + $availablePayments;
|
||||
}
|
||||
|
||||
return $availablePayments;
|
||||
}
|
||||
|
||||
private function enablePayments(): void
|
||||
{
|
||||
$this->enableExpressPayment();
|
||||
$this->enableStandardPayment();
|
||||
}
|
||||
|
||||
private function disablePayments(): void
|
||||
{
|
||||
$this->disableExpressPayment();
|
||||
$this->disableStandardPayment();
|
||||
}
|
||||
|
||||
private function enableStandardPayment(): void
|
||||
{
|
||||
Registry::getConfig()->saveShopConfVar('bool', 'blOEPayPalStandardCheckout', true, null, 'module:oepaypal');
|
||||
}
|
||||
|
||||
private function enableExpressPayment(): void
|
||||
{
|
||||
Registry::getConfig()->saveShopConfVar('bool', 'blOEPayPalExpressCheckout', true, null, 'module:oepaypal');
|
||||
}
|
||||
|
||||
private function disableStandardPayment(): void
|
||||
{
|
||||
Registry::getConfig()->saveShopConfVar('bool', 'blOEPayPalStandardCheckout', false, null, 'module:oepaypal');
|
||||
}
|
||||
|
||||
private function disableExpressPayment(): void
|
||||
{
|
||||
Registry::getConfig()->saveShopConfVar('bool', 'blOEPayPalExpressCheckout', false, null, 'module:oepaypal');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,586 @@
|
||||
<?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\Tests\Codeception\Acceptance\GraphQL;
|
||||
|
||||
use OxidEsales\GraphQL\Storefront\Basket\Exception\BasketAccessForbidden;
|
||||
use OxidEsales\GraphQL\Storefront\Country\Exception\CountryNotFound;
|
||||
use OxidEsales\PayPalModule\GraphQL\Exception\BasketCommunication;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\Acceptance\BaseCest;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\AcceptanceTester;
|
||||
use Codeception\Util\Fixtures;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\Page\PayPalLogin;
|
||||
use OxidEsales\PayPalModule\GraphQL\Exception\PaymentValidation;
|
||||
use OxidEsales\PayPalModule\GraphQL\Exception\BasketValidation;
|
||||
|
||||
/**
|
||||
* @group oepaypal
|
||||
* @group oepaypal_graphql
|
||||
* @group oepaypal_graphql_checkout
|
||||
*/
|
||||
class CheckoutWithGraphqlCest extends BaseCest
|
||||
{
|
||||
private const EXPIRED_TOKEN = 'EC-20P17490LV1421614';
|
||||
|
||||
use GraphqlCheckoutTrait;
|
||||
|
||||
public function _before(AcceptanceTester $I): void
|
||||
{
|
||||
if (!($I->checkGraphBaseActive() && $I->checkGraphStorefrontActive())) {
|
||||
$I->markTestSkipped('GraphQL modules are not active');
|
||||
}
|
||||
|
||||
parent::_before($I);
|
||||
|
||||
$I->updateConfigInDatabase('blPerfNoBasketSaving', false, 'bool');
|
||||
|
||||
$I->updateInDatabase(
|
||||
'oxuser',
|
||||
[
|
||||
'oxpassword' => '$2y$10$b186f117054b700a89de9uXDzfahkizUucitfPov3C2cwF5eit2M2',
|
||||
'oxpasssalt' => 'b186f117054b700a89de929ce90c6aef'
|
||||
],
|
||||
[
|
||||
'oxusername' => $I->getDemoUserName()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphql(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order successfully with PayPal via graphql');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 2);
|
||||
$this->setBasketDeliveryMethod($I, $basketId, Fixtures::get('shipping')['standard']);
|
||||
$this->setBasketPaymentMethod($I, $basketId, Fixtures::get('payment_id'));
|
||||
|
||||
//query basket payments
|
||||
$basketPayments = $this->getBasketPaymentIds($I, $basketId);
|
||||
$I->assertArrayHasKey(Fixtures::get('payment_id'), $basketPayments);
|
||||
|
||||
//Get token and approval url, make customer approve the payment
|
||||
$approvalDetails = $this->paypalApprovalProcess($I, $basketId);
|
||||
$I->amOnUrl($approvalDetails['data']['paypalApprovalProcess']['communicationUrl']);
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->approveGraphqlStandardPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
//place the order
|
||||
$result = $this->placeOrder($I, $basketId);
|
||||
$orderId = $result['data']['placeOrder']['id'];
|
||||
|
||||
$I->assertNotEmpty($orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlNewUserWithoutInvoiceAddress(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order with PayPal via graphql for newly registered user without invoice address');
|
||||
|
||||
//register customer via graphql, he's in 'oxidnotyetordered' group.
|
||||
$username = 'newPayPalUser@oxid-esales.com';
|
||||
$password = 'useruser';
|
||||
$this->registerCustomer($I, $username, $password);
|
||||
|
||||
//log in to graphql
|
||||
$I->loginToGraphQLApi($username, $password);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 2);
|
||||
|
||||
//this is as far as we get in this case because of missing invoice country
|
||||
$shippingId = Fixtures::get('shipping')['standard'];
|
||||
$result = $this->setBasketDeliveryMethod($I, $basketId, $shippingId);
|
||||
|
||||
$expectedException = CountryNotFound::byId('');
|
||||
$I->assertStringContainsString($expectedException->getMessage(), $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlUseDeliveryAddress(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order successfully with PayPal via graphql using a delivery address');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_two');
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 2);
|
||||
$this->setBasketDeliveryAddress($I, $basketId, $this->createDeliveryAddress($I));
|
||||
$this->setBasketDeliveryMethod($I, $basketId, Fixtures::get('shipping')['standard']);
|
||||
$this->setBasketPaymentMethod($I, $basketId, Fixtures::get('payment_id'));
|
||||
|
||||
//Get token and approval url, make customer approve the payment
|
||||
$approvalDetails = $this->paypalApprovalProcess($I, $basketId);
|
||||
$I->amOnUrl($approvalDetails['data']['paypalApprovalProcess']['communicationUrl']);
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->approveGraphqlStandardPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
//place the order
|
||||
$result = $this->placeOrder($I, $basketId);
|
||||
|
||||
$orderId = $result['data']['placeOrder']['id'];
|
||||
$I->assertNotEmpty($orderId);
|
||||
|
||||
$orderDetails = $this->getLatestOrderFromOrderHistory($I);
|
||||
$I->assertSame($orderId, $orderDetails['id']);
|
||||
$I->assertNotEmpty($orderDetails['invoiceAddress']);
|
||||
$I->assertNotEmpty($orderDetails['deliveryAddress']);
|
||||
$I->assertNotEquals($orderDetails['invoiceAddress']['lastName'], $orderDetails['deliveryAddress']['lastName']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlChangeBasketContentsAfterApproval(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order with PayPal via graphql fails if basket contents was changed after PP approval');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 2);
|
||||
$this->setBasketDeliveryMethod($I, $basketId, Fixtures::get('shipping')['standard']);
|
||||
$this->setBasketPaymentMethod($I, $basketId, Fixtures::get('payment_id'));
|
||||
|
||||
//Get token and approval url, make customer approve the payment
|
||||
$approvalDetails = $this->paypalApprovalProcess($I, $basketId);
|
||||
$I->amOnUrl($approvalDetails['data']['paypalApprovalProcess']['communicationUrl']);
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->approveGraphqlStandardPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
//change basket contents
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 1);
|
||||
|
||||
//place the order
|
||||
$result = $this->placeOrder($I, $basketId);
|
||||
|
||||
$expectedException = BasketValidation::basketChange($basketId);
|
||||
$I->assertStringContainsString($expectedException->getMessage(), $result['errors'][0]['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlChangeDeliveryAddressToNonPayPalCountryAfterApproval(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order with PayPal via graphql fails if delivery address was changed after PP approval to unsupported country');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 2);
|
||||
$this->setBasketDeliveryMethod($I, $basketId, Fixtures::get('shipping')['standard']);
|
||||
$this->setBasketPaymentMethod($I, $basketId, Fixtures::get('payment_id'));
|
||||
|
||||
//Get token and approval url, make customer approve the payment
|
||||
$approvalDetails = $this->paypalApprovalProcess($I, $basketId);
|
||||
$I->amOnUrl($approvalDetails['data']['paypalApprovalProcess']['communicationUrl']);
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->approveGraphqlStandardPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
//We change delivery address to country (Belgium) which is not assigned to oxidstandard delivery set.
|
||||
$this->setBasketDeliveryAddress($I, $basketId, $this->createDeliveryAddress($I, 'a7c40f632e04633c9.47194042'));
|
||||
|
||||
//place the order
|
||||
$result = $this->placeOrder($I, $basketId);
|
||||
$expectedException = BasketValidation::basketAddressChange($basketId);
|
||||
$I->assertStringContainsString($expectedException->getMessage(), $result['errors'][0]['message']);
|
||||
|
||||
//PayPal check runs before shop check. Here's what shop would find:
|
||||
//$I->assertStringContainsString("Delivery set 'oxidstandard' is unavailable!", $result['errors'][0]['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlChangeDeliveryAddressAfterApproval(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order with PayPal via graphql fails if delivery address was changed after PP approval');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 2);
|
||||
$this->setBasketDeliveryMethod($I, $basketId, Fixtures::get('shipping')['standard']);
|
||||
$this->setBasketPaymentMethod($I, $basketId, Fixtures::get('payment_id'));
|
||||
|
||||
//Get token and approval url, make customer approve the payment
|
||||
$approvalDetails = $this->paypalApprovalProcess($I, $basketId);
|
||||
$I->amOnUrl($approvalDetails['data']['paypalApprovalProcess']['communicationUrl']);
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->approveGraphqlStandardPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
//change delivery address to one where country is assigned to oxidpaypal payment method.
|
||||
$this->setBasketDeliveryAddress($I, $basketId, $this->createDeliveryAddress($I));
|
||||
|
||||
//place the order
|
||||
$result = $this->placeOrder($I, $basketId);
|
||||
|
||||
$expectedException = BasketValidation::basketAddressChange($basketId);
|
||||
$I->assertStringContainsString($expectedException->getMessage(), $result['errors'][0]['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlFailsForNotFinishedPayPalApproval(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order with PayPal via graphql for not finished PP approval');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 2);
|
||||
$this->setBasketDeliveryMethod($I, $basketId, Fixtures::get('shipping')['standard']);
|
||||
$this->setBasketPaymentMethod($I, $basketId, Fixtures::get('payment_id'));
|
||||
|
||||
//Get token and approval url, make customer log in to PayPal but not yet approve the payment
|
||||
$approvalDetails = $this->paypalApprovalProcess($I, $basketId);
|
||||
$I->amOnUrl($approvalDetails['data']['paypalApprovalProcess']['communicationUrl']);
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->loginToPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
//placing the order fails
|
||||
$result = $this->placeOrder($I, $basketId);
|
||||
|
||||
$expectedException = BasketCommunication::notConfirmed($basketId);
|
||||
$I->assertEquals($expectedException->getMessage(), $result['errors'][0]['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlNotConfirmed(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order fails with PayPal via graphql not confirmed');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 2);
|
||||
$this->setBasketDeliveryMethod($I, $basketId, Fixtures::get('shipping')['standard']);
|
||||
$this->setBasketPaymentMethod($I, $basketId, Fixtures::get('payment_id'));
|
||||
|
||||
//Get token and approval url but do not have customer approve the transaction
|
||||
$this->paypalApprovalProcess($I, $basketId);
|
||||
|
||||
//placing the order fails
|
||||
$result = $this->placeOrder($I, $basketId);
|
||||
|
||||
$expectedException = BasketCommunication::notConfirmed($basketId);
|
||||
$I->assertEquals($expectedException->getMessage(), $result['errors'][0]['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlNotStarted(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order fails with PayPal via graphql not started');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 2);
|
||||
$this->setBasketDeliveryMethod($I, $basketId, Fixtures::get('shipping')['standard']);
|
||||
$this->setBasketPaymentMethod($I, $basketId, Fixtures::get('payment_id'));
|
||||
|
||||
//placing the order fails
|
||||
$result = $this->placeOrder($I, $basketId);
|
||||
|
||||
$expectedException = BasketCommunication::notStarted($basketId);
|
||||
$I->assertEquals($expectedException->getMessage(), $result['errors'][0]['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlEmptyBasket(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order fails with PayPal via graphql with empty basket');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
|
||||
//Get token and approval url, make customer approve the payment
|
||||
$approvalDetails = $this->paypalApprovalProcess($I, $basketId);
|
||||
|
||||
$expectedException = PaymentValidation::paymentMethodIsNotPaypal();
|
||||
$I->assertEquals($expectedException->getMessage(), $approvalDetails['errors'][0]['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlEmptyBasketDeliverySet(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order fails with PayPal via graphql with empty basket');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
$this->setBasketDeliveryMethod($I, $basketId, Fixtures::get('shipping')['standard']);
|
||||
$this->setBasketPaymentMethod($I, $basketId, Fixtures::get('payment_id'));
|
||||
|
||||
//Get token and approval url, make customer approve the payment
|
||||
$approvalDetails = $this->paypalApprovalProcess($I, $basketId);
|
||||
$I->assertStringContainsString(
|
||||
//TODO: use Codeception Translator when it is possible to switch the language:
|
||||
// to German 'OEPAYPAL_RESPONSE_FROM_PAYPAL'
|
||||
'Fehlermeldung von PayPal',
|
||||
$approvalDetails['errors'][0]['debugMessage']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlOtherPaymentMethod(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order fails with PayPal via graphql and payment method changed after token');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 2);
|
||||
$this->setBasketDeliveryMethod($I, $basketId, Fixtures::get('shipping')['standard']);
|
||||
$this->setBasketPaymentMethod($I, $basketId, Fixtures::get('payment_id'));
|
||||
|
||||
//Get token and approval url, make customer approve the payment
|
||||
$approvalDetails = $this->paypalApprovalProcess($I, $basketId);
|
||||
$I->amOnUrl($approvalDetails['data']['paypalApprovalProcess']['communicationUrl']);
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->approveGraphqlStandardPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
//change payment method
|
||||
$this->setBasketPaymentMethod($I, $basketId, Fixtures::get('payment_id_other'));
|
||||
|
||||
//place the order
|
||||
//TODO: should the token be reset when the payment method is changed to non-paypal?
|
||||
$result = $this->placeOrder($I, $basketId);
|
||||
$orderId = $result['data']['placeOrder']['id'];
|
||||
|
||||
$I->assertNotEmpty($orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlExpiredToken(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order fails with PayPal via graphql and expired token');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 2);
|
||||
$this->setBasketDeliveryMethod($I, $basketId, Fixtures::get('shipping')['standard']);
|
||||
$this->setBasketPaymentMethod($I, $basketId, Fixtures::get('payment_id'));
|
||||
|
||||
//we just set the token manually
|
||||
$I->updateInDatabase('oxuserbaskets',
|
||||
['OEPAYPAL_PAYMENT_TOKEN' => self::EXPIRED_TOKEN],
|
||||
['OXID' => $basketId]
|
||||
);
|
||||
|
||||
//place the order
|
||||
$result = $this->placeOrder($I, $basketId);
|
||||
|
||||
$I->assertStringContainsString(
|
||||
//TODO: use Codeception Translator when it is possible to switch the language:
|
||||
// to German 'OEPAYPAL_RESPONSE_FROM_PAYPAL'
|
||||
'Fehlermeldung von PayPal',
|
||||
$result['errors'][0]['debugMessage']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlNoPaymentMethodSet(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order fails with PayPal via graphql and payment method not set');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 2);
|
||||
$this->setBasketDeliveryMethod($I, $basketId, Fixtures::get('shipping')['standard']);
|
||||
|
||||
//Get token and approval url, make customer approve the payment
|
||||
$approvalDetails = $this->paypalApprovalProcess($I, $basketId);
|
||||
|
||||
$expectedException = PaymentValidation::paymentMethodIsNotPaypal();
|
||||
$I->assertEquals($expectedException->getMessage(), $approvalDetails['errors'][0]['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlGetTokenStatusExpired(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('get token status for PayPal via graphql for expired token');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
$result = $this->paypalTokenStatus($I, self::EXPIRED_TOKEN);
|
||||
|
||||
$I->assertStringContainsString(
|
||||
//TODO: use Codeception Translator when it is possible to switch the language:
|
||||
// to German 'OEPAYPAL_RESPONSE_FROM_PAYPAL'
|
||||
'Fehlermeldung von PayPal',
|
||||
$result['errors'][0]['debugMessage']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlGetTokenStatusForValidToken(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('get token status for PayPal via graphql for valid token');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 2);
|
||||
$this->setBasketDeliveryMethod($I, $basketId, Fixtures::get('shipping')['standard']);
|
||||
$this->setBasketPaymentMethod($I, $basketId, Fixtures::get('payment_id'));
|
||||
|
||||
//Get token and approval url
|
||||
$approvalDetails = $this->paypalApprovalProcess($I, $basketId);
|
||||
|
||||
//token is valid but not yet approved
|
||||
$result = $this->paypalTokenStatus($I, $approvalDetails['data']['paypalApprovalProcess']['token']);
|
||||
$I->assertFalse($result['data']['paypalTokenStatus']['tokenApproved']);
|
||||
|
||||
//make customer login to paypal but cancel
|
||||
$I->amOnUrl($approvalDetails['data']['paypalApprovalProcess']['communicationUrl']);
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->loginToPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
//token is not approved
|
||||
$result = $this->paypalTokenStatus($I, $approvalDetails['data']['paypalApprovalProcess']['token']);
|
||||
$I->assertFalse($result['data']['paypalTokenStatus']['tokenApproved']);
|
||||
|
||||
//make customer approve the payment
|
||||
$I->amOnUrl($approvalDetails['data']['paypalApprovalProcess']['communicationUrl']);
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->approveGraphqlStandardPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
//token is approved
|
||||
$result = $this->paypalTokenStatus($I, $approvalDetails['data']['paypalApprovalProcess']['token']);
|
||||
$I->assertTrue($result['data']['paypalTokenStatus']['tokenApproved']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group paypal_external
|
||||
* @group paypal_buyerlogin
|
||||
* @group paypal_checkout
|
||||
* @group paypal_graphql
|
||||
*/
|
||||
public function checkoutWithGraphqlPlaceOrderWhichDoesNotBelongToYou(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('placing an order with PayPal via graphql which does not belong to you');
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//prepare basket
|
||||
$basketId = $this->createBasket($I, 'my_cart_one');
|
||||
$this->addProductToBasket($I, $basketId, Fixtures::get('product')['id'], 2);
|
||||
$this->setBasketDeliveryMethod($I, $basketId, Fixtures::get('shipping')['standard']);
|
||||
$this->setBasketPaymentMethod($I, $basketId, Fixtures::get('payment_id'));
|
||||
|
||||
//Get token and approval url, make customer approve the payment
|
||||
$approvalDetails = $this->paypalApprovalProcess($I, $basketId);
|
||||
$I->amOnUrl($approvalDetails['data']['paypalApprovalProcess']['communicationUrl']);
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->approveGraphqlStandardPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
$I->logoutFromGraphQLApi();
|
||||
$I->haveInDatabase('oxuser', $I->getExistingUserData());
|
||||
$I->haveInDatabase('oxobject2group', Fixtures::get('usergroups'));
|
||||
$I->loginToGraphQLApi($I->getExistingUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
//place the order
|
||||
$result = $this->placeOrder($I, $basketId);
|
||||
$I->assertStringContainsString(
|
||||
BasketAccessForbidden::byAuthenticatedUser()->getMessage(),
|
||||
$result['errors'][0]['message']
|
||||
);
|
||||
|
||||
$I->logoutFromGraphQLApi();
|
||||
$I->loginToGraphQLApi($I->getDemoUserName(), $I->getExistingUserPassword(), 0);
|
||||
|
||||
$result = $this->placeOrder($I, $basketId);
|
||||
$orderId = $result['data']['placeOrder']['id'];
|
||||
|
||||
$I->assertNotEmpty($orderId);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,406 @@
|
||||
<?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\Tests\Codeception\Acceptance\GraphQL;
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\AcceptanceTester;
|
||||
use Codeception\Util\HttpCode;
|
||||
use TheCodingMachine\GraphQLite\Types\ID;
|
||||
|
||||
trait GraphqlCheckoutTrait
|
||||
{
|
||||
protected function getGQLResponse(
|
||||
AcceptanceTester $I,
|
||||
string $query,
|
||||
array $variables = []
|
||||
): array {
|
||||
$I->sendGQLQuery($query, $variables);
|
||||
$I->seeResponseCodeIs(HttpCode::OK);
|
||||
$I->seeResponseIsJson();
|
||||
|
||||
return $I->grabJsonResponseAsArray();
|
||||
}
|
||||
|
||||
protected function createBasket(AcceptanceTester $I, string $basketTitle): string
|
||||
{
|
||||
$variables = [
|
||||
'title' => $basketTitle,
|
||||
];
|
||||
|
||||
$query = '
|
||||
mutation ($title: String!){
|
||||
basketCreate(basket: {title: $title}) {
|
||||
id
|
||||
}
|
||||
}
|
||||
';
|
||||
$result = $this->getGQLResponse($I, $query, $variables);
|
||||
|
||||
return $result['data']['basketCreate']['id'];
|
||||
}
|
||||
|
||||
protected function addProductToBasket(AcceptanceTester $I, string $basketId, string $productId, float $amount): array
|
||||
{
|
||||
$variables = [
|
||||
'basketId' => $basketId,
|
||||
'productId' => $productId,
|
||||
'amount' => $amount,
|
||||
];
|
||||
|
||||
$mutation = '
|
||||
mutation ($basketId: ID!, $productId: ID!, $amount: Float! ) {
|
||||
basketAddItem(
|
||||
basketId: $basketId,
|
||||
productId: $productId,
|
||||
amount: $amount
|
||||
) {
|
||||
id
|
||||
items {
|
||||
id
|
||||
product {
|
||||
id
|
||||
}
|
||||
amount
|
||||
}
|
||||
}
|
||||
}
|
||||
';
|
||||
|
||||
$result = $this->getGQLResponse($I, $mutation, $variables);
|
||||
|
||||
return $result['data']['basketAddItem']['items'];
|
||||
}
|
||||
|
||||
protected function setBasketDeliveryMethod(
|
||||
AcceptanceTester $I,
|
||||
string $basketId,
|
||||
string $deliverySetId
|
||||
): string {
|
||||
$variables = [
|
||||
'basketId' => new ID($basketId),
|
||||
'deliveryId' => new ID($deliverySetId),
|
||||
];
|
||||
|
||||
$mutation = '
|
||||
mutation ($basketId: ID!, $deliveryId: ID!) {
|
||||
basketSetDeliveryMethod(
|
||||
basketId: $basketId,
|
||||
deliveryMethodId: $deliveryId
|
||||
) {
|
||||
deliveryMethod {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
';
|
||||
$result = $this->getGQLResponse($I, $mutation, $variables);
|
||||
|
||||
if (isset($result['errors'])) {
|
||||
return (string) $result['errors'][0]['message'];
|
||||
}
|
||||
|
||||
return (string) $result['data']['basketSetDeliveryMethod']['deliveryMethod']['id'];
|
||||
}
|
||||
|
||||
protected function setBasketPaymentMethod(AcceptanceTester $I, string $basketId, string $paymentId): string
|
||||
{
|
||||
$variables = [
|
||||
'basketId' => new ID($basketId),
|
||||
'paymentId' => new ID($paymentId),
|
||||
];
|
||||
|
||||
$mutation = '
|
||||
mutation ($basketId: ID!, $paymentId: ID!) {
|
||||
basketSetPayment(
|
||||
basketId: $basketId,
|
||||
paymentId: $paymentId
|
||||
) {
|
||||
id
|
||||
}
|
||||
}
|
||||
';
|
||||
$result = $this->getGQLResponse($I, $mutation, $variables);
|
||||
|
||||
return $result['data']['basketSetPayment']['id'];
|
||||
}
|
||||
|
||||
protected function placeOrder(AcceptanceTester $I, string $basketId, ?bool $termsAndConditions = null): array
|
||||
{
|
||||
//now actually place the order
|
||||
$variables = [
|
||||
'basketId' => new ID($basketId),
|
||||
'confirmTermsAndConditions' => $termsAndConditions,
|
||||
];
|
||||
|
||||
$mutation = '
|
||||
mutation ($basketId: ID!, $confirmTermsAndConditions: Boolean) {
|
||||
placeOrder(
|
||||
basketId: $basketId
|
||||
confirmTermsAndConditions: $confirmTermsAndConditions
|
||||
) {
|
||||
id
|
||||
orderNumber
|
||||
}
|
||||
}
|
||||
';
|
||||
|
||||
return $this->getGQLResponse($I, $mutation, $variables);
|
||||
}
|
||||
|
||||
protected function paypalApprovalProcess(AcceptanceTester $I, string $basketId): array
|
||||
{
|
||||
$variables = [
|
||||
'basketId' => $basketId,
|
||||
'returnUrl' => EshopRegistry::getConfig()->getShopUrl()
|
||||
];
|
||||
|
||||
$mutation = '
|
||||
query ($basketId: ID!, $returnUrl: String!) {
|
||||
paypalApprovalProcess(
|
||||
basketId: $basketId,
|
||||
returnUrl: $returnUrl,
|
||||
cancelUrl: ""
|
||||
displayBasketInPayPal: true
|
||||
) {
|
||||
token
|
||||
communicationUrl
|
||||
}
|
||||
}
|
||||
';
|
||||
|
||||
$result = $this->getGQLResponse($I, $mutation, $variables);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function paypalTokenStatus(AcceptanceTester $I, string $token): array
|
||||
{
|
||||
$variables = [
|
||||
'token' => $token
|
||||
];
|
||||
|
||||
$mutation = '
|
||||
query ($token: String!) {
|
||||
paypalTokenStatus(
|
||||
paypalToken: $token
|
||||
) {
|
||||
token
|
||||
tokenApproved
|
||||
}
|
||||
}
|
||||
';
|
||||
|
||||
$result = $this->getGQLResponse($I, $mutation, $variables);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function createDeliveryAddress(AcceptanceTester $I, string $countryId = 'a7c40f631fc920687.20179984'): string
|
||||
{
|
||||
$variables = [
|
||||
'countryId' => new ID($countryId),
|
||||
];
|
||||
|
||||
$mutation = 'mutation ($countryId: ID!) {
|
||||
customerDeliveryAddressAdd(deliveryAddress: {
|
||||
salutation: "MRS",
|
||||
firstName: "Marlene",
|
||||
lastName: "Musterlich",
|
||||
additionalInfo: "protected delivery",
|
||||
street: "Bertoldstrasse",
|
||||
streetNumber: "48",
|
||||
zipCode: "79098",
|
||||
city: "Freiburg",
|
||||
countryId: $countryId}
|
||||
){
|
||||
id
|
||||
}
|
||||
}
|
||||
';
|
||||
|
||||
$result = $this->getGQLResponse($I, $mutation, $variables);
|
||||
|
||||
return $result['data']['customerDeliveryAddressAdd']['id'];
|
||||
}
|
||||
|
||||
protected function setBasketDeliveryAddress(
|
||||
AcceptanceTester $I,
|
||||
string $basketId,
|
||||
string $deliveryAddressId
|
||||
): array
|
||||
{
|
||||
$variables = [
|
||||
'basketId' => $basketId,
|
||||
'deliveryAddressId' => $deliveryAddressId,
|
||||
];
|
||||
|
||||
$mutation = '
|
||||
mutation ($basketId: ID!, $deliveryAddressId: ID!) {
|
||||
basketSetDeliveryAddress(basketId: $basketId, deliveryAddressId: $deliveryAddressId) {
|
||||
deliveryAddress {
|
||||
id
|
||||
}
|
||||
}
|
||||
}';
|
||||
|
||||
return $this->getGQLResponse($I, $mutation, $variables);
|
||||
}
|
||||
|
||||
protected function getLatestOrderFromOrderHistory(AcceptanceTester $I): array
|
||||
{
|
||||
$mutation = '
|
||||
query {
|
||||
customer {
|
||||
id
|
||||
orders(
|
||||
pagination: {limit: 1, offset: 0}
|
||||
){
|
||||
id
|
||||
orderNumber
|
||||
invoiceNumber
|
||||
invoiced
|
||||
cancelled
|
||||
ordered
|
||||
paid
|
||||
updated
|
||||
cost {
|
||||
total
|
||||
voucher
|
||||
discount
|
||||
}
|
||||
vouchers {
|
||||
id
|
||||
}
|
||||
invoiceAddress {
|
||||
firstName
|
||||
lastName
|
||||
street
|
||||
city
|
||||
}
|
||||
deliveryAddress {
|
||||
firstName
|
||||
lastName
|
||||
street
|
||||
city
|
||||
country {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
';
|
||||
|
||||
$result = $this->getGQLResponse($I, $mutation);
|
||||
|
||||
return $result['data']['customer']['orders'][0];
|
||||
}
|
||||
|
||||
protected function getBasketPaymentIds(AcceptanceTester $I, string $basketId): array
|
||||
{
|
||||
$variables = [
|
||||
'basketId' => new ID($basketId)
|
||||
];
|
||||
|
||||
$query = 'query ($basketId: ID!) {
|
||||
basketPayments(basketId:$basketId){
|
||||
id
|
||||
}
|
||||
}';
|
||||
|
||||
$raw = $this->getGQLResponse($I, $query, $variables);
|
||||
|
||||
$result = [];
|
||||
foreach ($raw['data']['basketPayments'] as $sub) {
|
||||
$result[$sub['id']] = $sub['id'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
protected function registerCustomer(AcceptanceTester $I, string $email, string $password = 'useruser'): array
|
||||
{
|
||||
$variables = [
|
||||
'email' => $email,
|
||||
'password' => $password,
|
||||
'name',
|
||||
];
|
||||
|
||||
$mutation = 'mutation ($email: String!, $password: String!) {
|
||||
customerRegister (
|
||||
customer: {
|
||||
email: $email,
|
||||
password: $password
|
||||
}
|
||||
) {
|
||||
id
|
||||
email
|
||||
}
|
||||
}';
|
||||
|
||||
$result = $this->getGQLResponse($I, $mutation, $variables);
|
||||
|
||||
return $result['data']['customerRegister'];
|
||||
}
|
||||
|
||||
protected function setInvoiceAddress(AcceptanceTester $I): array
|
||||
{
|
||||
$variables = [
|
||||
'firstName' => 'Test',
|
||||
'lastName' => 'Registered',
|
||||
'street' => 'Landstraße',
|
||||
'streetNumber' => '66',
|
||||
'zipCode' => '22547',
|
||||
'city' => 'Hamburg',
|
||||
'countryId' => new ID('a7c40f631fc920687.20179984'),
|
||||
];
|
||||
|
||||
$mutation = 'mutation (
|
||||
$firstName: String!,
|
||||
$lastName: String!,
|
||||
$street: String!,
|
||||
$streetNumber: String!,
|
||||
$zipCode: String!,
|
||||
$city: String!,
|
||||
$countryId: ID!
|
||||
) {
|
||||
customerInvoiceAddressSet (
|
||||
invoiceAddress: {
|
||||
firstName: $firstName,
|
||||
lastName: $lastName,
|
||||
street: $street,
|
||||
streetNumber: $streetNumber
|
||||
zipCode: $zipCode,
|
||||
city: $city,
|
||||
countryId: $countryId
|
||||
})
|
||||
{
|
||||
firstName
|
||||
lastName
|
||||
}
|
||||
}';
|
||||
|
||||
$result = $this->getGQLResponse($I, $mutation, $variables);
|
||||
|
||||
return $result['data']['customerInvoiceAddressSet'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?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\Tests\Codeception\Acceptance\GraphQL;
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\AcceptanceTester;
|
||||
use TheCodingMachine\GraphQLite\Types\ID;
|
||||
|
||||
trait GraphqlExpressCheckoutTrait
|
||||
{
|
||||
protected function paypalExpressApprovalProcess(
|
||||
AcceptanceTester $I,
|
||||
string $basketId
|
||||
): array
|
||||
{
|
||||
$variables = [
|
||||
'basketId' => $basketId,
|
||||
'returnUrl' => EshopRegistry::getConfig()->getShopUrl(),
|
||||
'cancelUrl' => EshopRegistry::getConfig()->getShopUrl()
|
||||
];
|
||||
|
||||
$mutation = '
|
||||
query ($basketId: ID!, $returnUrl: String!, $cancelUrl: String!) {
|
||||
paypalExpressApprovalProcess(
|
||||
basketId: $basketId,
|
||||
returnUrl: $returnUrl,
|
||||
cancelUrl: $cancelUrl,
|
||||
displayBasketInPayPal: true
|
||||
) {
|
||||
token
|
||||
communicationUrl
|
||||
}
|
||||
}
|
||||
';
|
||||
|
||||
return $this->getGQLResponse($I, $mutation, $variables);
|
||||
}
|
||||
|
||||
protected function removeItemFromBasket(
|
||||
AcceptanceTester $I,
|
||||
string $basketId,
|
||||
string $itemId,
|
||||
int $amount = 1
|
||||
): array
|
||||
{
|
||||
$variables = [
|
||||
'basketId' => $basketId,
|
||||
'itemId' => $itemId,
|
||||
'amount' => $amount
|
||||
];
|
||||
|
||||
$mutation = 'mutation ($basketId: ID!, $itemId: ID!, $amount: Int!) {
|
||||
basketRemoveItem(
|
||||
basketId: $basketId,
|
||||
itemId: $itemId,
|
||||
amount: $amount
|
||||
) {
|
||||
id
|
||||
}
|
||||
}';
|
||||
|
||||
return $this->getGQLResponse($I, $mutation, $variables);
|
||||
}
|
||||
|
||||
protected function addVoucherToBasket(
|
||||
AcceptanceTester $I,
|
||||
string $basketId,
|
||||
string $voucherNumber
|
||||
) : array
|
||||
{
|
||||
$variables = [
|
||||
'basketId' => $basketId,
|
||||
'voucherNumber' => $voucherNumber
|
||||
];
|
||||
|
||||
$mutation = 'mutation ($basketId: ID!, $voucherNumber: String!) {
|
||||
basketAddVoucher (
|
||||
basketId: $basketId,
|
||||
voucherNumber: $voucherNumber
|
||||
) {
|
||||
id
|
||||
}
|
||||
}';
|
||||
|
||||
return $this->getGQLResponse($I, $mutation, $variables);
|
||||
}
|
||||
|
||||
protected function removeVoucherFromBasket(
|
||||
AcceptanceTester $I,
|
||||
string $basketId,
|
||||
string $voucherId
|
||||
) : array
|
||||
{
|
||||
$variables = [
|
||||
'basketId' => $basketId,
|
||||
'voucherId' => $voucherId
|
||||
];
|
||||
|
||||
$mutation = 'mutation ($basketId: String!, $voucherId: String!) {
|
||||
basketRemoveVoucher (
|
||||
basketId: $basketId,
|
||||
voucherId: $voucherId
|
||||
) {
|
||||
id
|
||||
}
|
||||
}';
|
||||
|
||||
return $this->getGQLResponse($I, $mutation, $variables);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,554 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OxidEsales\PayPalModule\Tests\Codeception\Acceptance;
|
||||
|
||||
use OxidEsales\Codeception\Module\Translation\Translator;
|
||||
use Codeception\Util\Fixtures;
|
||||
use OxidEsales\Codeception\Step\Basket;
|
||||
use OxidEsales\Codeception\Step\ProductNavigation;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\AcceptanceTester;
|
||||
|
||||
/**
|
||||
* @group oepaypal
|
||||
* @group oepaypal_standard
|
||||
* @group oepaypal_installment_banners
|
||||
*/
|
||||
class InstallmentBannersCest extends BaseCest
|
||||
{
|
||||
public function _after(AcceptanceTester $I): void
|
||||
{
|
||||
$I->activateFlowTheme();
|
||||
$I->clearShopCache();
|
||||
|
||||
parent::_after($I);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group installment_banners_paypal
|
||||
* @group installment_banners_paypal_search
|
||||
*/
|
||||
public function searchPageBannerInBruttoMode(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('PayPal installment banner on search page in brutto mode');
|
||||
|
||||
$I->updateConfigInDatabase('oePayPalBannersSearchResultsPage', false, 'bool');
|
||||
$I->updateConfigInDatabase('iNewBasketItemMessage', false, 'bool');
|
||||
|
||||
$basketItem = Fixtures::get('product');
|
||||
|
||||
$homePage = $I->openShop();
|
||||
$basket = new Basket($I);
|
||||
$basket->addProductToBasket($basketItem['id'], (int)$basketItem['amount']);
|
||||
$homePage
|
||||
->seeMiniBasketContains([$basketItem], $basketItem['price'], (string) $basketItem['amount'])
|
||||
->searchFor("3503");
|
||||
|
||||
$I->dontSeeElementInDOM('#paypal-installment-banner-container');
|
||||
|
||||
//Check installment banner body in Flow theme
|
||||
$I->updateConfigInDatabase('oePayPalBannersSearchResultsPage', true, 'bool');
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(119.6);
|
||||
|
||||
// Check banner visibility when oePayPalBannersHideAll setting is set to true
|
||||
$I->updateConfigInDatabase('oePayPalBannersHideAll', true, 'bool');
|
||||
$I->reloadPage();
|
||||
$I->dontSeeElementInDOM('#paypal-installment-banner-container');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group installment_banners_paypal
|
||||
* @group installment_banners_paypal_search
|
||||
*/
|
||||
public function searchPageBannerInNettoMode(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('PayPal installment banner on search page in netto mode');
|
||||
|
||||
$I->updateConfigInDatabase('blShowNetPrice', true, 'bool');
|
||||
$I->updateConfigInDatabase('iNewBasketItemMessage', false, 'bool');
|
||||
|
||||
$product = Fixtures::get('product');
|
||||
$product['price'] = '100,52 €';
|
||||
|
||||
$homePage = $I->openShop();
|
||||
$basket = new Basket($I);
|
||||
$basket->addProductToBasket($product['id'], (int)$product['amount']);
|
||||
$homePage
|
||||
->seeMiniBasketContains([$product], $product['price'], (string) $product['amount'])
|
||||
->searchFor($product['title']);
|
||||
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(100.52);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group installment_banners_paypal
|
||||
* @group installment_banners_paypal_checkout
|
||||
*/
|
||||
public function checkoutPageBannerInBruttoMode(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('PayPal installment banner on checkout page in brutto mode');
|
||||
$I->haveInDatabase('oxuser', $I->getExistingUserData());
|
||||
|
||||
$I->updateConfigInDatabase('oePayPalBannersCheckoutPage', false, 'bool');
|
||||
|
||||
$I
|
||||
->openShop()
|
||||
->loginUser($I->getExistingUserName(), $I->getExistingUserPassword());
|
||||
|
||||
// 0. Prepare basket
|
||||
$basket = new Basket($I);
|
||||
$basketPage = $basket->addProductToBasketAndOpenBasket(Fixtures::get('product')['id'], 1, 'basket');
|
||||
|
||||
// 1. Basket overview
|
||||
$I->dontSeeElementInDOM('#paypal-installment-banner-container');
|
||||
|
||||
$I->updateConfigInDatabase('oePayPalBannersCheckoutPage', true, 'bool');
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(33.8);
|
||||
|
||||
// Check banner visibility when oePayPalBannersHideAll setting is set to true
|
||||
$I->updateConfigInDatabase('oePayPalBannersHideAll', true, 'bool');
|
||||
$I->reloadPage();
|
||||
$I->dontSeeElementInDOM('#paypal-installment-banner-container');
|
||||
|
||||
// 3. Payment
|
||||
$I->updateConfigInDatabase('oePayPalBannersHideAll', false, 'bool');
|
||||
$I->updateConfigInDatabase('oePayPalBannersCheckoutPage', false, 'bool');
|
||||
|
||||
$basketPage->goToNextStep()->goToNextStep();
|
||||
|
||||
$I->dontSeeElementInDOM('#paypal-installment-banner-container');
|
||||
|
||||
$I->updateConfigInDatabase('oePayPalBannersCheckoutPage', true, 'bool');
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(33.8);
|
||||
|
||||
// Check banner visibility when oePayPalBannersHideAll setting is set to true
|
||||
$I->updateConfigInDatabase('oePayPalBannersHideAll', true, 'bool');
|
||||
$I->reloadPage();
|
||||
$I->dontSeeElementInDOM('#paypal-installment-banner-container');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group installment_banners_paypal
|
||||
* @group installment_banners_paypal_checkout
|
||||
*/
|
||||
public function checkoutPageBannerInNettoMode(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('PayPal installment banner on checkout page in netto mode');
|
||||
$I->haveInDatabase('oxuser', $I->getExistingUserData());
|
||||
$I->updateConfigInDatabase('blShowNetPrice', true, 'bool');
|
||||
$I
|
||||
->openShop()
|
||||
->loginUser($I->getExistingUserName(), $I->getExistingUserPassword());
|
||||
|
||||
// 0. Prepare basket
|
||||
$basket = new Basket($I);
|
||||
$basketPage = $basket->addProductToBasketAndOpenBasket(Fixtures::get('product')['id'], 1, 'basket');
|
||||
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(33.8);
|
||||
|
||||
$basketPage->goToNextStep()->goToNextStep();
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(33.8);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group installment_banners_paypal
|
||||
* @group installment_banners_paypal_category
|
||||
*/
|
||||
public function categoryPageBannerInBruttoMode(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('PayPal installment banner on category page in brutto mode');
|
||||
|
||||
$I->updateConfigInDatabase('oePayPalBannersCategoryPage', false, 'bool');
|
||||
$I->updateConfigInDatabase('iNewBasketItemMessage', false, 'bool');
|
||||
|
||||
$homePage = $I->openShop();
|
||||
$basket = new Basket($I);
|
||||
$basketItem = Fixtures::get('product');
|
||||
$basket->addProductToBasket($basketItem['id'], (int)$basketItem['amount']);
|
||||
$homePage
|
||||
->seeMiniBasketContains([$basketItem], $basketItem['price'], (string) $basketItem['amount'])
|
||||
->openCategoryPage("Kiteboarding");
|
||||
|
||||
$I->dontSeeElementInDOM('#paypal-installment-banner-container');
|
||||
|
||||
//Check installment banner body in Flow and Wave theme
|
||||
$I->updateConfigInDatabase('oePayPalBannersCategoryPage', true, 'bool');
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(119.6);
|
||||
|
||||
// Check banner visibility when oePayPalBannersHideAll setting is set to true
|
||||
$I->updateConfigInDatabase('oePayPalBannersHideAll', true, 'bool');
|
||||
$I->reloadPage();
|
||||
$I->dontSeeElementInDOM('#paypal-installment-banner-container');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group installment_banners_paypal
|
||||
* @group installment_banners_paypal_category
|
||||
*/
|
||||
public function categoryPageBannerInNettoMode(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('PayPal installment banner on category page in netto mode');
|
||||
|
||||
$I->updateConfigInDatabase('blShowNetPrice', true, 'bool');
|
||||
$I->updateConfigInDatabase('iNewBasketItemMessage', false, 'bool');
|
||||
|
||||
$homePage = $I->openShop();
|
||||
$basket = new Basket($I);
|
||||
$basketItem = Fixtures::get('product');
|
||||
$basketItem['price'] = '100,52 €';
|
||||
$basket->addProductToBasket($basketItem['id'], (int)$basketItem['amount']);
|
||||
$homePage
|
||||
->seeMiniBasketContains([$basketItem], $basketItem['price'], (string) $basketItem['amount'])
|
||||
->openCategoryPage("Kiteboarding");
|
||||
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(100.52);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group installment_banners_paypal
|
||||
*/
|
||||
public function checkBannerPlaceholderAppearsOnStartPageOnlyByCorrectConfig(AcceptanceTester $I)
|
||||
{
|
||||
$I->updateConfigInDatabase('oePayPalBannersStartPage', false, 'bool');
|
||||
$I->openShop();
|
||||
$I->dontSeeElementInDOM("#paypal-installment-banner-container");
|
||||
|
||||
$I->updateConfigInDatabase('oePayPalBannersStartPage', true, 'bool');
|
||||
$I->clearShopCache();
|
||||
$I->openShop();
|
||||
$I->seeElementInDOM("#paypal-installment-banner-container");
|
||||
|
||||
$I->click(Translator::translate('HELP'));
|
||||
$I->dontSeeElementInDOM("#paypal-installment-banner-container");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group installment_banners_paypal
|
||||
*/
|
||||
public function checkCorrectDefaultsSentToPaypalInstallmentsOnStartPageWithEmptyBasket(AcceptanceTester $I)
|
||||
{
|
||||
$I->updateConfigInDatabase('oePayPalBannersStartPage', true, 'bool');
|
||||
$I->openShop();
|
||||
|
||||
$I->checkInstallmentBannerData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group installment_banners_paypal
|
||||
*/
|
||||
public function checkCorrectSumSentToPaypalInstallmentsOnStartPageWithFilledBasketBrutto(AcceptanceTester $I)
|
||||
{
|
||||
$I->updateConfigInDatabase('oePayPalBannersStartPage', true, 'bool');
|
||||
$I->updateConfigInDatabase('iNewBasketItemMessage', false, 'bool');
|
||||
$I->updateConfigInDatabase('blShowNetPrice', false, 'bool');
|
||||
$I->updateConfigInDatabase('iNewBasketItemMessage', false, 'bool');
|
||||
|
||||
$homePage = $I->openShop();
|
||||
$basket = new Basket($I);
|
||||
$basketItem = Fixtures::get('product');
|
||||
$basket->addProductToBasket($basketItem['id'], (int) $basketItem['amount']);
|
||||
$homePage->seeMiniBasketContains([$basketItem], $basketItem['price'], (string) $basketItem['amount']);
|
||||
|
||||
$I->checkInstallmentBannerData(119.6);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group installment_banners_paypal
|
||||
*/
|
||||
public function checkCorrectSumSentToPaypalInstallmentsOnStartPageWithFilledBasketNetto(AcceptanceTester $I)
|
||||
{
|
||||
$I->updateConfigInDatabase('oePayPalBannersStartPage', true, 'bool');
|
||||
$I->updateConfigInDatabase('iNewBasketItemMessage', false, 'bool');
|
||||
$I->updateConfigInDatabase('blShowNetPrice', true, 'bool');
|
||||
$I->updateConfigInDatabase('iNewBasketItemMessage', false, 'bool');
|
||||
|
||||
$homePage = $I->openShop();
|
||||
$basket = new Basket($I);
|
||||
$basketItem = Fixtures::get('product');
|
||||
$basketItem['price'] = '100,52 €';
|
||||
$basket->addProductToBasket($basketItem['id'], (int)$basketItem['amount']);
|
||||
$homePage->seeMiniBasketContains([$basketItem], $basketItem['price'], (string) $basketItem['amount']);
|
||||
|
||||
$I->checkInstallmentBannerData(100.52);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group installment_banners_paypal
|
||||
* @group installment_banners_paypal_details
|
||||
*/
|
||||
public function productDetailsPageBannerBrutto(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('PayPal installment banner on product details page brutto mode');
|
||||
|
||||
$parentProduct = Fixtures::get('parent');
|
||||
$variant = Fixtures::get('variant');
|
||||
$alternateVariant = Fixtures::get('alternate_variant');
|
||||
$basketItem = Fixtures::get('product');
|
||||
|
||||
$I->updateConfigInDatabase('oePayPalBannersProductDetailsPage', false, 'bool');
|
||||
|
||||
$parentProductNavigation = new ProductNavigation($I);
|
||||
$parentProductNavigation->openProductDetailsPage($parentProduct['id'])
|
||||
->seeOnBreadCrumb(Translator::translate('YOU_ARE_HERE'));
|
||||
$I->dontSee(Translator::translate('ERROR_MESSAGE_ARTICLE_ARTICLE_NOT_BUYABLE'));
|
||||
$I->dontSeeElementInDOM('#paypal-installment-banner-container');
|
||||
|
||||
$I->updateConfigInDatabase('oePayPalBannersProductDetailsPage', true, 'bool');
|
||||
$parentProductNavigation->openProductDetailsPage($parentProduct['id'])
|
||||
->seeOnBreadCrumb(Translator::translate('YOU_ARE_HERE'));
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme($parentProduct['minBruttoPrice'], Translator::translate('YOU_ARE_HERE'));
|
||||
|
||||
// Check banner amount when basket is not empty
|
||||
$basket = new Basket($I);
|
||||
$basket->addProductToBasket($basketItem['id'], 1);
|
||||
$parentProductNavigation->openProductDetailsPage($parentProduct['id'])
|
||||
->seeOnBreadCrumb(Translator::translate('YOU_ARE_HERE'));
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(
|
||||
$basketItem['bruttoprice_single'] + $parentProduct['minBruttoPrice'],
|
||||
Translator::translate('YOU_ARE_HERE')
|
||||
);
|
||||
|
||||
// Check banner amount when the given product is also in the basket
|
||||
$basket->addProductToBasket($variant['id'], 1);
|
||||
$I->waitForPageLoad();
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme($basketItem['bruttoprice_single'] + $variant['bruttoprice']); //check on front page
|
||||
|
||||
//check banner in case we open variant parent details page and have no variant selected
|
||||
$parentProductNavigation->openProductDetailsPage($parentProduct['id']);
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(
|
||||
$basketItem['bruttoprice_single'] + $variant['bruttoprice'],
|
||||
Translator::translate('YOU_ARE_HERE')
|
||||
); //check on details page
|
||||
|
||||
//check banner in case we open alternate variant details page, alternate variant price should be added to price
|
||||
$parentProductNavigation->openProductDetailsPage($alternateVariant['id']);
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(
|
||||
$basketItem['bruttoprice_single'] + $variant['bruttoprice'] + $alternateVariant['bruttoprice'],
|
||||
Translator::translate('YOU_ARE_HERE')
|
||||
); //check on details page */
|
||||
|
||||
//check banner in case we open variant details page
|
||||
$parentProductNavigation->openProductDetailsPage($variant['id']);
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(
|
||||
$basketItem['bruttoprice_single'] + $variant['bruttoprice'],
|
||||
Translator::translate('YOU_ARE_HERE')
|
||||
); //check on details page */
|
||||
|
||||
// Check banner visibility when oePayPalBannersHideAll setting is set to true
|
||||
$I->updateConfigInDatabase('oePayPalBannersHideAll', true, 'bool');
|
||||
$I->reloadPage();
|
||||
$I->dontSeeElementInDOM('#paypal-installment-banner-container');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group installment_banners_paypal
|
||||
* @group installment_banners_paypal_details
|
||||
*/
|
||||
public function productDetailsPageBannerNetto(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('PayPal installment banner on product details page in netto mode');
|
||||
$I->updateConfigInDatabase('blShowNetPrice', true, 'bool');
|
||||
|
||||
$parentProduct = Fixtures::get('parent');
|
||||
$variant = Fixtures::get('variant');
|
||||
$alternateVariant = Fixtures::get('alternate_variant');
|
||||
$basketItem = Fixtures::get('product');
|
||||
|
||||
$parentProductNavigation = new ProductNavigation($I);
|
||||
$parentProductNavigation->openProductDetailsPage($parentProduct['id'])
|
||||
->seeOnBreadCrumb(Translator::translate('YOU_ARE_HERE'));
|
||||
$I->waitForPageLoad();
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme($parentProduct['minNettoPrice']);
|
||||
|
||||
// Check banner amount when basket is not empty
|
||||
$basket = new Basket($I);
|
||||
$basket->addProductToBasket($basketItem['id'], 1);
|
||||
$parentProductNavigation->openProductDetailsPage($parentProduct['id'])
|
||||
->seeOnBreadCrumb(Translator::translate('YOU_ARE_HERE'));
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme($basketItem['nettoprice_single'] + $parentProduct['minNettoPrice']);
|
||||
|
||||
// Check banner amount when the given product is also in the basket
|
||||
$basket->addProductToBasket($variant['id'], 1);
|
||||
$I->waitForPageLoad();
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme($basketItem['nettoprice_single'] + $variant['nettoprice']); //check on front page
|
||||
|
||||
//check banner in case we open variant parent details page and have no variant selected
|
||||
$parentProductNavigation->openProductDetailsPage($parentProduct['id']);
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(
|
||||
$basketItem['nettoprice_single'] + $variant['nettoprice'],
|
||||
Translator::translate('YOU_ARE_HERE')
|
||||
); //check on details page
|
||||
|
||||
//check banner in case we open alternate variant details page, alternate variant price should be added to price
|
||||
$parentProductNavigation->openProductDetailsPage($alternateVariant['id']);
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(
|
||||
$basketItem['nettoprice_single'] + $variant['nettoprice'] + $alternateVariant['nettoprice'],
|
||||
Translator::translate('YOU_ARE_HERE')
|
||||
); //check on details page */
|
||||
|
||||
//check banner in case we open variant details page
|
||||
$parentProductNavigation->openProductDetailsPage($variant['id']);
|
||||
$I->seePayPalInstallmentBannerInFlowAndWaveTheme(
|
||||
$basketItem['nettoprice_single'] + $variant['nettoprice'],
|
||||
Translator::translate('YOU_ARE_HERE')
|
||||
); //check on details page */
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group installment_banners_paypal
|
||||
* @group installment_banners_paypal_variant
|
||||
*/
|
||||
public function productVariantBannerBrutto(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('PayPal installment banner for selected variant in brutto mode');
|
||||
|
||||
$product = Fixtures::get('parent');
|
||||
|
||||
$productNavigation = new ProductNavigation($I);
|
||||
$productNavigation
|
||||
->openProductDetailsPage($product['id'])
|
||||
->selectVariant(1, 'W 30/L 30')
|
||||
->selectVariant(2, 'Super Blue')
|
||||
->seeProductData([
|
||||
'id' => '0702-85-853-1-3',
|
||||
'title' => 'Kuyichi Jeans ANNA W 30/L 30 | Super Blue',
|
||||
'description' => 'Cool lady jeans by Kuyichi',
|
||||
'price' => '99,90 €'
|
||||
]);
|
||||
$I->checkInstallmentBannerData($product['maxBruttoPrice']);
|
||||
|
||||
$I->activateWaveTheme();
|
||||
$I->reloadPage();
|
||||
$I->waitForPageLoad();
|
||||
$productDetails = $productNavigation
|
||||
->openProductDetailsPage($product['id']);
|
||||
$this->selectWaveVariant($I, 1, 'W 30/L 30');
|
||||
$this->selectWaveVariant($I, 2, 'Super Blue');
|
||||
$productDetails->seeProductData([
|
||||
'id' => '0702-85-853-1-3',
|
||||
'title' => 'Kuyichi Jeans ANNA W 30/L 30 | Super Blue',
|
||||
'description' => 'Cool lady jeans by Kuyichi',
|
||||
'price' => '99,90 €'
|
||||
]);
|
||||
$I->checkInstallmentBannerData($product['maxBruttoPrice']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
*
|
||||
* @group installment_banners_paypal
|
||||
* @group installment_banners_paypal_variant
|
||||
*/
|
||||
public function productVariantBannerWrongSelector(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('PayPal installment banner with wrong selector');
|
||||
|
||||
$I->updateConfigInDatabase('oePayPalBannersProductDetailsPageSelector', '.non-existing-css-selector', 'str');
|
||||
|
||||
$product = Fixtures::get('parent');
|
||||
|
||||
$productNavigation = new ProductNavigation($I);
|
||||
$productNavigation
|
||||
->openProductDetailsPage($product['id'])
|
||||
->seeProductData([
|
||||
'id' => '3570',
|
||||
'title' => 'Kuyichi Jeans ANNA',
|
||||
'description' => 'Cool lady jeans by Kuyichi',
|
||||
'price' => 'from 92,90 € *'
|
||||
])
|
||||
->selectVariant(1, "W 30/L 30", "W 30/L 30")
|
||||
->selectVariant(2, "Blue", "W 30/L 30, Blue")
|
||||
->seeProductData([
|
||||
'id' => '0702-85-853-1-1',
|
||||
'title' => 'Kuyichi Jeans ANNA W 30/L 30 | Blue',
|
||||
'description' => 'Cool lady jeans by Kuyichi',
|
||||
'price' => '99,90 €'
|
||||
]);
|
||||
|
||||
$I->activateWaveTheme();
|
||||
$I->reloadPage();
|
||||
$I->waitForPageLoad();
|
||||
$productDetails = $productNavigation
|
||||
->openProductDetailsPage($product['id'])
|
||||
->seeProductData([
|
||||
'id' => '3570',
|
||||
'title' => 'Kuyichi Jeans ANNA',
|
||||
'description' => 'Cool lady jeans by Kuyichi',
|
||||
'price' => 'from 92,90 € *'
|
||||
]);
|
||||
$this->selectWaveVariant($I, 1, 'W 30/L 30');
|
||||
$this->selectWaveVariant($I, 2, 'Blue');
|
||||
$productDetails->seeProductData([
|
||||
'id' => '0702-85-853-1-1',
|
||||
'title' => 'Kuyichi Jeans ANNA W 30/L 30 | Blue',
|
||||
'description' => 'Cool lady jeans by Kuyichi',
|
||||
'price' => '99,90 €'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
* @param int $variant The position of the variant.
|
||||
* @param string $variantValue The value of the variant.
|
||||
*/
|
||||
private function selectWaveVariant(AcceptanceTester $I, int $variant, string $variantValue)
|
||||
{
|
||||
$variantSelection = '/descendant::button[@class="btn btn-outline-dark btn-sm dropdown-toggle"][%s]';
|
||||
$variantOpenSelection = '//ul[@class="dropdown-menu vardrop"]';
|
||||
|
||||
$I->click(sprintf($variantSelection, $variant));
|
||||
$I->click($variantValue);
|
||||
if ($I->see($variantValue)) {
|
||||
$I->click($variantValue);
|
||||
}
|
||||
$I->waitForElementNotVisible($variantOpenSelection);
|
||||
$I->waitForPageLoad();
|
||||
$I->see($variantValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
<?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\Tests\Codeception\Acceptance;
|
||||
|
||||
use Codeception\Util\Fixtures;
|
||||
use OxidEsales\Codeception\Page\Checkout\ThankYou;
|
||||
use OxidEsales\Codeception\Step\Basket;
|
||||
use OxidEsales\Codeception\Page\Checkout\PaymentCheckout;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\AcceptanceTester;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\Page\PayPalLogin;
|
||||
use OxidEsales\Codeception\Module\Translation\Translator;
|
||||
|
||||
/**
|
||||
* @group oepaypal
|
||||
* @group oepaypal_standard
|
||||
* @group oepaypal_standard_checkout
|
||||
*
|
||||
* Tests for checkout with regular payment method 'oxidpaypal'
|
||||
*/
|
||||
class StandardPaymentCest extends BaseCest
|
||||
{
|
||||
/**
|
||||
* @group oepaypal_mandatory_test_with_graphql
|
||||
*/
|
||||
public function checkoutWithPaypalStandard(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('checking out as logged in user with PayPal as payment method. Shop login and PayPal login mail are different.');
|
||||
|
||||
//order will be captured and finalized in shop
|
||||
$I->updateConfigInDatabase('sOEPayPalTransactionMode', 'Sale', 'str');
|
||||
|
||||
$this->proceedToPaymentStep($I, Fixtures::get('userName'));
|
||||
|
||||
$paymentPage = new PaymentCheckout($I);
|
||||
$paymentPage = $paymentPage->selectPayment('oxidpaypal');
|
||||
$I->click($paymentPage->nextStepButton);
|
||||
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$orderCheckout = $loginPage->checkoutWithStandardPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
$orderCheckout->submitOrder();
|
||||
|
||||
$thankYouPage = new ThankYou($I);
|
||||
$orderNumber = $thankYouPage->grabOrderNumber();
|
||||
$I->assertGreaterThan(1, $orderNumber);
|
||||
|
||||
$I->seeInDataBase(
|
||||
'oxorder',
|
||||
[
|
||||
'OXORDERNR' => $orderNumber,
|
||||
'OXTOTALORDERSUM' => '119.6',
|
||||
'OXBILLFNAME' => Fixtures::get('details')['firstname'],
|
||||
'OXBILLCITY' => Fixtures::get('details')['oxcity'],
|
||||
'OXDELCITY' => ''
|
||||
]
|
||||
);
|
||||
|
||||
//Order was captured, so it should be marked as paid
|
||||
$oxPaid = $I->grabFromDatabase('oxorder', 'oxpaid', ['OXORDERNR' => $orderNumber]);
|
||||
$I->assertStringStartsWith(date('Y-m-d'), $oxPaid);
|
||||
}
|
||||
|
||||
public function checkoutWithPaypalStandardSameUserData(AcceptanceTester $I): void
|
||||
{
|
||||
$I->wantToTest('checking out as logged in user with PayPal as payment method. Shop login and PayPal login mail are the same.');
|
||||
|
||||
//order will be only authorized
|
||||
$I->updateConfigInDatabase('sOEPayPalTransactionMode', 'Authorization', 'str');
|
||||
|
||||
$this->setUserDataSameAsPayPal($I);
|
||||
$this->proceedToPaymentStep($I, $_ENV['sBuyerLogin']);
|
||||
|
||||
$paymentPage = new PaymentCheckout($I);
|
||||
$paymentPage = $paymentPage->selectPayment('oxidpaypal');
|
||||
$I->click($paymentPage->nextStepButton);
|
||||
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$orderCheckout = $loginPage->checkoutWithStandardPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
$orderCheckout->submitOrder();
|
||||
|
||||
$thankYouPage = new ThankYou($I);
|
||||
$orderNumber = $thankYouPage->grabOrderNumber();
|
||||
$I->assertGreaterThan(1, $orderNumber);
|
||||
|
||||
$orderId = $I->grabFromDatabase('oxorder', 'oxid', ['OXORDERNR' => $orderNumber]);
|
||||
|
||||
$I->seeInDataBase(
|
||||
'oxorder',
|
||||
[
|
||||
'OXID' => $orderId,
|
||||
'OXTOTALORDERSUM' => '119.6',
|
||||
'OXBILLFNAME' => $_ENV['sBuyerFirstName'],
|
||||
'OXBILLCITY' => 'Freiburg',
|
||||
'OXDELCITY' => ''
|
||||
]
|
||||
);
|
||||
|
||||
//Order was only authorized, so it should not yet be marked as paid
|
||||
$oxPaid = $I->grabFromDatabase('oxorder', 'oxpaid', ['OXORDERNR' => $orderNumber]);
|
||||
$I->assertStringStartsWith(date('0000-00-00'), $oxPaid);
|
||||
}
|
||||
|
||||
public function changeBasketDuringCheckout(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantToTest('changing basket contents after payment was authorized');
|
||||
|
||||
$this->proceedToPaymentStep($I, Fixtures::get('userName'));
|
||||
|
||||
$paymentPage = new PaymentCheckout($I);
|
||||
$paymentPage = $paymentPage->selectPayment('oxidpaypal');
|
||||
$I->click($paymentPage->nextStepButton);
|
||||
|
||||
$loginPage = new PayPalLogin($I);
|
||||
$loginPage->checkoutWithStandardPayPal($_ENV['sBuyerLogin'], $_ENV['sBuyerPassword']);
|
||||
|
||||
$I->amOnUrl($this->getShopUrl() . '/en/cart');
|
||||
|
||||
$product = Fixtures::get('product');
|
||||
$basket = new Basket($I);
|
||||
$basket->addProductToBasketAndOpenBasket($product['id'], $product['amount'], 'basket');
|
||||
|
||||
//finalize order in previous tab
|
||||
$I->amOnUrl($this->getShopUrl() . '?cl=order');
|
||||
|
||||
$orderNumber = $this->finalizeOrderInOrderStep($I);
|
||||
$I->assertGreaterThan(1, $orderNumber);
|
||||
|
||||
$shopOrderId = $I->grabFromDatabase(
|
||||
'oxorder',
|
||||
'oxid',
|
||||
[
|
||||
'OXORDERNR' => $orderNumber,
|
||||
'OXTOTALORDERSUM' => '239.2'
|
||||
]
|
||||
);
|
||||
$I->seeInDatabase(
|
||||
'oepaypal_order',
|
||||
[
|
||||
'OEPAYPAL_ORDERID' => $shopOrderId,
|
||||
'OEPAYPAL_PAYMENTSTATUS' => 'completed',
|
||||
'OEPAYPAL_CAPTUREDAMOUNT' => '239.20'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
// This is acceptance bootstrap
|
||||
$helper = new \OxidEsales\Codeception\Module\FixturesHelper();
|
||||
$helper->loadRuntimeFixtures(dirname(__FILE__).'/../_data/fixtures.php');
|
||||
$helper->loadRuntimeFixtures(dirname(__FILE__).'/../_data/configData.php');
|
||||
|
||||
$dotenv = new \Symfony\Component\Dotenv\Dotenv();
|
||||
$dotenv->load(__DIR__.'/../../../.env');
|
||||
@@ -0,0 +1,87 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Facts\Facts;
|
||||
use OxidEsales\Eshop\Core\ConfigFile;
|
||||
use OxidEsales\TestingLibrary\Services\Library\DatabaseDefaultsFileGenerator;
|
||||
|
||||
$facts = new Facts();
|
||||
$selenium_server_port = getenv('SELENIUM_SERVER_PORT');
|
||||
$selenium_server_port = ($selenium_server_port) ? $selenium_server_port : '4444';
|
||||
$selenium_server_host = getenv('SELENIUM_SERVER_HOST');
|
||||
$selenium_server_host = ($selenium_server_host) ? : 'localhost';
|
||||
$php = (getenv('PHPBIN')) ? getenv('PHPBIN') : 'php';
|
||||
|
||||
return [
|
||||
'SHOP_URL' => $facts->getShopUrl(),
|
||||
'SHOP_SOURCE_PATH' => $facts->getSourcePath(),
|
||||
'VENDOR_PATH' => $facts->getVendorPath(),
|
||||
'DB_NAME' => $facts->getDatabaseName(),
|
||||
'DB_USERNAME' => $facts->getDatabaseUserName(),
|
||||
'DB_PASSWORD' => $facts->getDatabasePassword(),
|
||||
'DB_HOST' => $facts->getDatabaseHost(),
|
||||
'DB_PORT' => $facts->getDatabasePort(),
|
||||
'DUMP_PATH' => getTestDataDumpFilePath(),
|
||||
'MYSQL_CONFIG_PATH' => getMysqlConfigPath(),
|
||||
'MODULE_DUMP_PATH' => getModuleTestDataDumpFilePath(),
|
||||
'SELENIUM_SERVER_PORT' => $selenium_server_port,
|
||||
'SELENIUM_SERVER_HOST' => $selenium_server_host,
|
||||
'BROWSER_NAME' => getenv('BROWSER_NAME') ?: 'chrome',
|
||||
'PHP_BIN' => $php,
|
||||
];
|
||||
|
||||
function getModuleTestDataDumpFilePath()
|
||||
{
|
||||
return __DIR__ . '/../_data/dump.sql';
|
||||
}
|
||||
|
||||
function getTestDataDumpFilePath()
|
||||
{
|
||||
return getShopTestPath() . '/Codeception/_data/dump.sql';
|
||||
}
|
||||
|
||||
function getShopSuitePath($facts)
|
||||
{
|
||||
$testSuitePath = getenv('TEST_SUITE');
|
||||
if (!$testSuitePath) {
|
||||
$testSuitePath = $facts->getShopRootPath() . '/tests';
|
||||
}
|
||||
|
||||
return $testSuitePath;
|
||||
}
|
||||
|
||||
function getShopTestPath()
|
||||
{
|
||||
$facts = new Facts();
|
||||
|
||||
$shopTestPath = getShopSuitePath($facts);
|
||||
|
||||
return $shopTestPath;
|
||||
}
|
||||
|
||||
function getMysqlConfigPath()
|
||||
{
|
||||
$facts = new Facts();
|
||||
$configFile = new ConfigFile($facts->getSourcePath() . '/config.inc.php');
|
||||
|
||||
$generator = new DatabaseDefaultsFileGenerator($configFile);
|
||||
|
||||
return $generator->generate();
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OxidEsales\PayPalModule\Tests\Codeception\Module;
|
||||
|
||||
use Codeception\Lib\Interfaces\DependsOnModule;
|
||||
use Codeception\Module;
|
||||
use Codeception\Module\REST;
|
||||
use InvalidArgumentException;
|
||||
use Lcobucci\JWT\Encoding\JoseEncoder;
|
||||
use Lcobucci\JWT\Token\Parser;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setup\Bridge\ModuleActivationBridgeInterface;
|
||||
use PHPUnit\Framework\AssertionFailedError;
|
||||
|
||||
class GraphQLHelper extends Module implements DependsOnModule
|
||||
{
|
||||
/** @var REST */
|
||||
private $rest;
|
||||
|
||||
/**
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function _depends()
|
||||
{
|
||||
return [REST::class => 'Codeception\Module\REST is required'];
|
||||
}
|
||||
|
||||
public function _inject(REST $rest): void
|
||||
{
|
||||
$this->rest = $rest;
|
||||
}
|
||||
|
||||
public function getRest(): REST
|
||||
{
|
||||
return $this->rest;
|
||||
}
|
||||
|
||||
public function sendGQLQuery(
|
||||
string $query,
|
||||
?array $variables = null,
|
||||
int $language = 0,
|
||||
int $shopId = 1,
|
||||
array $additionalParameters = []
|
||||
): void {
|
||||
$uri = '/graphql?lang=' . $language . '&shp=' . $shopId;
|
||||
|
||||
foreach ($additionalParameters as $key => $value) {
|
||||
$uri .= '&' . $key . '=' . $value;
|
||||
}
|
||||
|
||||
$this->rest->haveHTTPHeader('Content-Type', 'application/json');
|
||||
$this->rest->sendPOST($uri, [
|
||||
'query' => $query,
|
||||
'variables' => $variables,
|
||||
]);
|
||||
}
|
||||
|
||||
public function loginToGraphQLApi(string $username, string $password, int $shopId = 1): void
|
||||
{
|
||||
$this->logoutFromGraphQLApi();
|
||||
|
||||
$query = 'query ($username: String!, $password: String!) { token (username: $username, password: $password) }';
|
||||
$variables = [
|
||||
'username' => $username,
|
||||
'password' => $password,
|
||||
];
|
||||
|
||||
$this->sendGQLQuery($query, $variables, 0, $shopId);
|
||||
$this->rest->seeResponseIsJson();
|
||||
$this->seeResponseContainsValidJWTToken();
|
||||
|
||||
$this->rest->amBearerAuthenticated($this->grabTokenFromResponse());
|
||||
}
|
||||
|
||||
public function anonymousLoginToGraphQLApi(int $shopId = 1): void
|
||||
{
|
||||
$this->logoutFromGraphQLApi();
|
||||
|
||||
$query = 'query{token}';
|
||||
|
||||
$this->sendGQLQuery($query, [], 0, $shopId);
|
||||
$this->rest->seeResponseIsJson();
|
||||
$this->seeResponseContainsValidJWTToken();
|
||||
|
||||
$this->rest->amBearerAuthenticated($this->grabTokenFromResponse());
|
||||
}
|
||||
public function logoutFromGraphQLApi(): void
|
||||
{
|
||||
$this->rest->deleteHeader('Authorization');
|
||||
}
|
||||
|
||||
public function grabJsonResponseAsArray(): array
|
||||
{
|
||||
return json_decode($this->rest->grabResponse(), true);
|
||||
}
|
||||
|
||||
public function grabTokenFromResponse(): string
|
||||
{
|
||||
return $this->grabJsonResponseAsArray()['data']['token'];
|
||||
}
|
||||
|
||||
public function seeResponseContainsValidJWTToken(): void
|
||||
{
|
||||
$token = $this->grabTokenFromResponse();
|
||||
|
||||
try {
|
||||
(new Parser(new JoseEncoder()))->parse($token);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
throw new AssertionFailedError(sprintf('Not a valid JWT token: %s', $token));
|
||||
}
|
||||
}
|
||||
|
||||
public function extractSidFromResponseCookies(): string
|
||||
{
|
||||
$cookieHeaders = $this->rest->grabHttpHeader('Set-Cookie', false);
|
||||
|
||||
$sid = '';
|
||||
|
||||
foreach ($cookieHeaders as $value) {
|
||||
preg_match('/^(sid=)([a-z0-9]*);/', $value, $matches);
|
||||
|
||||
if (isset($matches[2])) {
|
||||
$sid = $matches[2];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $sid;
|
||||
}
|
||||
|
||||
public function checkGraphBaseActive(): bool
|
||||
{
|
||||
$moduleActivation = ContainerFactory::getInstance()
|
||||
->getContainer()
|
||||
->get(ModuleActivationBridgeInterface::class);
|
||||
|
||||
return (bool) $moduleActivation->isActive('oe_graphql_base', 1);
|
||||
}
|
||||
|
||||
public function checkGraphStorefrontActive(): bool
|
||||
{
|
||||
$moduleActivation = ContainerFactory::getInstance()
|
||||
->getContainer()
|
||||
->get(ModuleActivationBridgeInterface::class);
|
||||
|
||||
return (bool) $moduleActivation->isActive('oe_graphql_storefront', 1);
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
*/
|
||||
|
||||
return [
|
||||
'paymentMethod' => [
|
||||
'OXID' => '660f0f63epaypald63a78af0a4b44',
|
||||
'OXPAYMENTID' => 'oxidpaypal',
|
||||
'OXOBJECTID' => 'oxidstandard',
|
||||
'OXTYPE' => 'oxdelset'
|
||||
],
|
||||
'paymentCountry' => [
|
||||
'OXID' => '2c0879ca0d9b6d56273064bd6627a8f6',
|
||||
'OXPAYMENTID' => 'oxidpaypal',
|
||||
'OXOBJECTID' => 'a7c40f631fc920687.20179984',
|
||||
'OXTYPE' => 'oxcountry'
|
||||
],
|
||||
'adminData' => [
|
||||
'OXID' => 'codeceptionadmin',
|
||||
'OXRIGHTS' => 'malladmin',
|
||||
'OXUSERNAME' => 'admin@myo3-shop.com',
|
||||
'OXPASSWORD' => '6cb4a34e1b66d3445108cd91b67f98b9',
|
||||
'OXPASSSALT' => '6631386565336161636139613634663766383538633566623662613036636539',
|
||||
'OXCUSTNR' => 1,
|
||||
'OXCOMPANY' => 'Your Company Name',
|
||||
'OXFNAME' => 'John',
|
||||
'OXLNAME' => 'Doe',
|
||||
'OXSTREET' => 'Maple Street',
|
||||
'OXSTREETNR' => '2425',
|
||||
'OXCITY' => 'Any City',
|
||||
'OXCOUNTRYID' => 'a7c40f631fc920687.20179984',
|
||||
'OXZIP' => '9041',
|
||||
'OXFON' => '217-8918712',
|
||||
'OXFAX' => '217-8918713',
|
||||
'OXSAL' => 'MR',
|
||||
'OXBONI' => 1000,
|
||||
'OXCREATE' => '2003-01-01 00:00:00',
|
||||
'OXREGISTER' => '2003-01-01 00:00:00',
|
||||
'OXTIMESTAMP' => '2021-01-26 15:57:46',
|
||||
]
|
||||
];
|
||||
@@ -0,0 +1,48 @@
|
||||
SET @@session.sql_mode = '';
|
||||
|
||||
#Users demodata
|
||||
REPLACE INTO `oxuser` SET
|
||||
OXID = 'paypaluser',
|
||||
OXACTIVE = 1,
|
||||
OXRIGHTS = 'user',
|
||||
OXSHOPID = 1,
|
||||
OXUSERNAME = 'paypaluser@oxid-esales.dev',
|
||||
OXPASSWORD = '$2y$10$tJd1YkFr2y4kUmojqa6NPuHrcMzZmxc9mh4OWQcLONfHg4WXzbtlu',
|
||||
OXPASSSALT = '',
|
||||
OXFNAME = 'TestUserName',
|
||||
OXLNAME = 'TestUserSurname',
|
||||
OXSTREET = 'Musterstr.šÄßüл',
|
||||
OXSTREETNR = '12',
|
||||
OXCITY = 'City',
|
||||
OXZIP = '12345',
|
||||
OXCOUNTRYID = 'a7c40f631fc920687.20179984',
|
||||
OXBIRTHDATE = '1985-02-05 14:42:42',
|
||||
OXCREATE = '2021-02-05 14:42:42',
|
||||
OXREGISTER = '2021-02-05 14:42:42';
|
||||
|
||||
REPLACE INTO `oxuser` SET
|
||||
OXID = 'defaultuser',
|
||||
OXACTIVE = 1,
|
||||
OXRIGHTS = 'user',
|
||||
OXSHOPID = 1,
|
||||
OXUSERNAME = 'defaultuser@oxid-esales.dev',
|
||||
OXPASSWORD = '$2y$10$tJd1YkFr2y4kUmojqa6NPuHrcMzZmxc9mh4OWQcLONfHg4WXzbtlu',
|
||||
OXPASSSALT = '',
|
||||
OXFNAME = 'UserName',
|
||||
OXLNAME = 'UserSurname',
|
||||
OXSTREET = 'MeineStrasse',
|
||||
OXSTREETNR = '12',
|
||||
OXCITY = 'Hamburg',
|
||||
OXZIP = '22001',
|
||||
OXCOUNTRYID = 'a7c40f631fc920687.20179984',
|
||||
OXBIRTHDATE = '1985-02-05 14:42:42',
|
||||
OXCREATE = '2021-02-05 14:42:42',
|
||||
OXREGISTER = '2021-02-05 14:42:42';
|
||||
|
||||
REPLACE INTO `oxuser` (`OXID`, `OXACTIVE`, `OXRIGHTS`, `OXSHOPID`, `OXUSERNAME`, `OXPASSWORD`, `OXPASSSALT`, `OXCUSTNR`, `OXUSTID`, `OXCOMPANY`, `OXFNAME`, `OXLNAME`, `OXSTREET`, `OXSTREETNR`, `OXADDINFO`, `OXCITY`, `OXCOUNTRYID`, `OXSTATEID`, `OXZIP`, `OXFON`, `OXFAX`, `OXSAL`, `OXBONI`, `OXCREATE`, `OXREGISTER`, `OXPRIVFON`, `OXMOBFON`, `OXBIRTHDATE`, `OXURL`, `OXUPDATEKEY`, `OXUPDATEEXP`, `OXPOINTS`) VALUES
|
||||
('oxdefaultadmin', 1, 'malladmin', 1, 'admin', 'e3a8a383819630e42d9ef90be2347ea70364b5efbb11dfc59adbf98487e196fffe4ef4b76174a7be3f2338581e507baa61c852b7d52f4378e21bd2de8c1efa5e', '61646D696E61646D696E61646D696E', 1, '', 'Your Company Name', 'John', 'Doe', 'Maple Street', '2425', '', 'Any City', 'a7c40f631fc920687.20179984', '', '9041', '217-8918712', '217-8918713', 'MR', 1000, '2003-01-01 00:00:00', '2003-01-01 00:00:00', '', '', '0000-00-00', '', '', 0, 0);
|
||||
|
||||
|
||||
REPLACE INTO `oxobject2payment` (`OXID`, `OXPAYMENTID`, `OXOBJECTID`, `OXTYPE`) VALUES ('660b8f058paypal6ada9ee7586d946ef', 'oxidpaypal', 'a7c40f6320aeb2ec2.72885259', 'oxcountry');
|
||||
REPLACE INTO `oxobject2payment` (`OXID`, `OXPAYMENTID`, `OXOBJECTID`, `OXTYPE`) VALUES ('26586trf09oiu927b50ed832f76feed4', 'oxidpaypal', '1b842e732a23255b1.91207750', 'oxdelset');
|
||||
REPLACE INTO `oxobject2payment` (`OXID`, `OXPAYMENTID`, `OXOBJECTID`, `OXTYPE`) VALUES ('26586trf09oiu927b50ed832f76feeg5', 'oxidpaypal', '1b842e732a23255b1.91207751', 'oxdelset');
|
||||
@@ -0,0 +1,168 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
return [
|
||||
'adminUser' => [
|
||||
"userId" => "admin",
|
||||
"userLoginName" => "admin",
|
||||
"userPassword" => "admin",
|
||||
"userName" => "John",
|
||||
"userLastName" => "Doe",
|
||||
],
|
||||
'userPassword' => 'useruser',
|
||||
'defaultUserName' => 'defaultuser@oxid-esales.dev',
|
||||
'defaultUserFirstName' => 'UserName',
|
||||
'userName' => 'paypaluser@oxid-esales.dev',
|
||||
'demoUserName' => 'user@oxid-esales.com',
|
||||
'details' => [
|
||||
'firstname' => 'TestUserName',
|
||||
'lastname' => 'TestUserSurname',
|
||||
'oxcity' => 'Hamburg',
|
||||
'oxstreet' => 'Hauptstr.',
|
||||
'oxstreetnr' => '13',
|
||||
'oxzip' => '22547'
|
||||
],
|
||||
'totalordersum_ecsdetails' => 149.5,
|
||||
'totalordersum_ecswithshipping' => 33.80,
|
||||
// This user will be created and will be available in ce|pe|ee demodata
|
||||
'user' => [
|
||||
'oxid' => 'pptestuser',
|
||||
'oxactive' => 1,
|
||||
'oxrights' => 'user',
|
||||
'oxshopid' => 1,
|
||||
'oxusername' => 'testing_account@oxid-esales.dev',
|
||||
'oxpassword' => '$2y$10$lj90Q/CaB0IB8PZemQW4Xu1/EWvAhkW9SOZ1Sr3JBx8DOmd3qz7bu',
|
||||
'oxfname' => 'User',
|
||||
'oxlname' => 'User',
|
||||
'oxstreet' => 'Street',
|
||||
'oxstreetnr' => 'Street Number',
|
||||
'oxzip' => 'ZIP',
|
||||
'oxcity' => 'City',
|
||||
'oxcountryid' => 'a7c40f631fc920687.20179984',
|
||||
'oxboni' => '600',
|
||||
'oxcreate' => date("Y-m-d H:i:s"),
|
||||
'oxregister' => date("Y-m-d H:i:s"),
|
||||
'oxbirthdate' => date("Y-m-d"),
|
||||
'oxpasssalt' => ''
|
||||
],
|
||||
'usergroups' => [
|
||||
'OXID' => 'pptestusergroups',
|
||||
'oxobjectid' => 'pptestuser',
|
||||
'oxgroupsid' => 'oxidcustomer'
|
||||
],
|
||||
// This product is available in ce|pe|ee demodata
|
||||
'product' => [
|
||||
'id' => 'dc5ffdf380e15674b56dd562a7cb6aec',
|
||||
'title' => 'Kuyichi leather belt JEVER',
|
||||
'amount' => 4,
|
||||
'price' => '119,60 €',
|
||||
'bruttoprice_single' => '29.9',
|
||||
'nettoprice_single' => '25.13'
|
||||
],
|
||||
'parent' => [
|
||||
'id' => '531b537118f5f4d7a427cdb825440922',
|
||||
'maxNettoPrice' => 83.95,
|
||||
'maxBruttoPrice' => 99.9,
|
||||
'minNettoPrice' => 78.07,
|
||||
'minBruttoPrice' => 92.9,
|
||||
],
|
||||
'variant' => [
|
||||
'id' => '6b6e0bb9f2b8b5f070f91593073b4555',
|
||||
'bruttoprice' => '99.9',
|
||||
'nettoprice' => '83.95'
|
||||
],
|
||||
'alternate_variant' => [
|
||||
'id' => '6b65295a7fe5fa6faaa2f0ac3f9b0f80',
|
||||
'bruttoprice' => '109.9',
|
||||
'nettoprice' => '92.35'
|
||||
],
|
||||
'shipping' => [
|
||||
'standard' => 'oxidstandard'
|
||||
],
|
||||
'payment_id' => 'oxidpaypal',
|
||||
'payment_id_other' => 'oxidcashondel',
|
||||
'oxvoucherseries' => [
|
||||
'OXID' => 'ppgserie1',
|
||||
'OXSERIENR' => 'ppgserie1',
|
||||
'OXDISCOUNT' => '10',
|
||||
'OXDISCOUNTTYPE' => 'absolute',
|
||||
'OXBEGINDATE' => '2000-01-01',
|
||||
'OXENDDATE' => '2050-12-31',
|
||||
'OXSERIEDESCRIPTION' => 'PPG test voucher',
|
||||
'OXALLOWOTHERSERIES' => 1
|
||||
],
|
||||
'oxvoucherseries_ee' => [
|
||||
'OXID' => 'ppgserie1',
|
||||
'OXMAPID' => '6543',
|
||||
'OXSERIENR' => 'ppgserie1',
|
||||
'OXDISCOUNT' => '10',
|
||||
'OXDISCOUNTTYPE' => 'absolute',
|
||||
'OXBEGINDATE' => '2000-01-01',
|
||||
'OXENDDATE' => '2050-12-31',
|
||||
'OXSERIEDESCRIPTION' => 'PPG test voucher',
|
||||
'OXALLOWOTHERSERIES' => 1
|
||||
],
|
||||
'oxvoucherseries2shop' => [
|
||||
'OXSHOPID' => '1',
|
||||
'OXMAPOBJECTID' => '6543'
|
||||
],
|
||||
'oxvouchers' => [
|
||||
'OXID' => 'ppgvoucher1',
|
||||
'OXVOUCHERNR' => 'ppgvoucher1',
|
||||
'OXVOUCHERSERIEID' => 'ppgserie1'
|
||||
],
|
||||
'oxdiscount' => [
|
||||
'OXID' => 'ppgdiscount',
|
||||
'OXSHOPID' => 1,
|
||||
'OXACTIVE' => 1,
|
||||
'OXACTIVEFROM' => '2020-12-01 00:00:00',
|
||||
'OXACTIVETO' => '2099-01-01 00:00:00',
|
||||
'OXTITLE' => 'ppgdiscount for product',
|
||||
'OXTITLE_1' => 'ppgdiscount for product',
|
||||
'OXAMOUNT' => 1,
|
||||
'OXAMOUNTTO' => 999999,
|
||||
'OXADDSUMTYPE' => 'abs',
|
||||
'OXADDSUM' => 9.9
|
||||
],
|
||||
'oxdiscount_ee' => [
|
||||
'OXID' => 'ppgdiscount',
|
||||
'OXMAPID' => '7654',
|
||||
'OXSHOPID' => 1,
|
||||
'OXACTIVE' => 1,
|
||||
'OXACTIVEFROM' => '2020-12-01 00:00:00',
|
||||
'OXACTIVETO' => '2099-01-01 00:00:00',
|
||||
'OXTITLE' => 'ppgdiscount for product',
|
||||
'OXTITLE_1' => 'ppgdiscount for product',
|
||||
'OXAMOUNT' => 1,
|
||||
'OXAMOUNTTO' => 999999,
|
||||
'OXADDSUMTYPE' => 'abs',
|
||||
'OXADDSUM' => 9.9
|
||||
],
|
||||
'oxdiscount2shop' => [
|
||||
'OXSHOPID' => '1',
|
||||
'OXMAPOBJECTID' => '7654'
|
||||
],
|
||||
'oxobject2discount' => [
|
||||
'OXID' => 'ppgdiscountrelation',
|
||||
'OXDISCOUNTID' => 'ppgdiscount',
|
||||
'OXOBJECTID' => 'dc5ffdf380e15674b56dd562a7cb6aec',
|
||||
'OXTYPE' => 'oxarticles'
|
||||
]
|
||||
];
|
||||
@@ -0,0 +1,319 @@
|
||||
<?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\Tests\Codeception;
|
||||
|
||||
use Codeception\Util\Fixtures;
|
||||
use OxidEsales\Codeception\Admin\AdminLoginPage;
|
||||
use OxidEsales\Codeception\Admin\AdminPanel;
|
||||
use OxidEsales\Codeception\Page\Home;
|
||||
use OxidEsales\Codeception\Module\Translation\Translator;
|
||||
use OxidEsales\Facts\Facts;
|
||||
use OxidEsales\PayPalModule\Tests\Codeception\Admin\PayPalOrder;
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class AcceptanceTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\AcceptanceTesterActions;
|
||||
|
||||
protected $maxRetries = 20;
|
||||
|
||||
/**
|
||||
* Open shop first page.
|
||||
*/
|
||||
public function openShop()
|
||||
{
|
||||
$I = $this;
|
||||
$homePage = new Home($I);
|
||||
$I->amOnPage($homePage->URL);
|
||||
|
||||
return $homePage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OxidEsales\Codeception\Admin\AdminPanel
|
||||
*/
|
||||
public function openAdminLoginPage()
|
||||
{
|
||||
$I = $this;
|
||||
$adminPanel = new AdminLoginPage($I);
|
||||
$I->amOnPage($adminPanel->URL);
|
||||
|
||||
return $adminPanel;
|
||||
}
|
||||
|
||||
public function activatePaypalModule(): void
|
||||
{
|
||||
$rootPath = (new Facts())->getShopRootPath();
|
||||
$possiblePaths = [
|
||||
'/bin/oe-console',
|
||||
'/vendor/bin/oe-console',
|
||||
];
|
||||
foreach ($possiblePaths as $path) {
|
||||
if (is_file($rootPath . $path)) {
|
||||
exec($rootPath . $path . ' oe:module:activate oepaypal');
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new \Exception('Could not find script "/bin/oe-console" to activate module');
|
||||
}
|
||||
|
||||
public function deactivatePaypalModule(): void
|
||||
{
|
||||
$rootPath = (new Facts())->getShopRootPath();
|
||||
$possiblePaths = [
|
||||
'/bin/oe-console',
|
||||
'/vendor/bin/oe-console',
|
||||
];
|
||||
foreach ($possiblePaths as $path) {
|
||||
if (is_file($rootPath . $path)) {
|
||||
exec($rootPath . $path . ' oe:module:deactivate oepaypal');
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new \Exception('Could not find script "/bin/oe-console" to deactivate module');
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch to PayPal Installment banner iframe
|
||||
* and check if body contains elements.
|
||||
*/
|
||||
public function seePayPalInstallmentBanner()
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
$I->waitForElement("//div[contains(@id, 'paypal-installment-banner-container')]//iframe");
|
||||
$I->switchToIFrame("//div[contains(@id, 'paypal-installment-banner-container')]//iframe");
|
||||
$I->waitForElementVisible("//body[node()]");
|
||||
|
||||
// Switch back to main window, otherwise we will stay in PP banner iframe
|
||||
$I->switchToIFrame();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function activateFlowTheme()
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
//prepare testing with flow theme
|
||||
$I->updateConfigInDatabase('sTheme', 'flow', 'str');
|
||||
$I->updateConfigInDatabase('oePayPalBannersStartPageSelector', '#wrapper .row', 'str');
|
||||
$I->updateConfigInDatabase('oePayPalBannersSearchResultsPageSelector', '#content .page-header .clearfix', 'str');
|
||||
$I->updateConfigInDatabase('oePayPalBannersProductDetailsPageSelector', '.detailsParams', 'str');
|
||||
$I->updateConfigInDatabase('oePayPalBannersPaymentPageSelector', '.checkoutSteps ~ .spacer', 'str');
|
||||
}
|
||||
|
||||
public function activateWaveTheme()
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
//prepare testing with wave theme
|
||||
$I->updateConfigInDatabase('sTheme', 'wave', 'str');
|
||||
$I->updateConfigInDatabase('oePayPalBannersStartPageSelector', '#wrapper .container', 'str');
|
||||
$I->updateConfigInDatabase('oePayPalBannersSearchResultsPageSelector', '.page-header', 'str');
|
||||
$I->updateConfigInDatabase('oePayPalBannersProductDetailsPageSelector', '#detailsItemsPager', 'str');
|
||||
$I->updateConfigInDatabase('oePayPalBannersPaymentPageSelector', '.checkout-steps', 'str');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $amount
|
||||
*/
|
||||
public function seePayPalInstallmentBannerInFlowAndWaveTheme(float $amount = 0, $breadCrumbText = '')
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
//Check installment banner body in Flow theme
|
||||
$I->reloadPage();
|
||||
$I->waitForPageLoad();
|
||||
if ($breadCrumbText) {
|
||||
$I->see($breadCrumbText);
|
||||
}
|
||||
$I->dontSee(Translator::translate('ERROR_MESSAGE_ARTICLE_ARTICLE_NOT_BUYABLE'));
|
||||
$I->seePayPalInstallmentBanner();
|
||||
$I->checkInstallmentBannerData($amount);
|
||||
|
||||
//Check installment banner body in Wave theme
|
||||
$this->activateWaveTheme();
|
||||
$I->reloadPage();
|
||||
$I->waitForPageLoad();
|
||||
if ($breadCrumbText) {
|
||||
$I->see($breadCrumbText);
|
||||
}
|
||||
$I->dontSee(Translator::translate('ERROR_MESSAGE_ARTICLE_ARTICLE_NOT_BUYABLE'));
|
||||
$I->seePayPalInstallmentBanner();
|
||||
$I->checkInstallmentBannerData($amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $amount
|
||||
* @param string $ratio
|
||||
* @param string $currency
|
||||
*/
|
||||
public function checkInstallmentBannerData(float $amount = 0, string $ratio = '20x1', string $currency = 'EUR')
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
$onloadMethod = $I->executeJS("return PayPalMessage.toString()");
|
||||
$I->assertRegExp($this->prepareMessagePartRegex(sprintf("amount: %s", $amount)), $onloadMethod);
|
||||
$I->assertRegExp($this->prepareMessagePartRegex(sprintf("ratio: '%s'", $ratio)), $onloadMethod);
|
||||
$I->assertRegExp($this->prepareMessagePartRegex(sprintf("currency: '%s'", $currency)), $onloadMethod);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getExistingUserData(): array
|
||||
{
|
||||
return Fixtures::get('user');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExistingUserName(): string
|
||||
{
|
||||
return $this->getExistingUserData()['oxusername'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExistingUserPassword(): string
|
||||
{
|
||||
return Fixtures::get('userPassword');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDemoUserName(): string
|
||||
{
|
||||
return Fixtures::get('demoUserName');
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the message part in message required conditions
|
||||
*
|
||||
* @param string $part
|
||||
* @return string
|
||||
*/
|
||||
protected function prepareMessagePartRegex($part)
|
||||
{
|
||||
return "/paypal.Messages\(\{[^}\)]*{$part}/";
|
||||
}
|
||||
|
||||
public function openAdmin(): AdminLoginPage
|
||||
{
|
||||
$I = $this;
|
||||
$adminLogin = new AdminLoginPage($I);
|
||||
$I->amOnPage($adminLogin->URL);
|
||||
return $adminLogin;
|
||||
}
|
||||
|
||||
public function loginAdmin(): AdminPanel
|
||||
{
|
||||
$adminPage = $this->openAdmin();
|
||||
$admin = Fixtures::get('adminUser');
|
||||
return $adminPage->login($admin['userLoginName'], $admin['userPassword']);
|
||||
}
|
||||
|
||||
public function getShopUrl(): string
|
||||
{
|
||||
$facts = new Facts();
|
||||
|
||||
return $facts->getShopUrl();
|
||||
}
|
||||
|
||||
public function switchToLastWindow()
|
||||
{
|
||||
$I = $this;
|
||||
$I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
|
||||
$handles=$webdriver->getWindowHandles();
|
||||
$last_window = end($handles);
|
||||
$webdriver->switchTo()->window($last_window);
|
||||
$size = new \Facebook\WebDriver\WebDriverDimension(1920, 1280);
|
||||
$webdriver->manage()->window()->setSize($size);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AcceptanceTester $I
|
||||
* @param int $orderNumber
|
||||
*
|
||||
* @return PayPalOrder
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function openAdminOrder(int $orderNumber, int $retry = 0)
|
||||
{
|
||||
$I = $this;
|
||||
|
||||
if ($retry >= $this->maxRetries) {
|
||||
$I->makeScreenshot();
|
||||
$I->makeHtmlSnapshot();
|
||||
$I->markTestIncomplete('Did not manage to open the PayPal order tab');
|
||||
}
|
||||
|
||||
$adminLoginPage = $I->openAdminLoginPage();
|
||||
$adminUser = Fixtures::get('adminUser');
|
||||
$adminPanel = $adminLoginPage->login($adminUser['userLoginName'], $adminUser['userPassword']);
|
||||
|
||||
$ordersList = $adminPanel->openOrders($adminPanel);
|
||||
|
||||
$ordersList->searchByOrderNumber($orderNumber);
|
||||
$I->wait(1);
|
||||
if ($I->seePageHasElement('//a[text()="' . $orderNumber . '"]')) {
|
||||
$I->retryClick('//a[text()="' . $orderNumber . '"]');
|
||||
} elseif ($I->seePageHasElement('//a[text()="PayPal"]')) {
|
||||
$I->retryClick('//a[text()="PayPal"]');
|
||||
} else {
|
||||
$this->openAdminOrder($orderNumber, ++$retry);
|
||||
}
|
||||
|
||||
$I->wait(1);
|
||||
$paypalOrder = new PayPalOrder($I);
|
||||
if (!$I->seePageHasElement($paypalOrder->paypalTab)) {
|
||||
$this->openAdminOrder($orderNumber, ++$retry);
|
||||
}
|
||||
|
||||
$I->retryClick($paypalOrder->paypalTab);
|
||||
$I->selectEditFrame();
|
||||
|
||||
if (!$I->seePageHasElement($paypalOrder->captureButton)) {
|
||||
$this->openAdminOrder($orderNumber, ++$retry);
|
||||
}
|
||||
|
||||
return $paypalOrder;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?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\Tests\Codeception\Admin;
|
||||
|
||||
use OxidEsales\Codeception\Page\Page;
|
||||
|
||||
/**
|
||||
* Class Orders
|
||||
* @package OxidEsales\PayPalModule\Tests\Codeception\Admin
|
||||
*/
|
||||
class PayPalOrder extends Page
|
||||
{
|
||||
public $paypalTab = '//a[@href="#oepaypalorder_paypal"]';
|
||||
public $captureButton = '#captureButton';
|
||||
public $amountSelect = '.amountSelect';
|
||||
public $captureAmountInput = '#captureAmountInput';
|
||||
public $pendingStatusCheckbox = '#pendingStatusCheckbox';
|
||||
public $editForm = '[name=myedit]';
|
||||
public $refundButton = '#refundButton0';
|
||||
public $refundAmountInput = '#refundAmountInput';
|
||||
public $errorBox = '.errorbox';
|
||||
public $captureErrorText = 'Error message from PayPal: Amount is not valid';
|
||||
public $refundErrorText = 'Error message from PayPal: The partial refund amount is not valid';
|
||||
public $lastHistoryRowAction = '//*[@id="historyTable"]/tbody/tr[2]/td[2]';
|
||||
public $lastHistoryRowAmount = '//*[@id="historyTable"]/tbody/tr[2]/td[3]';
|
||||
|
||||
/**
|
||||
* Capture order
|
||||
*
|
||||
* @param $amount
|
||||
* @param string $type
|
||||
* @return $this
|
||||
*/
|
||||
public function captureAmount($amount, $type = 'Complete')
|
||||
{
|
||||
$I = $this->user;
|
||||
$I->waitForElement($this->captureButton, 10);
|
||||
$I->click($this->captureButton);
|
||||
$I->selectOption($this->amountSelect, $type);
|
||||
if ($type !== 'Complete') {
|
||||
$I->fillField($this->captureAmountInput, $amount);
|
||||
$I->click($this->pendingStatusCheckbox);
|
||||
}
|
||||
$I->submitForm($this->editForm, []);
|
||||
$I->waitForElementNotVisible($this->editForm, 30);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund amount
|
||||
*
|
||||
* @param $amount
|
||||
* @param string $type
|
||||
* @return $this
|
||||
*/
|
||||
public function refundAmount($amount, $type = 'Full')
|
||||
{
|
||||
$I = $this->user;
|
||||
$I->waitForElement($this->refundButton, 10);
|
||||
$I->click($this->refundButton);
|
||||
$I->selectOption($this->amountSelect, $type);
|
||||
if ($type !== 'Full') {
|
||||
$I->fillField($this->refundAmountInput, $amount);
|
||||
}
|
||||
$I->submitForm($this->editForm, []);
|
||||
$I->waitForElementNotVisible($this->editForm, 30);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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\Tests\Codeception\Helper;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
use PHPUnit\Framework\AssertionFailedError;
|
||||
|
||||
class Acceptance extends \Codeception\Module
|
||||
{
|
||||
public function seePageHasElement($element)
|
||||
{
|
||||
try {
|
||||
$this->getModule('WebDriver')->_findElements($element);
|
||||
} catch (AssertionFailedError $f) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?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\Tests\Codeception\Page\Checkout;
|
||||
|
||||
/**
|
||||
* Class OrderCheckout
|
||||
* @package OxidEsales\PayPalModule\Tests\Codeception\Page
|
||||
*/
|
||||
class OrderCheckout extends \OxidEsales\Codeception\Page\Checkout\OrderCheckout
|
||||
{
|
||||
public $confirmationButton = '#orderConfirmAgbBottom';
|
||||
|
||||
/**
|
||||
* Clicks on submit order button.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function submitOrder()
|
||||
{
|
||||
$I = $this->user;
|
||||
$I->waitForElementVisible($this->confirmationButton, 10);
|
||||
$I->submitForm($this->confirmationButton, []);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,356 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OxidEsales\PayPalModule\Tests\Codeception\Page;
|
||||
|
||||
use Facebook\WebDriver\Exception\ElementNotVisibleException;
|
||||
use OxidEsales\Codeception\Page\Checkout\OrderCheckout;
|
||||
use OxidEsales\Codeception\Page\Page;
|
||||
|
||||
/**
|
||||
* Class PayPalLogin
|
||||
* @package OxidEsales\PayPalModule\Tests\Codeception\Page
|
||||
*/
|
||||
class PayPalLogin extends Page
|
||||
{
|
||||
public $userLoginEmail = '#email';
|
||||
public $oldUserLoginEmail = '#login_email';
|
||||
|
||||
public $userPassword = '#password';
|
||||
public $oldUserPassword = '#login_password';
|
||||
|
||||
public $nextButton = '#btnNext';
|
||||
|
||||
public $loginButton = '#btnLogin';
|
||||
public $oldLoginButton = '#submitLogin';
|
||||
|
||||
public $newConfirmButton = '#confirmButtonTop';
|
||||
public $oldConfirmButton = '#continue_abovefold';
|
||||
|
||||
public $oneTouchNotNowLink = '#notNowLink';
|
||||
|
||||
public $spinner = '#spinner';
|
||||
|
||||
public $gdprContainer = "#gdpr-container";
|
||||
public $gdprCookieBanner = "#gdprCookieBanner";
|
||||
public $acceptAllPaypalCookies = "#acceptAllButton";
|
||||
|
||||
public $loginSection = "#loginSection";
|
||||
public $oldLoginSection = "#passwordSection";
|
||||
|
||||
public $cancelLink = "#cancelLink";
|
||||
public $returnToShop = "#cancel_return";
|
||||
|
||||
public $breadCrumb = "#breadCrumb";
|
||||
|
||||
public $paymentConfirmButton = "#payment-submit-btn";
|
||||
public $globalSpinner = "//div[@data-testid='global-spinner']";
|
||||
public $preloaderSpinner = "//div[@id='preloaderSpinner']";
|
||||
|
||||
public $paypalBannerContainer = "//div[@id='paypal-installment-banner-container']";
|
||||
|
||||
public $backToInputEmail = "#backToInputEmailLink";
|
||||
public $errorSection = '#notifications #pageLevelErrors';
|
||||
public $splitPassword = '#splitPassword';
|
||||
public $splitEmail = '#splitEmail';
|
||||
public $rememberedEmail = "//div[@class='profileRememberedEmail']";
|
||||
|
||||
/**
|
||||
* @param string $userName
|
||||
* @param string $userPassword
|
||||
*
|
||||
* @return OrderCheckout
|
||||
*/
|
||||
public function loginAndCheckout(string $userName, string $userPassword): OrderCheckout
|
||||
{
|
||||
$I = $this->user;
|
||||
$usingNewLogin = true;
|
||||
|
||||
$this->waitForPayPalPage();
|
||||
|
||||
// In case we have cookie message, accept all cookies
|
||||
$this->acceptAllPayPalCookies();
|
||||
|
||||
// new login page
|
||||
if ($I->seePageHasElement($this->userLoginEmail)) {
|
||||
$I->waitForElementVisible($this->userLoginEmail, 30);
|
||||
$I->fillField($this->userLoginEmail, $userName);
|
||||
$I->retryClick($this->nextButton);
|
||||
$this->waitForPayPalPage();
|
||||
|
||||
$I->waitForElementVisible($this->userPassword, 10);
|
||||
$I->fillField($this->userPassword, $userPassword);
|
||||
$I->retryClick($this->loginButton);
|
||||
}
|
||||
|
||||
// old login page
|
||||
if ($I->seePageHasElement($this->oldUserLoginEmail)) {
|
||||
$usingNewLogin = false;
|
||||
|
||||
$I->waitForElementVisible($this->oldUserLoginEmail, 30);
|
||||
$I->fillField($this->oldUserLoginEmail, $userName);
|
||||
$I->waitForElementVisible($this->oldUserPassword, 5);
|
||||
$I->fillField($this->oldUserPassword, $userPassword);
|
||||
$I->retryClick($this->oldLoginButton);
|
||||
}
|
||||
|
||||
$this->waitForPayPalPage();
|
||||
|
||||
if ($I->seePageHasElement($this->oneTouchNotNowLink)) {
|
||||
$I->retryClick($this->oneTouchNotNowLink);
|
||||
}
|
||||
|
||||
$confirmButton = $usingNewLogin ? $this->newConfirmButton : $this->oldConfirmButton;
|
||||
$I->waitForElementClickable($confirmButton, 60);
|
||||
|
||||
$this->waitForPayPalPage();
|
||||
|
||||
$I->retryClick($confirmButton);
|
||||
$I->waitForDocumentReadyState();
|
||||
|
||||
return new OrderCheckout($I);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $userName
|
||||
* @param string $userPassword
|
||||
*
|
||||
* @return OrderCheckout
|
||||
*/
|
||||
public function checkoutWithStandardPayPal(string $userName, string $userPassword): OrderCheckout
|
||||
{
|
||||
$I = $this->user;
|
||||
|
||||
$this->loginToPayPal($userName, $userPassword);
|
||||
|
||||
$this->confirmPayPal();
|
||||
|
||||
//retry
|
||||
$this->waitForSpinnerDisappearance();
|
||||
$this->confirmPayPal();
|
||||
|
||||
return new OrderCheckout($I);
|
||||
}
|
||||
|
||||
public function loginToPayPal(string $userName, string $userPassword): void
|
||||
{
|
||||
$I = $this->user;
|
||||
|
||||
$this->waitForPayPalPage();
|
||||
$this->removeCookieConsent();
|
||||
|
||||
if ($I->seePageHasElement($this->splitPassword)
|
||||
&& $I->seePageHasElement($this->rememberedEmail)
|
||||
&& $I->seePageHasElement($this->backToInputEmail)
|
||||
) {
|
||||
try {
|
||||
$I->seeAndClick($this->backToInputEmail);
|
||||
$I->waitForDocumentReadyState();
|
||||
$this->waitForSpinnerDisappearance();
|
||||
$I->waitForElementNotVisible($this->backToInputEmail);
|
||||
} catch(ElementNotVisibleException $e) {
|
||||
//nothing to be done, element was not visible
|
||||
}
|
||||
}
|
||||
|
||||
if ($I->seePageHasElement($this->oldLoginSection)) {
|
||||
$I->waitForElementVisible($this->userLoginEmail, 5);
|
||||
$I->fillField($this->userLoginEmail, $userName);
|
||||
|
||||
if ($I->seePageHasElement($this->nextButton)) {
|
||||
$I->retryClick($this->nextButton);
|
||||
}
|
||||
|
||||
$I->waitForElementVisible($this->userPassword, 5);
|
||||
$I->fillField($this->userPassword, $userPassword);
|
||||
$I->retryClick($this->loginButton);
|
||||
}
|
||||
|
||||
if ($I->seePageHasElement($this->oneTouchNotNowLink)) {
|
||||
$I->retryClick($this->oneTouchNotNowLink);
|
||||
}
|
||||
|
||||
$this->waitForSpinnerDisappearance();
|
||||
$this->removeCookieConsent();
|
||||
$this->waitForSpinnerDisappearance();
|
||||
$I->wait(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $userName
|
||||
* @param string $userPassword
|
||||
*/
|
||||
public function approveGraphqlStandardPayPal(string $userName, string $userPassword): void
|
||||
{
|
||||
$I = $this->user;
|
||||
|
||||
$this->loginToPayPal($userName, $userPassword);
|
||||
|
||||
$this->confirmPayPal();
|
||||
|
||||
//retry
|
||||
$this->waitForSpinnerDisappearance();
|
||||
$this->confirmPayPal();
|
||||
|
||||
//we should be back to shop frontend as we sent a redirect url to paypal
|
||||
$I->assertTrue($I->seePageHasElement($this->paypalBannerContainer));
|
||||
}
|
||||
|
||||
public function confirmPayPal()
|
||||
{
|
||||
$I = $this->user;
|
||||
|
||||
$this->waitForSpinnerDisappearance();
|
||||
$this->removeCookieConsent();
|
||||
|
||||
if ($I->seePageHasElement(substr($this->newConfirmButton, 1))) {
|
||||
$I->retryClick($this->newConfirmButton);
|
||||
$I->waitForDocumentReadyState();
|
||||
$I->waitForElementNotVisible($this->globalSpinner, 60);
|
||||
$I->wait(10);
|
||||
}
|
||||
|
||||
if ($I->seePageHasElement("//input[@id='" . substr($this->newConfirmButton, 1) . "']")) {
|
||||
$I->executeJS("document.getElementById('" . substr($this->newConfirmButton, 1) . "').click();");
|
||||
$I->waitForDocumentReadyState();
|
||||
$I->waitForElementNotVisible($this->globalSpinner, 60);
|
||||
$I->wait(10);
|
||||
}
|
||||
|
||||
if ($I->seePageHasElement($this->paymentConfirmButton)) {
|
||||
$I->retryClick($this->paymentConfirmButton);
|
||||
$I->waitForDocumentReadyState();
|
||||
$I->waitForElementNotVisible($this->globalSpinner, 60);
|
||||
$I->wait(10);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $userName
|
||||
* @param string $userPassword
|
||||
*/
|
||||
public function approveGraphqlExpressPayPal(string $userName, string $userPassword): void
|
||||
{
|
||||
$I = $this->user;
|
||||
|
||||
$this->approveExpressPayPal($userName, $userPassword);
|
||||
|
||||
//we should be back to shop frontend as we sent a redirect url to paypal
|
||||
$I->seePageHasElement($this->paypalBannerContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $userName
|
||||
* @param string $userPassword
|
||||
*/
|
||||
public function approveExpressPayPal(string $userName, string $userPassword): void
|
||||
{
|
||||
$I = $this->user;
|
||||
|
||||
$this->waitForPayPalPage();
|
||||
$this->waitForSpinnerDisappearance();
|
||||
$this->removeCookieConsent();
|
||||
|
||||
$this->loginToPayPal($userName, $userPassword);
|
||||
$this->waitForSpinnerDisappearance();
|
||||
$I->wait(3);
|
||||
|
||||
$this->confirmPayPal();
|
||||
|
||||
//retry
|
||||
$this->waitForSpinnerDisappearance();
|
||||
$this->confirmPayPal();
|
||||
}
|
||||
|
||||
public function waitForPayPalPage(): PayPalLogin
|
||||
{
|
||||
$I = $this->user;
|
||||
|
||||
$I->waitForDocumentReadyState();
|
||||
$I->waitForElementNotVisible($this->spinner, 90);
|
||||
$I->wait(10);
|
||||
|
||||
if ($I->seePageHasElement($this->loginSection)) {
|
||||
$I->retryClick('.loginRedirect a');
|
||||
$I->waitForDocumentReadyState();
|
||||
$this->waitForSpinnerDisappearance();
|
||||
$I->waitForElementNotVisible($this->loginSection);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Click cancel on payPal side to return to shop.
|
||||
*/
|
||||
public function cancelPayPal(bool $isRetry = false): void
|
||||
{
|
||||
$I = $this->user;
|
||||
|
||||
if ($I->seePageHasElement($this->cancelLink)) {
|
||||
$I->amOnUrl($I->grabAttributeFrom($this->cancelLink, 'href'));
|
||||
$I->waitForDocumentReadyState();
|
||||
} elseif ($I->seePageHasElement($this->returnToShop)) {
|
||||
$I->amOnUrl($I->grabAttributeFrom($this->returnToShop, 'href'));
|
||||
$I->waitForDocumentReadyState();
|
||||
}
|
||||
|
||||
//we should be redirected back to shop at this point
|
||||
if ($I->dontSeeElement($this->breadCrumb) &&
|
||||
$I->dontSeeElement(strtolower($this->breadCrumb)) &&
|
||||
!$isRetry
|
||||
) {
|
||||
$this->cancelPayPal(true);
|
||||
}
|
||||
}
|
||||
|
||||
private function acceptAllPayPalCookies()
|
||||
{
|
||||
$I = $this->user;
|
||||
|
||||
// In case we have cookie message, accept all cookies
|
||||
if ($I->seePageHasElement($this->acceptAllPaypalCookies)) {
|
||||
$I->retryClick($this->acceptAllPaypalCookies);
|
||||
$I->waitForElementNotVisible($this->acceptAllPaypalCookies);
|
||||
}
|
||||
}
|
||||
|
||||
private function waitForSpinnerDisappearance()
|
||||
{
|
||||
$I = $this->user;
|
||||
$I->waitForElementNotVisible($this->preloaderSpinner, 30);
|
||||
$I->waitForElementNotVisible($this->globalSpinner, 30);
|
||||
$I->waitForElementNotVisible($this->spinner, 30);
|
||||
}
|
||||
|
||||
private function removeCookieConsent()
|
||||
{
|
||||
$I = $this->user;
|
||||
if ($I->seePageHasElement($this->gdprContainer)) {
|
||||
$I->executeJS("document.getElementById('" . substr($this->gdprContainer, 1) . "').remove();");
|
||||
}
|
||||
if ($I->seePageHasElement($this->gdprCookieBanner)) {
|
||||
$I->executeJS("document.getElementById('" . substr($this->gdprCookieBanner, 1) . "').remove();");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
# suite config
|
||||
actor: AcceptanceTester
|
||||
path: Acceptance
|
||||
bootstrap: _bootstrap.php
|
||||
modules:
|
||||
enabled:
|
||||
- Asserts
|
||||
- REST:
|
||||
url: '%SHOP_URL%'
|
||||
depends: PhpBrowser
|
||||
part: Json
|
||||
- \OxidEsales\PayPalModule\Tests\Codeception\Helper\Acceptance
|
||||
- WebDriver:
|
||||
url: '%SHOP_URL%'
|
||||
browser: '%BROWSER_NAME%'
|
||||
port: '%SELENIUM_SERVER_PORT%'
|
||||
host: '%SELENIUM_SERVER_HOST%'
|
||||
window_size: 1920x1080
|
||||
clear_cookies: true
|
||||
- Db:
|
||||
dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%;charset=utf8'
|
||||
user: '%DB_USERNAME%'
|
||||
password: '%DB_PASSWORD%'
|
||||
port: '%DB_PORT%'
|
||||
dump: '%DUMP_PATH%'
|
||||
module_dump: '%MODULE_DUMP_PATH%'
|
||||
mysql_config: '%MYSQL_CONFIG_PATH%'
|
||||
populate: true # run populator before all tests
|
||||
cleanup: true # run populator before each test
|
||||
populator: >
|
||||
%PHP_BIN% %VENDOR_PATH%/bin/reset-shop
|
||||
&& mysql --defaults-file=$mysql_config --default-character-set=utf8 $dbname < $dump
|
||||
&& mysql --defaults-file=$mysql_config --default-character-set=utf8 $dbname < $module_dump
|
||||
initial_queries:
|
||||
- "SET SESSION sql_mode = '';"
|
||||
- \OxidEsales\Codeception\Module\Oxideshop:
|
||||
depends:
|
||||
- WebDriver
|
||||
- Db
|
||||
- \OxidEsales\Codeception\Module\OxideshopAdmin:
|
||||
depends:
|
||||
- WebDriver
|
||||
- \OxidEsales\Codeception\Module\Oxideshop
|
||||
- \OxidEsales\Codeception\Module\Database:
|
||||
config_key: 'fq45QS09_fqyx09239QQ'
|
||||
depends: Db
|
||||
- \OxidEsales\Codeception\Module\Translation\TranslationsModule:
|
||||
shop_path: '%SHOP_SOURCE_PATH%'
|
||||
paths: 'Application/views/flow,Application/views/admin,modules/oe/oepaypal/translations,modules/oe/oepaypal/views/admin'
|
||||
- \OxidEsales\Codeception\Module\OxideshopModules
|
||||
- \OxidEsales\PayPalModule\Tests\Codeception\Module\GraphQLHelper:
|
||||
depends:
|
||||
- REST
|
||||
step_decorators:
|
||||
- \Codeception\Step\Retry
|
||||
@@ -0,0 +1,252 @@
|
||||
<?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\Tests\Integration\CheckoutRequest;
|
||||
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
|
||||
class CheckoutRequestTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/**
|
||||
* Test cases directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_sTestCasesPath = '/testcases/';
|
||||
|
||||
/* Specified test cases (optional) */
|
||||
protected $_aTestCases = array(
|
||||
//'standard/caseSetExpressCheckout_AdditionalItems.php',
|
||||
//'standard/caseSetExpressCheckout_Config2.php',
|
||||
);
|
||||
|
||||
/**
|
||||
* Initialize the fixture.
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->reset();
|
||||
$this->cleanTmpDir();
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Basket startup data and expected calculations results
|
||||
*/
|
||||
public function providerDoExpressCheckoutPayment()
|
||||
{
|
||||
$parser = new \OxidEsales\PayPalModule\Tests\Integration\Library\TestCaseParser();
|
||||
$parser->setDirectory(__DIR__ . $this->_sTestCasesPath);
|
||||
if (isset($this->_aTestCases)) {
|
||||
$parser->setTestCases($this->_aTestCases);
|
||||
}
|
||||
$parser->setReplacements($this->getReplacements());
|
||||
|
||||
return $parser->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDoExpressCheckoutPayment
|
||||
*/
|
||||
public function testExpressCheckoutPaymentRequest($testCase)
|
||||
{
|
||||
if ($testCase['skipped']) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($testCase['session'])) {
|
||||
foreach ($testCase['session'] as $key=> $value) {
|
||||
\OxidEsales\Eshop\Core\Registry::getSession()->setVariable($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($testCase['config'])) {
|
||||
foreach ($testCase['config'] as $key=> $value) {
|
||||
$this->getConfig()->setConfigParam($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
$communicationHelper = new \OxidEsales\PayPalModule\Tests\Integration\Library\CommunicationHelper();
|
||||
$curl = $communicationHelper->getCurl(array());
|
||||
|
||||
$dispatcher = $this->getDispatcher($testCase);
|
||||
$this->setCurlToDispatcher($dispatcher, $curl);
|
||||
|
||||
$dispatcher->{$testCase['action']}();
|
||||
|
||||
$curlParameters = $curl->getParameters();
|
||||
|
||||
$expected = $testCase['expected'];
|
||||
|
||||
$asserts = new \OxidEsales\PayPalModule\Tests\Integration\Library\ArrayAsserts();
|
||||
|
||||
$asserts->assertArraysEqual($expected['requestToPayPal'], $curlParameters);
|
||||
|
||||
if (isset($expected['header'])) {
|
||||
$curlHeader = $curl->getHeader();
|
||||
$asserts->assertArraysEqual($expected['header'], $curlHeader);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return dispatcher object
|
||||
*
|
||||
* @param array $testCase
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class
|
||||
*/
|
||||
protected function getDispatcher($testCase)
|
||||
{
|
||||
$basketConstruct = new \OxidEsales\PayPalModule\Tests\Integration\Library\ShopConstruct();
|
||||
$basketConstruct->setParams($testCase);
|
||||
|
||||
$basket = $basketConstruct->getBasket();
|
||||
$session = $this->getSessionMock();
|
||||
$session->setBasket($basket);
|
||||
\OxidEsales\Eshop\Core\Registry::set(\OxidEsales\Eshop\Core\Session::class, $session);
|
||||
|
||||
$this->setMockedUtils();
|
||||
|
||||
$mockBuilder = $this->getMockBuilder($testCase['class']);
|
||||
$mockBuilder->setMethods(['getPayPalOrder']);
|
||||
$dispatcher = $mockBuilder->getMock();
|
||||
|
||||
$dispatcher->expects($this->any())->method('getPayPalOrder')->will($this->returnValue($this->getOrder()));
|
||||
$dispatcher->setUser($basketConstruct->getUser());
|
||||
|
||||
return $dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function getSessionMock()
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\Eshop\Core\Session::class);
|
||||
$mockBuilder->setMethods(['getRemoteAccessToken']);
|
||||
$session = $mockBuilder->getMock();
|
||||
|
||||
$session->expects($this->any())->method('getRemoteAccessToken')->will($this->returnValue('token'));
|
||||
|
||||
return $session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Curl to dispatcher
|
||||
*
|
||||
* @param $dispatcher
|
||||
* @param $curl
|
||||
*/
|
||||
protected function setCurlToDispatcher($dispatcher, $curl)
|
||||
{
|
||||
$communicationService = $dispatcher->getPayPalCheckoutService();
|
||||
$caller = $communicationService->getCaller();
|
||||
$oldCurl = $caller->getCurl();
|
||||
|
||||
$curl->setHost($oldCurl->getHost());
|
||||
$curl->setDataCharset($oldCurl->getDataCharset());
|
||||
$curl->setUrlToCall($oldCurl->getUrlToCall());
|
||||
|
||||
$caller->setCurl($curl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns mocked order object
|
||||
*
|
||||
* @return \OxidEsales\Eshop\Application\Model\Order
|
||||
*/
|
||||
protected function getOrder()
|
||||
{
|
||||
/** @var \OxidEsales\Eshop\Application\Model\Order $order */
|
||||
$mockBuilder = $this->getMockBuilder(Order::class);
|
||||
$mockBuilder->setMethods(['finalizePayPalOrder']);
|
||||
$order = $mockBuilder->getMock();
|
||||
|
||||
$order->expects($this->any())->method('finalizePayPalOrder')->will($this->returnValue(null));
|
||||
$order->oxorder__oxid = new \OxidEsales\Eshop\Core\Field('_test_order');
|
||||
$order->save();
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mocks oxUtils redirect method so that no redirect would be made
|
||||
*/
|
||||
protected function setMockedUtils()
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\Eshop\Core\Utils::class);
|
||||
$mockBuilder->setMethods(['redirect']);
|
||||
$utils = $mockBuilder->getMock();
|
||||
|
||||
$utils->expects($this->any())->method('redirect')->will($this->returnValue(null));
|
||||
\OxidEsales\Eshop\Core\Registry::set(\OxidEsales\Eshop\Core\Utils::class, $utils);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of replacements in test data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getReplacements()
|
||||
{
|
||||
$facts = new \OxidEsales\Facts\Facts();
|
||||
$buttonSource = 'O3SHOP_Cart_CommunityECS';
|
||||
|
||||
$replacements = array(
|
||||
'{SHOP_URL}' => $this->getConfig()->getShopUrl(),
|
||||
'{SHOP_ID}' => $this->getConfig()->getShopId(),
|
||||
'{BN_ID}' => $buttonSource,
|
||||
'{BN_ID_SHORTCUT}' => 'O3SHOP_Cart_ECS_Shortcut'
|
||||
);
|
||||
|
||||
return $replacements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets db tables, required configs
|
||||
*/
|
||||
protected function reset()
|
||||
{
|
||||
$db = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
|
||||
$config = \OxidEsales\Eshop\Core\Registry::getConfig();
|
||||
$db->execute("TRUNCATE oxarticles");
|
||||
$db->execute("TRUNCATE oxcategories");
|
||||
$db->execute("TRUNCATE oxcounters");
|
||||
$db->execute("TRUNCATE oxdiscount");
|
||||
$db->execute("TRUNCATE oxobject2discount");
|
||||
$db->execute("TRUNCATE oxgroups");
|
||||
$db->execute("TRUNCATE oxobject2group");
|
||||
$db->execute("TRUNCATE oxwrapping");
|
||||
$db->execute("TRUNCATE oxdelivery");
|
||||
$db->execute("TRUNCATE oxdel2delset");
|
||||
$db->execute("TRUNCATE oxobject2payment");
|
||||
$db->execute("TRUNCATE oxvouchers");
|
||||
$db->execute("TRUNCATE oxvoucherseries");
|
||||
$db->execute("TRUNCATE oxobject2delivery");
|
||||
$db->execute("TRUNCATE oxdeliveryset");
|
||||
$db->execute("TRUNCATE oxuser");
|
||||
$db->execute("TRUNCATE oxprice2article");
|
||||
$config->setConfigParam("blShowVATForDelivery", true);
|
||||
$config->setConfigParam("blShowVATForPayCharge", true);
|
||||
$db->execute("UPDATE oxpayments SET oxaddsum=0 WHERE oxid = 'oxidpaypal'");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: netto
|
||||
* Price view mode: netto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
use OxidEsales\Eshop\Application\Model\PaymentGateway;
|
||||
|
||||
$data = array(
|
||||
'class' => PaymentGateway::class,
|
||||
'action' => 'doExpressCheckoutPayment',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 9001,
|
||||
'oxprice' => 100,
|
||||
'oxvat' => 19,
|
||||
'amount' => 33,
|
||||
'oxstock' => 50,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 9002,
|
||||
'oxprice' => 66,
|
||||
'oxvat' => 19,
|
||||
'amount' => 16,
|
||||
'oxstock' => 20,
|
||||
),
|
||||
),
|
||||
'discounts' => array(),
|
||||
'costs' => array(),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser4',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword5',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature6',
|
||||
'sOEPayPalTransactionMode' => 'Authorization',
|
||||
'blShowNetPrice' => true,
|
||||
'OEPayPalDisableIPN' => false,
|
||||
),
|
||||
'session' => ['oepaypal' => 2],
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword5',
|
||||
'USER' => 'testUser4',
|
||||
'SIGNATURE' => 'testSignature6',
|
||||
'TOKEN' => '',
|
||||
'PAYERID' => '',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
|
||||
'PAYMENTREQUEST_0_AMT' => '4355.82',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_NOTIFYURL' => '{SHOP_URL}index.php?cl=oepaypalipnhandler&fnc=handleRequest&shp={SHOP_ID}',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Bestellnummer 1',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Bestellnummer 1',
|
||||
'BUTTONSOURCE' => '{BN_ID_SHORTCUT}',
|
||||
'METHOD' => 'DoExpressCheckoutPayment',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,164 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: bruto
|
||||
* Price view mode: brutto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
use OxidEsales\Eshop\Application\Model\PaymentGateway;
|
||||
|
||||
$data = array(
|
||||
'class' => PaymentGateway::class,
|
||||
'action' => 'doExpressCheckoutPayment',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 9001,
|
||||
'oxprice' => 100,
|
||||
'oxvat' => 19,
|
||||
'amount' => 33,
|
||||
'oxstock' => 33,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 9002,
|
||||
'oxprice' => 66,
|
||||
'oxvat' => 19,
|
||||
'amount' => 16,
|
||||
'oxstock' => 50,
|
||||
),
|
||||
),
|
||||
'discounts' => array(
|
||||
0 => array(
|
||||
'oxid' => 'shopdiscount5for9001',
|
||||
'oxaddsum' => 5,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxamount' => 0,
|
||||
'oxamountto' => 99999,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array(9001),
|
||||
),
|
||||
),
|
||||
'costs' => array(
|
||||
'wrapping' => array(
|
||||
0 => array(
|
||||
'oxtype' => 'WRAP',
|
||||
'oxname' => 'testWrap9001',
|
||||
'oxprice' => 9,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array(9001)
|
||||
),
|
||||
),
|
||||
'delivery' => array(
|
||||
0 => array(
|
||||
'oxtitle' => '6_abs_del',
|
||||
'oxactive' => 1,
|
||||
'oxaddsum' => 6,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxdeltype' => 'p',
|
||||
'oxfinalize' => 1,
|
||||
'oxparamend' => 99999
|
||||
),
|
||||
),
|
||||
'payment' => array(
|
||||
0 => array(
|
||||
'oxtitle' => '1 abs payment',
|
||||
'oxaddsum' => 1,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxfromamount' => 0,
|
||||
'oxtoamount' => 1000000,
|
||||
'oxchecked' => 1,
|
||||
'oxarticles' => array(9001, 9002),
|
||||
),
|
||||
),
|
||||
'voucherserie' => array(
|
||||
0 => array(
|
||||
'oxserienr' => 'abs_4_voucher_serie',
|
||||
'oxdiscount' => 6.00,
|
||||
'oxdiscounttype' => 'absolute',
|
||||
'oxallowsameseries' => 1,
|
||||
'oxallowotherseries' => 1,
|
||||
'oxallowuseanother' => 1,
|
||||
'oxshopincl' => 1,
|
||||
'voucher_count' => 1
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
'sOEPayPalTransactionMode' => 'Automatic',
|
||||
'sOEPayPalEmptyStockLevel' => 1,
|
||||
'OEPayPalDisableIPN' => false,
|
||||
),
|
||||
'session' => ['oepaypal' => 2],
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'TOKEN' => '',
|
||||
'PAYERID' => '',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
|
||||
'PAYMENTREQUEST_0_AMT' => '4489.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_NOTIFYURL' => '{SHOP_URL}index.php?cl=oepaypalipnhandler&fnc=handleRequest&shp={SHOP_ID}',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Bestellnummer 1',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Bestellnummer 1',
|
||||
'BUTTONSOURCE' => '{BN_ID_SHORTCUT}',
|
||||
'METHOD' => 'DoExpressCheckoutPayment',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,164 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: netto
|
||||
* Price view mode: netto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
use OxidEsales\Eshop\Application\Model\PaymentGateway;
|
||||
|
||||
$data = array(
|
||||
'class' => PaymentGateway::class,
|
||||
'action' => 'doExpressCheckoutPayment',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 9001,
|
||||
'oxprice' => 100,
|
||||
'oxvat' => 19,
|
||||
'amount' => 33,
|
||||
'oxstock' => 50,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 9002,
|
||||
'oxprice' => 66,
|
||||
'oxvat' => 19,
|
||||
'amount' => 16,
|
||||
'oxstock' => 20,
|
||||
),
|
||||
),
|
||||
'discounts' => array(
|
||||
0 => array(
|
||||
'oxid' => 'shopdiscount5for9001',
|
||||
'oxaddsum' => 5,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxamount' => 0,
|
||||
'oxamountto' => 99999,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array(9001),
|
||||
),
|
||||
),
|
||||
'costs' => array(
|
||||
'wrapping' => array(
|
||||
0 => array(
|
||||
'oxtype' => 'WRAP',
|
||||
'oxname' => 'testWrap9001',
|
||||
'oxprice' => 9,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array(9001)
|
||||
),
|
||||
),
|
||||
'delivery' => array(
|
||||
0 => array(
|
||||
'oxtitle' => '6_abs_del',
|
||||
'oxactive' => 1,
|
||||
'oxaddsum' => 6,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxdeltype' => 'p',
|
||||
'oxfinalize' => 1,
|
||||
'oxparamend' => 99999
|
||||
),
|
||||
),
|
||||
'payment' => array(
|
||||
0 => array(
|
||||
'oxtitle' => '1 abs payment',
|
||||
'oxaddsum' => 1,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxfromamount' => 0,
|
||||
'oxtoamount' => 1000000,
|
||||
'oxchecked' => 1,
|
||||
'oxarticles' => array(9001, 9002),
|
||||
),
|
||||
),
|
||||
'voucherserie' => array(
|
||||
0 => array(
|
||||
'oxserienr' => 'abs_4_voucher_serie',
|
||||
'oxdiscount' => 6.00,
|
||||
'oxdiscounttype' => 'absolute',
|
||||
'oxallowsameseries' => 1,
|
||||
'oxallowotherseries' => 1,
|
||||
'oxallowuseanother' => 1,
|
||||
'oxshopincl' => 1,
|
||||
'voucher_count' => 1
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser1',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword2',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature3',
|
||||
'sOEPayPalTransactionMode' => 'Automatic',
|
||||
'blShowNetPrice' => true,
|
||||
'OEPayPalDisableIPN' => false,
|
||||
),
|
||||
'session' => ['oepaypal' => 2],
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword2',
|
||||
'USER' => 'testUser1',
|
||||
'SIGNATURE' => 'testSignature3',
|
||||
'TOKEN' => '',
|
||||
'PAYERID' => '',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'PAYMENTREQUEST_0_AMT' => '4456.33',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_NOTIFYURL' => '{SHOP_URL}index.php?cl=oepaypalipnhandler&fnc=handleRequest&shp={SHOP_ID}',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Bestellnummer 1',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Bestellnummer 1',
|
||||
'BUTTONSOURCE' => '{BN_ID_SHORTCUT}',
|
||||
'METHOD' => 'DoExpressCheckoutPayment',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,110 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: bruto
|
||||
* Price view mode: brutto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
use OxidEsales\Eshop\Application\Model\PaymentGateway;
|
||||
|
||||
$data = array(
|
||||
'class' => PaymentGateway::class,
|
||||
'action' => 'doExpressCheckoutPayment',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 9001,
|
||||
'oxprice' => 100,
|
||||
'oxvat' => 19,
|
||||
'amount' => 33,
|
||||
'oxstock' => 33,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 9002,
|
||||
'oxprice' => 66,
|
||||
'oxvat' => 19,
|
||||
'amount' => 16,
|
||||
'oxstock' => 50,
|
||||
),
|
||||
),
|
||||
'discounts' => array(),
|
||||
'costs' => array(),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
'sOEPayPalEmptyStockLevel' => 10,
|
||||
'OEPayPalDisableIPN' => false,
|
||||
),
|
||||
'session' => ['oepaypal' => 2],
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'TOKEN' => '',
|
||||
'PAYERID' => '',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'PAYMENTREQUEST_0_AMT' => '4356.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_NOTIFYURL' => '{SHOP_URL}index.php?cl=oepaypalipnhandler&fnc=handleRequest&shp={SHOP_ID}',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Bestellnummer 1',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Bestellnummer 1',
|
||||
'BUTTONSOURCE' => '{BN_ID_SHORTCUT}',
|
||||
'METHOD' => 'DoExpressCheckoutPayment',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,129 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: bruto
|
||||
* Price view mode: brutto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
use OxidEsales\Eshop\Application\Model\PaymentGateway;
|
||||
|
||||
$data = array(
|
||||
'class' => PaymentGateway::class,
|
||||
'action' => 'doExpressCheckoutPayment',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testUserLogged1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
),
|
||||
'user' => array(
|
||||
'oxactive' => 1,
|
||||
'oxusername' => 'testuser@email.com',
|
||||
'oxfname' => 'Name',
|
||||
'oxlname' => 'LName',
|
||||
'oxstreet' => 'Street',
|
||||
'oxstreetnr' => 'StreetNr',
|
||||
'oxcity' => 'City',
|
||||
'oxzip' => 'ZipCode',
|
||||
'oxfon' => 'PhoneNr',
|
||||
'oxcountryid' => '8f241f11096877ac0.98748826', // United States
|
||||
'oxstateid' => 'IL', // Illinois
|
||||
'address' => array(
|
||||
'oxid' => 'TestUserAddressId',
|
||||
'oxfname' => 'AddressName',
|
||||
'oxlname' => 'AddressLName',
|
||||
'oxstreet' => 'AddressStreet',
|
||||
'oxstreetnr' => 'AddressStreetNr',
|
||||
'oxcity' => 'AddressCity',
|
||||
'oxzip' => 'AddressZipCode',
|
||||
'oxfon' => 'AddressPhoneNr',
|
||||
'oxcountryid' => 'a7c40f6323c4bfb36.59919433', // Italy
|
||||
),
|
||||
),
|
||||
'discounts' => array(),
|
||||
'costs' => array(),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
'sOEPayPalEmptyStockLevel' => 10,
|
||||
'OEPayPalDisableIPN' => false,
|
||||
),
|
||||
'session' => array(
|
||||
'deladrid' => 'TestUserAddressId',
|
||||
'oepaypal' => 2,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'TOKEN' => '',
|
||||
'PAYERID' => '',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'PAYMENTREQUEST_0_AMT' => '27.27',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_NOTIFYURL' => '{SHOP_URL}index.php?cl=oepaypalipnhandler&fnc=handleRequest&shp={SHOP_ID}',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Bestellnummer 1',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Bestellnummer 1',
|
||||
'BUTTONSOURCE' => '{BN_ID_SHORTCUT}',
|
||||
'METHOD' => 'DoExpressCheckoutPayment',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'AddressName AddressLName',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'AddressStreet AddressStreetNr',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'AddressCity',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => 'AddressZipCode',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => 'AddressPhoneNr',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'IT',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,78 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: bruto
|
||||
* Price view mode: brutto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'getExpressCheckoutDetails',
|
||||
'articles' => array(),
|
||||
'discounts' => array(),
|
||||
'session' => array(
|
||||
'oepaypal-token' => 'super_secure_token_f24b24a32df3a9'
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
),
|
||||
'costs' => array(),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'TOKEN' => 'super_secure_token_f24b24a32df3a9',
|
||||
'METHOD' => 'GetExpressCheckoutDetails',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,124 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: brut
|
||||
* Price view mode: net
|
||||
*
|
||||
* In costs there is wrapping.
|
||||
*/
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => '_testId1',
|
||||
'oxprice' => 119,
|
||||
'oxvat' => 19,
|
||||
'amount' => 10,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => '_testId2',
|
||||
'oxprice' => 11.9,
|
||||
'oxvat' => 19,
|
||||
'amount' => 100,
|
||||
),
|
||||
),
|
||||
'costs' => array(
|
||||
'wrapping' => array(
|
||||
0 => array(
|
||||
'oxtype' => 'WRAP',
|
||||
'oxname' => 'testWrap9001',
|
||||
'oxprice' => 11.9,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array('_testId1')
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
'sOEPayPalTransactionMode' => 'Authorization',
|
||||
'blSeoMode' => false,
|
||||
'blShowNetPrice' => true,
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
|
||||
'CALLBACK' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=processCallBack',
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_TAXAMT' => '399.00',
|
||||
'PAYMENTREQUEST_0_AMT' => '2499.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '2100.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 2.499,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 2.499,00 EUR',
|
||||
'MAXAMT' => '2530.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '100.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '10',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=_testId1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '100',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=_testId2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME2' => 'Geschenkverpackung',
|
||||
'L_PAYMENTREQUEST_0_AMT2' => '100.00',
|
||||
'L_PAYMENTREQUEST_0_QTY2' => '1',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,124 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: brut
|
||||
* Price view mode: net
|
||||
*
|
||||
* In costs there is voucher.
|
||||
*/
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => '_testId1',
|
||||
'oxprice' => 119,
|
||||
'oxvat' => 19,
|
||||
'amount' => 10,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => '_testId2',
|
||||
'oxprice' => 11.9,
|
||||
'oxvat' => 19,
|
||||
'amount' => 100,
|
||||
),
|
||||
),
|
||||
'costs' => array(
|
||||
'voucherserie' => array(
|
||||
0 => array(
|
||||
'oxserienr' => 'abs_4_voucher_serie',
|
||||
'oxdiscount' => 1,
|
||||
'oxdiscounttype' => 'absolute',
|
||||
'oxallowsameseries' => 1,
|
||||
'oxallowotherseries' => 1,
|
||||
'oxallowuseanother' => 1,
|
||||
'oxshopincl' => 1,
|
||||
'voucher_count' => 1
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
'sOEPayPalTransactionMode' => 'Authorization',
|
||||
'blSeoMode' => false,
|
||||
'blShowNetPrice' => true,
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
|
||||
'CALLBACK' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=processCallBack',
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_TAXAMT' => '379.81',
|
||||
'PAYMENTREQUEST_0_AMT' => '2378.81',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '2000.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '-1.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 2.378,81 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 2.378,81 EUR',
|
||||
'MAXAMT' => '2410.81',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '100.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '10',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=_testId1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '100',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=_testId2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,121 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: brut
|
||||
* Price view mode: net
|
||||
*
|
||||
* Case with discount.
|
||||
*/
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => '_testId1',
|
||||
'oxprice' => 119,
|
||||
'oxvat' => 19,
|
||||
'amount' => 1,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => '_testId2',
|
||||
'oxprice' => 11.9,
|
||||
'oxvat' => 19,
|
||||
'amount' => 1,
|
||||
),
|
||||
),
|
||||
'discounts' => array(
|
||||
0 => array(
|
||||
'oxid' => '_discountitm',
|
||||
'oxaddsum' => 10,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxamount' => 1,
|
||||
'oxamountto' => 99999,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array('_testId1'),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
'sOEPayPalTransactionMode' => 'Authorization',
|
||||
'blSeoMode' => false,
|
||||
'blShowNetPrice' => true,
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
|
||||
'CALLBACK' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=processCallBack',
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_TAXAMT' => '19.00',
|
||||
'PAYMENTREQUEST_0_AMT' => '119.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '100.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 119,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 119,00 EUR',
|
||||
'MAXAMT' => '150.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '90.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '1',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=_testId1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '1',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=_testId2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,124 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testAddItems1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 0,
|
||||
'amount' => 1,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'testAddItems2',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 0,
|
||||
'amount' => 1,
|
||||
),
|
||||
),
|
||||
'costs' => array(
|
||||
'wrapping' => array(
|
||||
0 => array(
|
||||
'oxtype' => 'WRAP',
|
||||
'oxname' => 'testWrap9001',
|
||||
'oxprice' => 0.50,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array('testAddItems1', 'testAddItems2')
|
||||
),
|
||||
1 => array(
|
||||
'oxtype' => 'CARD',
|
||||
'oxname' => 'testCard9001',
|
||||
'oxprice' => 0.30,
|
||||
'oxactive' => 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'CALLBACK' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=processCallBack',
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_AMT' => '21.30',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '21.30',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 21,30 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 21,30 EUR',
|
||||
'MAXAMT' => '52.30',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '1',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testAddItems1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '1',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=testAddItems2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME2' => 'Geschenkverpackung',
|
||||
'L_PAYMENTREQUEST_0_AMT2' => '1.00',
|
||||
'L_PAYMENTREQUEST_0_QTY2' => '1',
|
||||
'L_PAYMENTREQUEST_0_NAME3' => 'Grußkarte',
|
||||
'L_PAYMENTREQUEST_0_AMT3' => '0.30',
|
||||
'L_PAYMENTREQUEST_0_QTY3' => '1',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,148 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
/**
|
||||
* Price enter mode: netto
|
||||
* Price view mode: netto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'test9001',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 19,
|
||||
'oxartnum' => '9001',
|
||||
'oxtitle' => 'Test Title 1',
|
||||
'amount' => 2,
|
||||
'oxstock' => 50,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'test9002',
|
||||
'oxprice' => 20,
|
||||
'oxvat' => 19,
|
||||
'oxartnum' => '9002',
|
||||
'oxtitle' => 'Test Title 2',
|
||||
'amount' => 1,
|
||||
'oxstock' => 50,
|
||||
),
|
||||
2 => array(
|
||||
'oxid' => 'test9003',
|
||||
'oxprice' => 30,
|
||||
'oxvat' => 19,
|
||||
'oxartnum' => '9003',
|
||||
'oxtitle' => 'Test Title 3',
|
||||
'amount' => 1,
|
||||
'oxstock' => 50,
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => true,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'CALLBACK' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=processCallBack',
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_AMT' => '70.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '70.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 70,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 70,00 EUR',
|
||||
'MAXAMT' => '101.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => 'Test Title 1',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '2.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}Test-Title-1.html',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '9001',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => 'Test Title 2',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '20.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '1.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}Test-Title-2.html',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '9002',
|
||||
'L_PAYMENTREQUEST_0_NAME2' => 'Test Title 3',
|
||||
'L_PAYMENTREQUEST_0_AMT2' => '30.00',
|
||||
'L_PAYMENTREQUEST_0_QTY2' => '1.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL2' => '{SHOP_URL}Test-Title-3.html',
|
||||
'L_PAYMENTREQUEST_0_NUMBER2' => '9003',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,102 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 9001,
|
||||
'oxprice' => 100,
|
||||
'oxvat' => 19,
|
||||
'amount' => 33,
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalBrandName' => 'ShopBrandName',
|
||||
'sOEPayPalBorderColor' => 'testColor',
|
||||
'dMaxPayPalDeliveryAmount' => 50,
|
||||
'sOEPayPalLogoImageOption' => 'customLogo',
|
||||
'shopLogo' => 'shouldNotBeUsed.ico',
|
||||
'sOEPayPalCustomShopLogoImage' => 'favicon.ico',
|
||||
'blOEPayPalSendToPayPal' => false,
|
||||
'blOEPayPalSandboxMode' => true,
|
||||
'sOEPayPalUsername' => 'tesUser',
|
||||
'sOEPayPalPassword' => 'tesPassword',
|
||||
'sOEPayPalSignature' => 'tesSignature',
|
||||
'sOEPayPalSandboxUsername' => 'testSandboxUser',
|
||||
'sOEPayPalSandboxPassword' => 'testSandboxPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSandboxSignature',
|
||||
'sOEPayPalTransactionMode' => 'Sales',
|
||||
'blOEPayPalGuestBuyRole' => true,
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => false,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testSandboxPassword',
|
||||
'USER' => 'testSandboxUser',
|
||||
'SIGNATURE' => 'testSandboxSignature',
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Sole',
|
||||
'BRANDNAME' => 'ShopBrandName',
|
||||
'CARTBORDERCOLOR' => 'testColor',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'LOGOIMG' => '{SHOP_URL}out/azure/img/favicon.ico',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sales',
|
||||
'CALLBACK' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=processCallBack',
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_AMT' => '3300.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '3300.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei ShopBrandName in Höhe von 3.300,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei ShopBrandName in Höhe von 3.300,00 EUR',
|
||||
'MAXAMT' => '3351.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => 'Gesamtsumme:',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '3300.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '1',
|
||||
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,101 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 9001,
|
||||
'oxprice' => 100,
|
||||
'oxvat' => 19,
|
||||
'amount' => 33,
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalBrandName' => 'ShopBrandName',
|
||||
'sOEPayPalBorderColor' => 'testColor',
|
||||
'dMaxPayPalDeliveryAmount' => 50,
|
||||
'sOEPayPalLogoImageOption' => 'shopLogo',
|
||||
'sShopLogo' => 'favicon.ico',
|
||||
'sOEPayPalCustomShopLogoImage' => 'shouldNotBeUsed.ico',
|
||||
'blOEPayPalSendToPayPal' => true,
|
||||
'blOEPayPalSandboxMode' => false,
|
||||
'sOEPayPalUsername' => 'testUser',
|
||||
'sOEPayPalPassword' => 'testPassword',
|
||||
'sOEPayPalSignature' => 'testSignature',
|
||||
'sOEPayPalSandboxUsername' => 'testSandboxUser',
|
||||
'sOEPayPalSandboxPassword' => 'testSandboxPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSandboxSignature',
|
||||
'sOEPayPalTransactionMode' => 'Authorization',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => false,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'ShopBrandName',
|
||||
'CARTBORDERCOLOR' => 'testColor',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'LOGOIMG' => '{SHOP_URL}out/azure/img/favicon.ico',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
|
||||
'CALLBACK' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=processCallBack',
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_AMT' => '3300.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '3300.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei ShopBrandName in Höhe von 3.300,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei ShopBrandName in Höhe von 3.300,00 EUR',
|
||||
'MAXAMT' => '3351.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => 'Gesamtsumme:',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '3300.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '1',
|
||||
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,117 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testVouchers1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'testVouchers2',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 4,
|
||||
),
|
||||
),
|
||||
'user' => false,
|
||||
'costs' => array(
|
||||
'delivery' => array(
|
||||
'oxdeliveryset' => array(
|
||||
'createOnly' => true,
|
||||
'oxid' => 'mobileShippingSet',
|
||||
'oxactive' => 1,
|
||||
'oxtitle' => 'TestDeliverySet',
|
||||
),
|
||||
0 => array(
|
||||
'oxactive' => 1,
|
||||
'oxaddsum' => 55,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxdeltype' => 'p',
|
||||
'oxfinalize' => 1,
|
||||
'oxparamend' => 99999,
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalMECDefaultShippingId' => 'mobileShippingSet',
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'serverParams' => array(
|
||||
'HTTP_USER_AGENT' => 'iphone',
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'CALLBACK' => null,
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_AMT' => '125.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '70.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '55.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => 'TestDeliverySet',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '55.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 125,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 125,00 EUR',
|
||||
'MAXAMT' => '126.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testVouchers1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '4',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=testVouchers2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,116 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testVouchers1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'testVouchers2',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 4,
|
||||
),
|
||||
),
|
||||
'user' => false,
|
||||
'costs' => array(
|
||||
'delivery' => array(
|
||||
'oxdeliveryset' => array(
|
||||
'createOnly' => true,
|
||||
'oxid' => 'mobileShippingSet',
|
||||
'oxactive' => 1,
|
||||
'oxtitle' => 'TestDeliverySet',
|
||||
),
|
||||
0 => array(
|
||||
'oxactive' => 1,
|
||||
'oxaddsum' => 55,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxdeltype' => 'p',
|
||||
'oxfinalize' => 1,
|
||||
'oxparamend' => 99999,
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'serverParams' => array(
|
||||
'HTTP_USER_AGENT' => 'iphone',
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'CALLBACK' => null,
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_AMT' => '70.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '70.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 70,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 70,00 EUR',
|
||||
'MAXAMT' => '71.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testVouchers1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '4',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=testVouchers2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,112 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testDiscountsAbs1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'testDiscountsAbs2',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 4,
|
||||
),
|
||||
),
|
||||
'discounts' => array(
|
||||
0 => array(
|
||||
'oxid' => 'discountForTestDiscountsAbs1',
|
||||
'oxaddsum' => 5,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxamount' => 0,
|
||||
'oxamountto' => 99999,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array('testDiscountsAbs1'),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'CALLBACK' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=processCallBack',
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_AMT' => '55.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '55.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 55,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 55,00 EUR',
|
||||
'MAXAMT' => '86.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '5.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testDiscountsAbs1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '4.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=testDiscountsAbs2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,111 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testDiscountsBasket1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'testDiscountsBasket2',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 4,
|
||||
),
|
||||
),
|
||||
'discounts' => array(
|
||||
0 => array(
|
||||
'oxid' => 'discountForTestDiscountsBasket1',
|
||||
'oxaddsum' => 5,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxamount' => 1,
|
||||
'oxprice' => 0,
|
||||
'oxactive' => 1,
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'CALLBACK' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=processCallBack',
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_AMT' => '65.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '70.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '-5.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 65,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 65,00 EUR',
|
||||
'MAXAMT' => '101.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testDiscountsBasket1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '4.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=testDiscountsBasket2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,112 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testDiscountsPercent1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'testDiscountsPercent2',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 4,
|
||||
),
|
||||
),
|
||||
'discounts' => array(
|
||||
0 => array(
|
||||
'oxid' => 'discountForTestDiscountsPercent1',
|
||||
'oxaddsum' => 50,
|
||||
'oxaddsumtype' => '%',
|
||||
'oxamount' => 0,
|
||||
'oxamountto' => 99999,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array('testDiscountsPercent1'),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'CALLBACK' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=processCallBack',
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_AMT' => '55.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '55.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 55,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 55,00 EUR',
|
||||
'MAXAMT' => '86.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '5.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testDiscountsPercent1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '4.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=testDiscountsPercent2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,113 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testUserLogged1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
),
|
||||
'groups' => array(
|
||||
0 => array(
|
||||
'oxid' => 'UserLoggedTestGroup',
|
||||
'oxactive' => 1,
|
||||
'oxtitle' => 'checkoutTestGroup',
|
||||
'oxobject2group' => array('TestLoggedUser', 'oxidpaypal'),
|
||||
),
|
||||
),
|
||||
'user' => array(
|
||||
'oxid' => 'TestLoggedUser',
|
||||
'oxactive' => 1,
|
||||
'oxusername' => 'testuser@email.com',
|
||||
'oxfname' => 'Name',
|
||||
'oxlname' => 'LName',
|
||||
'oxstreet' => 'Street',
|
||||
'oxstreetnr' => 'StreetNr',
|
||||
'oxcity' => 'City',
|
||||
'oxzip' => 'ZipCode',
|
||||
'oxfon' => 'PhoneNr',
|
||||
'oxcountryid' => '8f241f11096877ac0.98748826', // United States
|
||||
'oxstateid' => 'IL', // Illinois
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'CALLBACK' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=processCallBack',
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_AMT' => '27.27',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '27.27',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 27,27 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 27,27 EUR',
|
||||
'MAXAMT' => '58.27',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '9.09',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testUserLogged1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'EMAIL' => 'testuser@email.com',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'Name LName',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Street StreetNr',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => 'ZipCode',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => 'PhoneNr',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'US',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTATE' => 'IL',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,126 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testUserLogged1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
),
|
||||
'groups' => array(
|
||||
0 => array(
|
||||
'oxid' => 'UserLoggedTestGroup',
|
||||
'oxactive' => 1,
|
||||
'oxtitle' => 'checkoutTestGroup',
|
||||
'oxobject2group' => array('TestLoggedUser', 'oxidpaypal'),
|
||||
),
|
||||
),
|
||||
'user' => array(
|
||||
'oxid' => 'TestLoggedUser',
|
||||
'oxactive' => 1,
|
||||
'oxusername' => 'testuser@email.com',
|
||||
'oxfname' => 'Name',
|
||||
'oxlname' => 'LName',
|
||||
'oxstreet' => 'Street',
|
||||
'oxstreetnr' => 'StreetNr',
|
||||
'oxcity' => 'City',
|
||||
'oxzip' => 'ZipCode',
|
||||
'oxfon' => 'PhoneNr',
|
||||
'oxcountryid' => '8f241f11096877ac0.98748826', // United States
|
||||
'oxstateid' => 'IL', // Illinois
|
||||
'address' => array(
|
||||
'oxid' => 'TestUserAddressId',
|
||||
'oxfname' => 'AddressName',
|
||||
'oxlname' => 'AddressLName',
|
||||
'oxstreet' => 'AddressStreet',
|
||||
'oxstreetnr' => 'AddressStreetNr',
|
||||
'oxcity' => 'AddressCity',
|
||||
'oxzip' => 'AddressZipCode',
|
||||
'oxfon' => 'AddressPhoneNr',
|
||||
'oxcountryid' => 'a7c40f6323c4bfb36.59919433', // Italy
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'session' => array(
|
||||
'deladrid' => 'TestUserAddressId',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'CALLBACK' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=processCallBack',
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_AMT' => '27.27',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '27.27',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 27,27 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 27,27 EUR',
|
||||
'MAXAMT' => '58.27',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '9.09',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testUserLogged1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'EMAIL' => 'testuser@email.com',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'AddressName AddressLName',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'AddressStreet AddressStreetNr',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'AddressCity',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => 'AddressZipCode',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => 'AddressPhoneNr',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'IT',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,84 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testUserNotLogged1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
),
|
||||
'user' => false,
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'CALLBACK' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=processCallBack',
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_AMT' => '30.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '30.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 30,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 30,00 EUR',
|
||||
'MAXAMT' => '61.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testUserNotLogged1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,115 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\ExpressCheckoutDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testVouchers1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'testVouchers2',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 4,
|
||||
),
|
||||
),
|
||||
'costs' => array(
|
||||
'voucherserie' => array(
|
||||
0 => array(
|
||||
'oxserienr' => 'voucherForShop',
|
||||
'oxdiscount' => 90.00,
|
||||
'oxdiscounttype' => 'absolute',
|
||||
'oxallowsameseries' => 1,
|
||||
'oxallowotherseries' => 1,
|
||||
'oxallowuseanother' => 1,
|
||||
'oxshopincl' => 1,
|
||||
'voucher_count' => 1
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=basket',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'CALLBACK' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalexpresscheckoutdispatcher&fnc=processCallBack',
|
||||
'CALLBACKTIMEOUT' => '6',
|
||||
'NOSHIPPING' => '2',
|
||||
'PAYMENTREQUEST_0_AMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '70.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '-70.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 0,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 0,00 EUR',
|
||||
'MAXAMT' => '101.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testVouchers1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '4',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=testVouchers2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of OXID eSales PayPal module.
|
||||
*
|
||||
* OXID eSales PayPal module 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OXID eSales PayPal module 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 OXID eSales PayPal module. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @link http://www.oxid-esales.com
|
||||
* @copyright (C) OXID eSales AG 2003-2013
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: netto / brutto
|
||||
* Price view mode: netto / brutto
|
||||
* Product count: count of used products
|
||||
* VAT info: count of used vat's (list)
|
||||
* Currency rate: 1.0 (change if needed)
|
||||
* Discounts: count
|
||||
* 1. shop / basket; abs / %; bargain;
|
||||
* 2. ...
|
||||
* ...
|
||||
* Vouchers: count
|
||||
* 1. voucher rule
|
||||
* 2 ...
|
||||
* ...
|
||||
* Wrapping: + / -
|
||||
* Gift cart: + / -;
|
||||
* Costs VAT caclulation rule: max / proportional
|
||||
* Costs:
|
||||
* 1. Payment + / -
|
||||
* 2. Delivery + / -
|
||||
* 3. TS + / -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
$aData = array(
|
||||
// Articles
|
||||
'articles' => array (
|
||||
0 => array (
|
||||
// oxarticles db fields
|
||||
'oxid' => 1001,
|
||||
'oxprice' => 0.00,
|
||||
'oxvat' => 0,
|
||||
// Amount in basket
|
||||
'amount' => 1,
|
||||
'scaleprices' => array(
|
||||
'oxaddabs' => 0.00,
|
||||
'oxamount' => 1,
|
||||
'oxamountto' => 3,
|
||||
'oxartid' => 1001
|
||||
),
|
||||
),
|
||||
1 => array (
|
||||
|
||||
),
|
||||
),
|
||||
// Categories
|
||||
'categories' => array (
|
||||
0 => array (
|
||||
'oxid' => '30e44ab8593023055.23928895',
|
||||
'oxactive' => 1,
|
||||
'oxtitle' => 'Bar-Equipment',
|
||||
'articles' => ( 1126 )
|
||||
),
|
||||
),
|
||||
// User
|
||||
'user' => array(
|
||||
'oxactive' => 1,
|
||||
'oxusername' => 'basketUser',
|
||||
// country id, for example this is United States, make sure country with specified ID is active
|
||||
'oxcountryid' => '8f241f11096877ac0.98748826',
|
||||
'address' => array(
|
||||
'oxfname' => 'user address name'
|
||||
)
|
||||
),
|
||||
// user will not be created. If not set - default user parameters is used
|
||||
'user' => false,
|
||||
// Group
|
||||
'group' => array (
|
||||
0 => array (
|
||||
'oxid' => 'oxidpricea',
|
||||
'oxactive' => 1,
|
||||
'oxtitle' => 'Price A',
|
||||
'oxobject2group' => array (
|
||||
'oxobjectid' => array( 1001, 'basketUser' ),
|
||||
),
|
||||
),
|
||||
1 => array (
|
||||
'oxid' => 'oxidpriceb',
|
||||
'oxactive' => 1,
|
||||
'oxtitle' => 'Price B',
|
||||
'oxobject2group' => array (
|
||||
'oxobjectid' => array( '30e44ab8593023055.23928895' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Discounts
|
||||
'discounts' => array (
|
||||
// oxdiscount DB fields
|
||||
0 => array (
|
||||
// ID needed for expectation later on, specify meaningful name
|
||||
'oxid' => 'absolutediscount',
|
||||
'oxaddsum' => 1,
|
||||
'oxaddsumtype' => '%',
|
||||
'oxamount' => 1,
|
||||
'oxamountto' => 99999,
|
||||
'oxactive' => 1,
|
||||
'...' => '',
|
||||
// If for article, specify here
|
||||
'oxarticles' => array ( 9001 ),
|
||||
),
|
||||
1 => array (
|
||||
|
||||
),
|
||||
),
|
||||
// Additional costs
|
||||
'costs' => array(
|
||||
// oxwrapping db fields
|
||||
'wrapping' => array(
|
||||
// Wrapping
|
||||
0 => array(
|
||||
'oxtype' => 'WRAP',
|
||||
'oxname' => 'testWrap9001',
|
||||
'oxprice' => 9,
|
||||
'oxactive' => 1,
|
||||
'...' => '',
|
||||
// If for article, specify here
|
||||
'oxarticles' => array( 9001 )
|
||||
),
|
||||
// Giftcard
|
||||
1 => array(
|
||||
'oxtype' => 'CARD',
|
||||
'oxname' => 'testCard',
|
||||
'oxprice' => 0.30,
|
||||
'oxactive' => 1,
|
||||
),
|
||||
),
|
||||
// Delivery
|
||||
'delivery' => array(
|
||||
0 => array(
|
||||
// oxdelivery DB fields
|
||||
'oxactive' => 1,
|
||||
'oxaddsum' => 1,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxdeltype' => 'p',
|
||||
'oxfinalize' => 1,
|
||||
'oxparamend' => 99999,
|
||||
'...' => ''
|
||||
),
|
||||
),
|
||||
// Payment
|
||||
'payment' => array(
|
||||
0 => array(
|
||||
// oxpayments DB fields
|
||||
'oxaddsum' => 1,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxfromamount' => 0,
|
||||
'oxtoamount' => 1000000,
|
||||
'oxchecked' => 1,
|
||||
'...' => ''
|
||||
),
|
||||
),
|
||||
// VOUCHERS
|
||||
'voucherserie' => array (
|
||||
0 => array (
|
||||
// oxvoucherseries DB fields
|
||||
'oxdiscount' => 1.00,
|
||||
'oxdiscounttype' => 'absolute',
|
||||
'oxallowsameseries' => 1,
|
||||
'oxallowotherseries' => 1,
|
||||
'oxallowuseanother' => 1,
|
||||
'oxshopincl' => 1,
|
||||
'...' => '',
|
||||
// voucher of this voucherserie count
|
||||
'voucher_count' => 1
|
||||
),
|
||||
),
|
||||
),
|
||||
'options' => array (
|
||||
'config' => array(
|
||||
'configParam' => true,
|
||||
'configParam2' => false
|
||||
),
|
||||
'activeCurrencyRate' => 1.47,
|
||||
),
|
||||
// TEST EXPECTATIONS
|
||||
'expected' => array (
|
||||
'request' => '',
|
||||
'response' => '',
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,110 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: netto
|
||||
* Price view mode: netto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
use OxidEsales\Eshop\Application\Model\PaymentGateway;
|
||||
|
||||
$data = array(
|
||||
'class' => PaymentGateway::class,
|
||||
'action' => 'doExpressCheckoutPayment',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 9001,
|
||||
'oxprice' => 100,
|
||||
'oxvat' => 19,
|
||||
'amount' => 33,
|
||||
'oxstock' => 50,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 9002,
|
||||
'oxprice' => 66,
|
||||
'oxvat' => 19,
|
||||
'amount' => 16,
|
||||
'oxstock' => 20,
|
||||
),
|
||||
),
|
||||
'discounts' => array(),
|
||||
'costs' => array(),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser4',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword5',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature6',
|
||||
'sOEPayPalTransactionMode' => 'Authorization',
|
||||
'blShowNetPrice' => true,
|
||||
'OEPayPalDisableIPN' => false,
|
||||
),
|
||||
'session' => ['oepaypal' => 1],
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword5',
|
||||
'USER' => 'testUser4',
|
||||
'SIGNATURE' => 'testSignature6',
|
||||
'TOKEN' => '',
|
||||
'PAYERID' => '',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
|
||||
'PAYMENTREQUEST_0_AMT' => '4355.82',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_NOTIFYURL' => '{SHOP_URL}index.php?cl=oepaypalipnhandler&fnc=handleRequest&shp={SHOP_ID}',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Bestellnummer 1',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Bestellnummer 1',
|
||||
'BUTTONSOURCE' => '{BN_ID}',
|
||||
'METHOD' => 'DoExpressCheckoutPayment',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,164 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: bruto
|
||||
* Price view mode: brutto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
use OxidEsales\Eshop\Application\Model\PaymentGateway;
|
||||
|
||||
$data = array(
|
||||
'class' => PaymentGateway::class,
|
||||
'action' => 'doExpressCheckoutPayment',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 9001,
|
||||
'oxprice' => 100,
|
||||
'oxvat' => 19,
|
||||
'amount' => 33,
|
||||
'oxstock' => 33,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 9002,
|
||||
'oxprice' => 66,
|
||||
'oxvat' => 19,
|
||||
'amount' => 16,
|
||||
'oxstock' => 50,
|
||||
),
|
||||
),
|
||||
'discounts' => array(
|
||||
0 => array(
|
||||
'oxid' => 'shopdiscount5for9001',
|
||||
'oxaddsum' => 5,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxamount' => 0,
|
||||
'oxamountto' => 99999,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array(9001),
|
||||
),
|
||||
),
|
||||
'costs' => array(
|
||||
'wrapping' => array(
|
||||
0 => array(
|
||||
'oxtype' => 'WRAP',
|
||||
'oxname' => 'testWrap9001',
|
||||
'oxprice' => 9,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array(9001)
|
||||
),
|
||||
),
|
||||
'delivery' => array(
|
||||
0 => array(
|
||||
'oxtitle' => '6_abs_del',
|
||||
'oxactive' => 1,
|
||||
'oxaddsum' => 6,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxdeltype' => 'p',
|
||||
'oxfinalize' => 1,
|
||||
'oxparamend' => 99999
|
||||
),
|
||||
),
|
||||
'payment' => array(
|
||||
0 => array(
|
||||
'oxtitle' => '1 abs payment',
|
||||
'oxaddsum' => 1,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxfromamount' => 0,
|
||||
'oxtoamount' => 1000000,
|
||||
'oxchecked' => 1,
|
||||
'oxarticles' => array(9001, 9002),
|
||||
),
|
||||
),
|
||||
'voucherserie' => array(
|
||||
0 => array(
|
||||
'oxserienr' => 'abs_4_voucher_serie',
|
||||
'oxdiscount' => 6.00,
|
||||
'oxdiscounttype' => 'absolute',
|
||||
'oxallowsameseries' => 1,
|
||||
'oxallowotherseries' => 1,
|
||||
'oxallowuseanother' => 1,
|
||||
'oxshopincl' => 1,
|
||||
'voucher_count' => 1
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
'sOEPayPalTransactionMode' => 'Automatic',
|
||||
'sOEPayPalEmptyStockLevel' => 1,
|
||||
'OEPayPalDisableIPN' => false,
|
||||
),
|
||||
'session' => ['oepaypal' => 1],
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'TOKEN' => '',
|
||||
'PAYERID' => '',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
|
||||
'PAYMENTREQUEST_0_AMT' => '4489.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_NOTIFYURL' => '{SHOP_URL}index.php?cl=oepaypalipnhandler&fnc=handleRequest&shp={SHOP_ID}',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Bestellnummer 1',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Bestellnummer 1',
|
||||
'BUTTONSOURCE' => '{BN_ID}',
|
||||
'METHOD' => 'DoExpressCheckoutPayment',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,164 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: netto
|
||||
* Price view mode: netto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
use OxidEsales\Eshop\Application\Model\PaymentGateway;
|
||||
|
||||
$data = array(
|
||||
'class' => PaymentGateway::class,
|
||||
'action' => 'doExpressCheckoutPayment',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 9001,
|
||||
'oxprice' => 100,
|
||||
'oxvat' => 19,
|
||||
'amount' => 33,
|
||||
'oxstock' => 50,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 9002,
|
||||
'oxprice' => 66,
|
||||
'oxvat' => 19,
|
||||
'amount' => 16,
|
||||
'oxstock' => 20,
|
||||
),
|
||||
),
|
||||
'discounts' => array(
|
||||
0 => array(
|
||||
'oxid' => 'shopdiscount5for9001',
|
||||
'oxaddsum' => 5,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxamount' => 0,
|
||||
'oxamountto' => 99999,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array(9001),
|
||||
),
|
||||
),
|
||||
'costs' => array(
|
||||
'wrapping' => array(
|
||||
0 => array(
|
||||
'oxtype' => 'WRAP',
|
||||
'oxname' => 'testWrap9001',
|
||||
'oxprice' => 9,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array(9001)
|
||||
),
|
||||
),
|
||||
'delivery' => array(
|
||||
0 => array(
|
||||
'oxtitle' => '6_abs_del',
|
||||
'oxactive' => 1,
|
||||
'oxaddsum' => 6,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxdeltype' => 'p',
|
||||
'oxfinalize' => 1,
|
||||
'oxparamend' => 99999
|
||||
),
|
||||
),
|
||||
'payment' => array(
|
||||
0 => array(
|
||||
'oxtitle' => '1 abs payment',
|
||||
'oxaddsum' => 1,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxfromamount' => 0,
|
||||
'oxtoamount' => 1000000,
|
||||
'oxchecked' => 1,
|
||||
'oxarticles' => array(9001, 9002),
|
||||
),
|
||||
),
|
||||
'voucherserie' => array(
|
||||
0 => array(
|
||||
'oxserienr' => 'abs_4_voucher_serie',
|
||||
'oxdiscount' => 6.00,
|
||||
'oxdiscounttype' => 'absolute',
|
||||
'oxallowsameseries' => 1,
|
||||
'oxallowotherseries' => 1,
|
||||
'oxallowuseanother' => 1,
|
||||
'oxshopincl' => 1,
|
||||
'voucher_count' => 1
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser1',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword2',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature3',
|
||||
'sOEPayPalTransactionMode' => 'Automatic',
|
||||
'blShowNetPrice' => true,
|
||||
'OEPayPalDisableIPN' => false,
|
||||
),
|
||||
'session' => ['oepaypal' => 1],
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword2',
|
||||
'USER' => 'testUser1',
|
||||
'SIGNATURE' => 'testSignature3',
|
||||
'TOKEN' => '',
|
||||
'PAYERID' => '',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'PAYMENTREQUEST_0_AMT' => '4456.33',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_NOTIFYURL' => '{SHOP_URL}index.php?cl=oepaypalipnhandler&fnc=handleRequest&shp={SHOP_ID}',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Bestellnummer 1',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Bestellnummer 1',
|
||||
'BUTTONSOURCE' => '{BN_ID}',
|
||||
'METHOD' => 'DoExpressCheckoutPayment',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,110 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: bruto
|
||||
* Price view mode: brutto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
use OxidEsales\Eshop\Application\Model\PaymentGateway;
|
||||
|
||||
$data = array(
|
||||
'class' => PaymentGateway::class,
|
||||
'action' => 'doExpressCheckoutPayment',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 9001,
|
||||
'oxprice' => 100,
|
||||
'oxvat' => 19,
|
||||
'amount' => 33,
|
||||
'oxstock' => 33,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 9002,
|
||||
'oxprice' => 66,
|
||||
'oxvat' => 19,
|
||||
'amount' => 16,
|
||||
'oxstock' => 50,
|
||||
),
|
||||
),
|
||||
'discounts' => array(),
|
||||
'costs' => array(),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
'sOEPayPalEmptyStockLevel' => 10,
|
||||
'OEPayPalDisableIPN' => false,
|
||||
),
|
||||
'session' => ['oepaypal' => 1],
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'TOKEN' => '',
|
||||
'PAYERID' => '',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'PAYMENTREQUEST_0_AMT' => '4356.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_NOTIFYURL' => '{SHOP_URL}index.php?cl=oepaypalipnhandler&fnc=handleRequest&shp={SHOP_ID}',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Bestellnummer 1',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Bestellnummer 1',
|
||||
'BUTTONSOURCE' => '{BN_ID}',
|
||||
'METHOD' => 'DoExpressCheckoutPayment',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,129 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: bruto
|
||||
* Price view mode: brutto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
use OxidEsales\Eshop\Application\Model\PaymentGateway;
|
||||
|
||||
$data = array(
|
||||
'class' => PaymentGateway::class,
|
||||
'action' => 'doExpressCheckoutPayment',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testUserLogged1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
),
|
||||
'user' => array(
|
||||
'oxactive' => 1,
|
||||
'oxusername' => 'testuser@email.com',
|
||||
'oxfname' => 'Name',
|
||||
'oxlname' => 'LName',
|
||||
'oxstreet' => 'Street',
|
||||
'oxstreetnr' => 'StreetNr',
|
||||
'oxcity' => 'City',
|
||||
'oxzip' => 'ZipCode',
|
||||
'oxfon' => 'PhoneNr',
|
||||
'oxcountryid' => '8f241f11096877ac0.98748826', // United States
|
||||
'oxstateid' => 'IL', // Illinois
|
||||
'address' => array(
|
||||
'oxid' => 'TestUserAddressId',
|
||||
'oxfname' => 'AddressName',
|
||||
'oxlname' => 'AddressLName',
|
||||
'oxstreet' => 'AddressStreet',
|
||||
'oxstreetnr' => 'AddressStreetNr',
|
||||
'oxcity' => 'AddressCity',
|
||||
'oxzip' => 'AddressZipCode',
|
||||
'oxfon' => 'AddressPhoneNr',
|
||||
'oxcountryid' => 'a7c40f6323c4bfb36.59919433', // Italy
|
||||
),
|
||||
),
|
||||
'discounts' => array(),
|
||||
'costs' => array(),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
'sOEPayPalEmptyStockLevel' => 10,
|
||||
'OEPayPalDisableIPN' => false,
|
||||
),
|
||||
'session' => array(
|
||||
'deladrid' => 'TestUserAddressId',
|
||||
'oepaypal' => 1,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'TOKEN' => '',
|
||||
'PAYERID' => '',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'PAYMENTREQUEST_0_AMT' => '27.27',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_NOTIFYURL' => '{SHOP_URL}index.php?cl=oepaypalipnhandler&fnc=handleRequest&shp={SHOP_ID}',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Bestellnummer 1',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Bestellnummer 1',
|
||||
'BUTTONSOURCE' => '{BN_ID}',
|
||||
'METHOD' => 'DoExpressCheckoutPayment',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'AddressName AddressLName',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'AddressStreet AddressStreetNr',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'AddressCity',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => 'AddressZipCode',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => 'AddressPhoneNr',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'IT',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,128 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: bruto
|
||||
* Price view mode: brutto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
use OxidEsales\Eshop\Application\Model\PaymentGateway;
|
||||
|
||||
$data = array(
|
||||
'class' => PaymentGateway::class,
|
||||
'action' => 'doExpressCheckoutPayment',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testUserLogged1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
),
|
||||
'user' => array(
|
||||
'oxactive' => 1,
|
||||
'oxusername' => 'testuser@email.com',
|
||||
'oxfname' => 'Name',
|
||||
'oxlname' => 'LName',
|
||||
'oxstreet' => 'Street',
|
||||
'oxstreetnr' => 'StreetNr',
|
||||
'oxcity' => 'City',
|
||||
'oxzip' => 'ZipCode',
|
||||
'oxfon' => 'PhoneNr',
|
||||
'oxcountryid' => '8f241f11096877ac0.98748826', // United States
|
||||
'oxstateid' => 'IL', // Illinois
|
||||
'address' => array(
|
||||
'oxid' => 'TestUserAddressId',
|
||||
'oxfname' => 'AddressName',
|
||||
'oxlname' => 'AddressLName',
|
||||
'oxstreet' => 'AddressStreet',
|
||||
'oxstreetnr' => 'AddressStreetNr',
|
||||
'oxcity' => 'AddressCity',
|
||||
'oxzip' => 'AddressZipCode',
|
||||
'oxfon' => 'AddressPhoneNr',
|
||||
'oxcountryid' => 'a7c40f6323c4bfb36.59919433', // Italy
|
||||
),
|
||||
),
|
||||
'discounts' => array(),
|
||||
'costs' => array(),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
'sOEPayPalEmptyStockLevel' => 10,
|
||||
'OEPayPalDisableIPN' => 1
|
||||
),
|
||||
'session' => array(
|
||||
'deladrid' => 'TestUserAddressId',
|
||||
'oepaypal' => 1,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'TOKEN' => '',
|
||||
'PAYERID' => '',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'PAYMENTREQUEST_0_AMT' => '27.27',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Bestellnummer 1',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Bestellnummer 1',
|
||||
'BUTTONSOURCE' => '{BN_ID}',
|
||||
'METHOD' => 'DoExpressCheckoutPayment',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'AddressName AddressLName',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'AddressStreet AddressStreetNr',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'AddressCity',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => 'AddressZipCode',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => 'AddressPhoneNr',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'IT',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,78 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: bruto
|
||||
* Price view mode: brutto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'getExpressCheckoutDetails',
|
||||
'articles' => array(),
|
||||
'discounts' => array(),
|
||||
'session' => array(
|
||||
'oepaypal-token' => 'super_secure_token_f24b24a32df3a9'
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
),
|
||||
'costs' => array(),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'TOKEN' => 'super_secure_token_f24b24a32df3a9',
|
||||
'METHOD' => 'GetExpressCheckoutDetails',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,123 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: brut
|
||||
* Price view mode: net
|
||||
*
|
||||
* In costs there is wrapping.
|
||||
*/
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => '_testId1',
|
||||
'oxprice' => 119,
|
||||
'oxvat' => 19,
|
||||
'amount' => 10,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => '_testId2',
|
||||
'oxprice' => 11.9,
|
||||
'oxvat' => 19,
|
||||
'amount' => 100,
|
||||
),
|
||||
),
|
||||
'costs' => array(
|
||||
'wrapping' => array(
|
||||
0 => array(
|
||||
'oxtype' => 'WRAP',
|
||||
'oxname' => 'testWrap9001',
|
||||
'oxprice' => 11.9,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array('_testId1')
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
'sOEPayPalTransactionMode' => 'Authorization',
|
||||
'blSeoMode' => false,
|
||||
'blShowNetPrice' => true,
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_TAXAMT' => '399.00',
|
||||
'PAYMENTREQUEST_0_AMT' => '2499.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '2100.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 2.499,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 2.499,00 EUR',
|
||||
'MAXAMT' => '2500.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '100.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '10',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=_testId1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '100',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=_testId2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME2' => 'Geschenkverpackung',
|
||||
'L_PAYMENTREQUEST_0_AMT2' => '100.00',
|
||||
'L_PAYMENTREQUEST_0_QTY2' => '1',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,123 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: brut
|
||||
* Price view mode: net
|
||||
*
|
||||
* In costs there is voucher.
|
||||
*/
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => '_testId1',
|
||||
'oxprice' => 119,
|
||||
'oxvat' => 19,
|
||||
'amount' => 10,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => '_testId2',
|
||||
'oxprice' => 11.9,
|
||||
'oxvat' => 19,
|
||||
'amount' => 100,
|
||||
),
|
||||
),
|
||||
'costs' => array(
|
||||
'voucherserie' => array(
|
||||
0 => array(
|
||||
'oxserienr' => 'abs_4_voucher_serie',
|
||||
'oxdiscount' => 1,
|
||||
'oxdiscounttype' => 'absolute',
|
||||
'oxallowsameseries' => 1,
|
||||
'oxallowotherseries' => 1,
|
||||
'oxallowuseanother' => 1,
|
||||
'oxshopincl' => 1,
|
||||
'voucher_count' => 1
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
'sOEPayPalTransactionMode' => 'Authorization',
|
||||
'blSeoMode' => false,
|
||||
'blShowNetPrice' => true,
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_TAXAMT' => '379.81',
|
||||
'PAYMENTREQUEST_0_AMT' => '2378.81',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '2000.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '-1.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 2.378,81 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 2.378,81 EUR',
|
||||
'MAXAMT' => '2380.81',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '100.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '10',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=_testId1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '100',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=_testId2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,120 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Price enter mode: brut
|
||||
* Price view mode: net
|
||||
*
|
||||
* Case with discount.
|
||||
*/
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => '_testId1',
|
||||
'oxprice' => 119,
|
||||
'oxvat' => 19,
|
||||
'amount' => 1,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => '_testId2',
|
||||
'oxprice' => 11.9,
|
||||
'oxvat' => 19,
|
||||
'amount' => 1,
|
||||
),
|
||||
),
|
||||
'discounts' => array(
|
||||
0 => array(
|
||||
'oxid' => '_discountitm',
|
||||
'oxaddsum' => 10,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxamount' => 1,
|
||||
'oxamountto' => 99999,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array('_testId1'),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalSandboxUsername' => 'testUser',
|
||||
'sOEPayPalSandboxPassword' => 'testPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSignature',
|
||||
'sOEPayPalTransactionMode' => 'Authorization',
|
||||
'blSeoMode' => false,
|
||||
'blShowNetPrice' => true,
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_TAXAMT' => '19.00',
|
||||
'PAYMENTREQUEST_0_AMT' => '119.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '100.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 119,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 119,00 EUR',
|
||||
'MAXAMT' => '120.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '90.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '1',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=_testId1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '1',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=_testId2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,123 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testAddItems1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 0,
|
||||
'amount' => 1,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'testAddItems2',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 0,
|
||||
'amount' => 1,
|
||||
),
|
||||
),
|
||||
'costs' => array(
|
||||
'wrapping' => array(
|
||||
0 => array(
|
||||
'oxtype' => 'WRAP',
|
||||
'oxname' => 'testWrap9001',
|
||||
'oxprice' => 0.50,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array('testAddItems1', 'testAddItems2')
|
||||
),
|
||||
1 => array(
|
||||
'oxtype' => 'CARD',
|
||||
'oxname' => 'testCard9001',
|
||||
'oxprice' => 0.30,
|
||||
'oxactive' => 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_AMT' => '21.30',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '21.30',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 21,30 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 21,30 EUR',
|
||||
'MAXAMT' => '22.30',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '1',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testAddItems1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '1',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=testAddItems2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME2' => 'Geschenkverpackung',
|
||||
'L_PAYMENTREQUEST_0_AMT2' => '1.00',
|
||||
'L_PAYMENTREQUEST_0_QTY2' => '1',
|
||||
'L_PAYMENTREQUEST_0_NAME3' => 'Grußkarte',
|
||||
'L_PAYMENTREQUEST_0_AMT3' => '0.30',
|
||||
'L_PAYMENTREQUEST_0_QTY3' => '1',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,147 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
/**
|
||||
* Price enter mode: netto
|
||||
* Price view mode: netto
|
||||
* Product count: count of used products
|
||||
* VAT info: 19%
|
||||
* Currency rate: 0.68
|
||||
* Discounts: count
|
||||
* 1. bascet 5 abs
|
||||
* 2. shop 5 abs for 9001
|
||||
* 3. bascet 1 abs for 9001
|
||||
* 4. shop 5% for 9002
|
||||
* 5. bascet 6% for 9002
|
||||
* Vouchers: count
|
||||
* 1. 6 abs
|
||||
* Wrapping: +;
|
||||
* Gift cart: -;
|
||||
* Costs VAT caclulation rule: max
|
||||
* Costs:
|
||||
* 1. Payment +
|
||||
* 2. Delivery +
|
||||
* 3. TS -
|
||||
* Actions with basket or order:
|
||||
* 1. update / delete / change config
|
||||
* 2. ...
|
||||
* ...
|
||||
* Short description: bug entry / support case other info;
|
||||
*/
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'test9001',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 19,
|
||||
'oxartnum' => '9001',
|
||||
'oxtitle' => 'Test Title 1',
|
||||
'amount' => 2,
|
||||
'oxstock' => 50,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'test9002',
|
||||
'oxprice' => 20,
|
||||
'oxvat' => 19,
|
||||
'oxartnum' => '9002',
|
||||
'oxtitle' => 'Test Title 2',
|
||||
'amount' => 1,
|
||||
'oxstock' => 50,
|
||||
),
|
||||
2 => array(
|
||||
'oxid' => 'test9003',
|
||||
'oxprice' => 30,
|
||||
'oxvat' => 19,
|
||||
'oxartnum' => '9003',
|
||||
'oxtitle' => 'Test Title 3',
|
||||
'amount' => 1,
|
||||
'oxstock' => 50,
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => true,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_AMT' => '70.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '70.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 70,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 70,00 EUR',
|
||||
'MAXAMT' => '71.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => 'Test Title 1',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '2.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}Test-Title-1.html',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '9001',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => 'Test Title 2',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '20.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '1.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}Test-Title-2.html',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '9002',
|
||||
'L_PAYMENTREQUEST_0_NAME2' => 'Test Title 3',
|
||||
'L_PAYMENTREQUEST_0_AMT2' => '30.00',
|
||||
'L_PAYMENTREQUEST_0_QTY2' => '1.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL2' => '{SHOP_URL}Test-Title-3.html',
|
||||
'L_PAYMENTREQUEST_0_NUMBER2' => '9003',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,100 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 9001,
|
||||
'oxprice' => 100,
|
||||
'oxvat' => 19,
|
||||
'amount' => 33,
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalBrandName' => 'ShopBrandName',
|
||||
'sOEPayPalBorderColor' => 'testColor',
|
||||
'dMaxPayPalDeliveryAmount' => 50,
|
||||
'sOEPayPalLogoImageOption' => 'customLogo',
|
||||
'shopLogo' => 'shouldNotBeUsed.ico',
|
||||
'sOEPayPalCustomShopLogoImage' => 'favicon.ico',
|
||||
'blOEPayPalSendToPayPal' => false,
|
||||
'blOEPayPalSandboxMode' => true,
|
||||
'sOEPayPalUsername' => 'tesUser',
|
||||
'sOEPayPalPassword' => 'tesPassword',
|
||||
'sOEPayPalSignature' => 'tesSignature',
|
||||
'sOEPayPalSandboxUsername' => 'testSandboxUser',
|
||||
'sOEPayPalSandboxPassword' => 'testSandboxPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSandboxSignature',
|
||||
'sOEPayPalTransactionMode' => 'Sales',
|
||||
'blOEPayPalGuestBuyRole' => true,
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => false,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testSandboxPassword',
|
||||
'USER' => 'testSandboxUser',
|
||||
'SIGNATURE' => 'testSandboxSignature',
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Sole',
|
||||
'BRANDNAME' => 'ShopBrandName',
|
||||
'CARTBORDERCOLOR' => 'testColor',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'LOGOIMG' => '{SHOP_URL}out/azure/img/favicon.ico',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sales',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_AMT' => '3300.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '3300.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei ShopBrandName in Höhe von 3.300,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei ShopBrandName in Höhe von 3.300,00 EUR',
|
||||
'MAXAMT' => '3301.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => 'Gesamtsumme:',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '3300.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '1',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,99 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 9001,
|
||||
'oxprice' => 100,
|
||||
'oxvat' => 19,
|
||||
'amount' => 33,
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'sOEPayPalBrandName' => 'ShopBrandName',
|
||||
'sOEPayPalBorderColor' => 'testColor',
|
||||
'dMaxPayPalDeliveryAmount' => 50,
|
||||
'sOEPayPalLogoImageOption' => 'shopLogo',
|
||||
'sShopLogo' => 'favicon.ico',
|
||||
'sOEPayPalCustomShopLogoImage' => 'shouldNotBeUsed.ico',
|
||||
'blOEPayPalSendToPayPal' => true,
|
||||
'blOEPayPalSandboxMode' => false,
|
||||
'sOEPayPalUsername' => 'testUser',
|
||||
'sOEPayPalPassword' => 'testPassword',
|
||||
'sOEPayPalSignature' => 'testSignature',
|
||||
'sOEPayPalSandboxUsername' => 'testSandboxUser',
|
||||
'sOEPayPalSandboxPassword' => 'testSandboxPassword',
|
||||
'sOEPayPalSandboxSignature' => 'testSandboxSignature',
|
||||
'sOEPayPalTransactionMode' => 'Authorization',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => false,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => 'testPassword',
|
||||
'USER' => 'testUser',
|
||||
'SIGNATURE' => 'testSignature',
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'ShopBrandName',
|
||||
'CARTBORDERCOLOR' => 'testColor',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'LOGOIMG' => '{SHOP_URL}out/azure/img/favicon.ico',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_AMT' => '3300.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '3300.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei ShopBrandName in Höhe von 3.300,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei ShopBrandName in Höhe von 3.300,00 EUR',
|
||||
'MAXAMT' => '3301.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => 'Gesamtsumme:',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '3300.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '1',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,116 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testVouchers1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'testVouchers2',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 4,
|
||||
),
|
||||
),
|
||||
'costs' => array(
|
||||
'delivery' => array(
|
||||
'oxdeliveryset' => array(
|
||||
'oxactive' => 1,
|
||||
'oxtitle' => 'Test Delivery & Set',
|
||||
),
|
||||
0 => array(
|
||||
'oxactive' => 1,
|
||||
'oxaddsum' => 55,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxdeltype' => 'p',
|
||||
'oxfinalize' => 1,
|
||||
'oxparamend' => 99999,
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_AMT' => '125.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '70.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '55.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => 'Test Delivery & Set',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '55.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 125,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 125,00 EUR',
|
||||
'MAXAMT' => '126.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testVouchers1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '4',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=testVouchers2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,111 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testDiscountsAbs1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'testDiscountsAbs2',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 4,
|
||||
),
|
||||
),
|
||||
'discounts' => array(
|
||||
0 => array(
|
||||
'oxid' => 'discountForTestDiscountsAbs1',
|
||||
'oxaddsum' => 5,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxamount' => 0,
|
||||
'oxamountto' => 99999,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array('testDiscountsAbs1'),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_AMT' => '55.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '55.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 55,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 55,00 EUR',
|
||||
'MAXAMT' => '56.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '5.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testDiscountsAbs1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '4.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=testDiscountsAbs2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,110 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testDiscountsBasket1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'testDiscountsBasket2',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 4,
|
||||
),
|
||||
),
|
||||
'discounts' => array(
|
||||
0 => array(
|
||||
'oxid' => 'discountForTestDiscountsBasket1',
|
||||
'oxaddsum' => 5,
|
||||
'oxaddsumtype' => 'abs',
|
||||
'oxamount' => 1,
|
||||
'oxprice' => 0,
|
||||
'oxactive' => 1,
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_AMT' => '65.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '70.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '-5.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 65,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 65,00 EUR',
|
||||
'MAXAMT' => '71.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testDiscountsBasket1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '4.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=testDiscountsBasket2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,111 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testDiscountsPercent1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'testDiscountsPercent2',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 4,
|
||||
),
|
||||
),
|
||||
'discounts' => array(
|
||||
0 => array(
|
||||
'oxid' => 'discountForTestDiscountsPercent1',
|
||||
'oxaddsum' => 50,
|
||||
'oxaddsumtype' => '%',
|
||||
'oxamount' => 0,
|
||||
'oxamountto' => 99999,
|
||||
'oxactive' => 1,
|
||||
'oxarticles' => array('testDiscountsPercent1'),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_AMT' => '55.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '55.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 55,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 55,00 EUR',
|
||||
'MAXAMT' => '56.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '5.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testDiscountsPercent1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '4.0',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=testDiscountsPercent2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,111 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testVouchers1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'testVouchers2',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 4,
|
||||
),
|
||||
),
|
||||
'costs' => array(
|
||||
'payment' => array(
|
||||
0 => array(
|
||||
'oxid' => 'oxidpaypal',
|
||||
'oxaddsum' => 55,
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_AMT' => '125.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '125.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 125,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 125,00 EUR',
|
||||
'MAXAMT' => '126.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testVouchers1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '4',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=testVouchers2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME2' => 'Aufschlag Zahlungsart',
|
||||
'L_PAYMENTREQUEST_0_AMT2' => '55.00',
|
||||
'L_PAYMENTREQUEST_0_QTY2' => '1',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,112 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testUserLogged1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
),
|
||||
'groups' => array(
|
||||
0 => array(
|
||||
'oxid' => 'UserLoggedTestGroup',
|
||||
'oxactive' => 1,
|
||||
'oxtitle' => 'checkoutTestGroup',
|
||||
'oxobject2group' => array('TestLoggedUser', 'oxidpaypal'),
|
||||
),
|
||||
),
|
||||
'user' => array(
|
||||
'oxid' => 'TestLoggedUser',
|
||||
'oxactive' => 1,
|
||||
'oxusername' => 'testuser@email.com',
|
||||
'oxfname' => 'Name',
|
||||
'oxlname' => 'LName',
|
||||
'oxstreet' => 'Street',
|
||||
'oxstreetnr' => 'StreetNr',
|
||||
'oxcity' => 'City',
|
||||
'oxzip' => 'ZipCode',
|
||||
'oxfon' => 'PhoneNr',
|
||||
'oxcountryid' => '8f241f11096877ac0.98748826', // United States
|
||||
'oxstateid' => 'IL', // Illinois
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_AMT' => '27.27',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '27.27',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 27,27 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 27,27 EUR',
|
||||
'MAXAMT' => '28.27',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '9.09',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testUserLogged1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'EMAIL' => 'testuser@email.com',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'Name LName',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Street StreetNr',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => 'ZipCode',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => 'PhoneNr',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'US',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTATE' => 'IL',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,125 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testUserLogged1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
),
|
||||
'groups' => array(
|
||||
0 => array(
|
||||
'oxid' => 'UserLoggedTestGroup',
|
||||
'oxactive' => 1,
|
||||
'oxtitle' => 'checkoutTestGroup',
|
||||
'oxobject2group' => array('TestLoggedUser', 'oxidpaypal'),
|
||||
),
|
||||
),
|
||||
'user' => array(
|
||||
'oxid' => 'TestLoggedUser',
|
||||
'oxactive' => 1,
|
||||
'oxusername' => 'testuser@email.com',
|
||||
'oxfname' => 'Name',
|
||||
'oxlname' => 'LName',
|
||||
'oxstreet' => 'Street',
|
||||
'oxstreetnr' => 'StreetNr',
|
||||
'oxcity' => 'City',
|
||||
'oxzip' => 'ZipCode',
|
||||
'oxfon' => 'PhoneNr',
|
||||
'oxcountryid' => '8f241f11096877ac0.98748826', // United States
|
||||
'oxstateid' => 'IL', // Illinois
|
||||
'address' => array(
|
||||
'oxid' => 'TestUserAddressId',
|
||||
'oxfname' => 'AddressName',
|
||||
'oxlname' => 'AddressLName',
|
||||
'oxstreet' => 'AddressStreet',
|
||||
'oxstreetnr' => 'AddressStreetNr',
|
||||
'oxcity' => 'AddressCity',
|
||||
'oxzip' => 'AddressZipCode',
|
||||
'oxfon' => 'AddressPhoneNr',
|
||||
'oxcountryid' => 'a7c40f6323c4bfb36.59919433', // Italy
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'session' => array(
|
||||
'deladrid' => 'TestUserAddressId',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_AMT' => '27.27',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '27.27',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 27,27 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 27,27 EUR',
|
||||
'MAXAMT' => '28.27',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '9.09',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testUserLogged1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'EMAIL' => 'testuser@email.com',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'AddressName AddressLName',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'AddressStreet AddressStreetNr',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'AddressCity',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => 'AddressZipCode',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => 'AddressPhoneNr',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'IT',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,83 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testUserNotLogged1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
),
|
||||
'user' => false,
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_AMT' => '30.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '30.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 30,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 30,00 EUR',
|
||||
'MAXAMT' => '31.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testUserNotLogged1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,114 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
|
||||
|
||||
$data = array(
|
||||
'class' => \OxidEsales\PayPalModule\Controller\StandardDispatcher::class,
|
||||
'action' => 'setExpressCheckout',
|
||||
'articles' => array(
|
||||
0 => array(
|
||||
'oxid' => 'testVouchers1',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 3,
|
||||
),
|
||||
1 => array(
|
||||
'oxid' => 'testVouchers2',
|
||||
'oxprice' => 10,
|
||||
'oxvat' => 10,
|
||||
'amount' => 4,
|
||||
),
|
||||
),
|
||||
'costs' => array(
|
||||
'voucherserie' => array(
|
||||
0 => array(
|
||||
'oxserienr' => 'voucherForShop',
|
||||
'oxdiscount' => 90.00,
|
||||
'oxdiscounttype' => 'absolute',
|
||||
'oxallowsameseries' => 1,
|
||||
'oxallowotherseries' => 1,
|
||||
'oxallowuseanother' => 1,
|
||||
'oxshopincl' => 1,
|
||||
'voucher_count' => 1
|
||||
),
|
||||
),
|
||||
),
|
||||
'config' => array(
|
||||
'blSeoMode' => false,
|
||||
'sOEPayPalTransactionMode' => 'Sale',
|
||||
),
|
||||
'requestToShop' => array(
|
||||
'displayCartInPayPal' => true,
|
||||
),
|
||||
'expected' => array(
|
||||
'requestToPayPal' => array(
|
||||
'VERSION' => '84.0',
|
||||
'PWD' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxPassword'),
|
||||
'USER' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxUsername'),
|
||||
'SIGNATURE' => EshopRegistry::getConfig()->getConfigParam('sOEPayPalSandboxSignature'),
|
||||
'CALLBACKVERSION' => '84.0',
|
||||
'LOCALECODE' => 'de_DE',
|
||||
'SOLUTIONTYPE' => 'Mark',
|
||||
'BRANDNAME' => 'PayPal Testshop',
|
||||
'CARTBORDERCOLOR' => '2b8da4',
|
||||
'RETURNURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=oepaypalstandarddispatcher&fnc=getExpressCheckoutDetails',
|
||||
'CANCELURL' => '{SHOP_URL}index.php?lang=0&sid=&rtoken=token&shp={SHOP_ID}&cl=payment',
|
||||
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
|
||||
'NOSHIPPING' => '0',
|
||||
'ADDROVERRIDE' => '1',
|
||||
'PAYMENTREQUEST_0_AMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR',
|
||||
'PAYMENTREQUEST_0_ITEMAMT' => '70.00',
|
||||
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00',
|
||||
'PAYMENTREQUEST_0_SHIPDISCAMT' => '-70.00',
|
||||
'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
|
||||
'L_SHIPPINGOPTIONNAME0' => '#1',
|
||||
'L_SHIPPINGOPTIONAMOUNT0' => '0.00',
|
||||
'PAYMENTREQUEST_0_DESC' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 0,00 EUR',
|
||||
'PAYMENTREQUEST_0_CUSTOM' => 'Ihre Bestellung bei PayPal Testshop in Höhe von 0,00 EUR',
|
||||
'MAXAMT' => '71.00',
|
||||
'L_PAYMENTREQUEST_0_NAME0' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT0' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY0' => '3',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL0' => '{SHOP_URL}index.php?cl=details&anid=testVouchers1',
|
||||
'L_PAYMENTREQUEST_0_NUMBER0' => '',
|
||||
'L_PAYMENTREQUEST_0_NAME1' => '',
|
||||
'L_PAYMENTREQUEST_0_AMT1' => '10.00',
|
||||
'L_PAYMENTREQUEST_0_QTY1' => '4',
|
||||
'L_PAYMENTREQUEST_0_ITEMURL1' => '{SHOP_URL}index.php?cl=details&anid=testVouchers2',
|
||||
'L_PAYMENTREQUEST_0_NUMBER1' => '',
|
||||
'EMAIL' => 'admin',
|
||||
'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe',
|
||||
'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Maple Street 10',
|
||||
'PAYMENTREQUEST_0_SHIPTOCITY' => 'Any City',
|
||||
'PAYMENTREQUEST_0_SHIPTOZIP' => '9041',
|
||||
'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '217-8918712',
|
||||
'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'DE',
|
||||
'METHOD' => 'SetExpressCheckout',
|
||||
),
|
||||
'header' => array(
|
||||
0 => 'POST /cgi-bin/webscr HTTP/1.1',
|
||||
1 => 'Content-Type: application/x-www-form-urlencoded',
|
||||
2 => 'Host: api-3t.sandbox.paypal.com',
|
||||
3 => 'Connection: close',
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,82 @@
|
||||
<?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\Tests\Integration;
|
||||
|
||||
class CurlMainParametersTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
public function testCurlMainParameterHost_modeSandbox_sandboxHost()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', true);
|
||||
|
||||
$service = new \OxidEsales\PayPalModule\Core\PayPalService();
|
||||
$curl = $service->getCaller()->getCurl();
|
||||
|
||||
$this->assertEquals('api-3t.sandbox.paypal.com', $curl->getHost());
|
||||
}
|
||||
|
||||
public function testCurlMainParameterHost_modeProduction_payPalHost()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', false);
|
||||
|
||||
$service = new \OxidEsales\PayPalModule\Core\PayPalService();
|
||||
$curl = $service->getCaller()->getCurl();
|
||||
|
||||
$this->assertEquals('api-3t.paypal.com', $curl->getHost());
|
||||
}
|
||||
|
||||
public function testCurlMainParameterCharset_default_iso()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('iUtfMode', false);
|
||||
|
||||
$service = new \OxidEsales\PayPalModule\Core\PayPalService();
|
||||
$curl = $service->getCaller()->getCurl();
|
||||
|
||||
$this->assertEquals('UTF-8', $curl->getDataCharset());
|
||||
}
|
||||
|
||||
public function testCurlMainParameterCharset_utfMode_utf()
|
||||
{
|
||||
$service = new \OxidEsales\PayPalModule\Core\PayPalService();
|
||||
$curl = $service->getCaller()->getCurl();
|
||||
|
||||
$this->assertEquals('UTF-8', $curl->getDataCharset());
|
||||
}
|
||||
|
||||
public function testCurlMainParameterUrlToCall_defaultProductionMode_ApiUrl()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', false);
|
||||
|
||||
$service = new \OxidEsales\PayPalModule\Core\PayPalService();
|
||||
$curl = $service->getCaller()->getCurl();
|
||||
|
||||
$this->assertEquals('https://api-3t.paypal.com/nvp', $curl->getUrlToCall());
|
||||
}
|
||||
|
||||
public function testCurlMainParameterUrlToCall_defaultSandboxMode_sandboxApiUrl()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', true);
|
||||
|
||||
$service = new \OxidEsales\PayPalModule\Core\PayPalService();
|
||||
$curl = $service->getCaller()->getCurl();
|
||||
|
||||
$this->assertEquals('https://api-3t.sandbox.paypal.com/nvp', $curl->getUrlToCall());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,823 @@
|
||||
<?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\Tests\Integration\IPNProcessing;
|
||||
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
|
||||
/**
|
||||
* Integration tests for IPN processing.
|
||||
*/
|
||||
class IPNProcessingTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/** @var string Command for paypal verification call. */
|
||||
const POSTBACK_CMD = 'cmd=_notify-validate';
|
||||
|
||||
/** @var string PayPal transaction id */
|
||||
const PAYPAL_TRANSACTION_ID = '5H706430HM112602B';
|
||||
|
||||
/** @var string PayPal id of authorization transaction */
|
||||
const PAYPAL_AUTHID = '5H706430HM1126666';
|
||||
|
||||
/** @var string PayPal parent transaction id*/
|
||||
const PAYPAL_PARENT_TRANSACTION_ID = '8HF77866N86936335';
|
||||
|
||||
/** @var string Amount paid*/
|
||||
const PAYMENT_AMOUNT = 30.66;
|
||||
|
||||
/** @var string currency specifier*/
|
||||
const PAYMENT_CURRENCY = 'EUR';
|
||||
|
||||
/** @var string PayPal correlation id for transaction*/
|
||||
const PAYMENT_CORRELATION_ID = '361b9ebf97777';
|
||||
|
||||
/** @var string PayPal correlation id for authorization transaction*/
|
||||
const AUTH_CORRELATION_ID = '361b9ebf9bcee';
|
||||
|
||||
/** @var string test order oxid*/
|
||||
private $testOrderId = null;
|
||||
|
||||
/** @var string test user oxid */
|
||||
private $testUserId = null;
|
||||
|
||||
/**
|
||||
* Set up fixture.
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->getConfig()->setConfigParam('iUtfMode', '1');
|
||||
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute('DROP TABLE IF EXISTS `oepaypal_order`');
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute('DROP TABLE IF EXISTS `oepaypal_orderpayments`');
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute('DROP TABLE IF EXISTS `oepaypal_orderpaymentcomments`');
|
||||
|
||||
\OxidEsales\PayPalModule\Core\Events::addOrderPaymentsTable();
|
||||
\OxidEsales\PayPalModule\Core\Events::addOrderTable();
|
||||
\OxidEsales\PayPalModule\Core\Events::addOrderPaymentsCommentsTable();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear down fixture.
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->cleanUpTable('oxorder');
|
||||
$this->cleanUpTable('oxuser');
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function providerPayPalIPNPaymentBuilderNewCapture()
|
||||
{
|
||||
$data = array();
|
||||
$data['capture_new'][0]['ipn'] = array(
|
||||
'payment_type' => 'instant',
|
||||
'payment_date' => '00:54:36 Jun 03, 2015 PDT',
|
||||
'payment_status' => 'Completed',
|
||||
'payer_status' => 'verified',
|
||||
'first_name' => 'Max',
|
||||
'last_name' => 'Muster',
|
||||
'payer_email' => 'buyer@paypalsandbox_com',
|
||||
'payer_id' => 'TESTBUYERID01',
|
||||
'address_name' => 'Max_Muster',
|
||||
'address_city' => 'Freiburg',
|
||||
'address_street' => 'Blafööstraße_123',
|
||||
'charset' => 'UTF-8',
|
||||
'transaction_entity' => 'payment',
|
||||
'address_country_code' => 'DE',
|
||||
'notify_version' => '3_8',
|
||||
'custom' => 'Bestellnummer_8',
|
||||
'parent_txn_id' => self::PAYPAL_AUTHID,
|
||||
'txn_id' => self::PAYPAL_TRANSACTION_ID,
|
||||
'auth_id' => self::PAYPAL_AUTHID,
|
||||
'receiver_email' => 'devbiz@oxid-esales_com',
|
||||
'item_name' => 'Bestellnummer_8',
|
||||
'mc_currency' => 'EUR',
|
||||
'test_ipn' => '1',
|
||||
'auth_amount' => self::PAYMENT_AMOUNT,
|
||||
'mc_gross' => self::PAYMENT_AMOUNT,
|
||||
'correlation_id' => self::PAYMENT_CORRELATION_ID,
|
||||
'auth_status' => 'Completed',
|
||||
'memo' => 'capture_new'
|
||||
);
|
||||
$data['capture_new'][0]['expected_payment_status'] = $data['capture_new'][0]['ipn']['payment_status'];
|
||||
$data['capture_new'][0]['expected_txn_id'] = $data['capture_new'][0]['ipn']['txn_id'];
|
||||
$data['capture_new'][0]['expected_date'] = '2015-06-03 09:54:36';
|
||||
$data['capture_new'][0]['expected_correlation_id'] = $data['capture_new'][0]['ipn']['correlation_id'];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IPN processing, payment building part.
|
||||
*
|
||||
* @dataProvider providerPayPalIPNPaymentBuilderNewCapture
|
||||
*/
|
||||
public function testPayPalIPNPaymentBuilderNewCapture($data)
|
||||
{
|
||||
$this->prepareFullOrder();
|
||||
$orderPaymentParent = $this->createPayPalOrderPaymentParent();
|
||||
$orderPayment = $this->getPayPalOrderPayment($data['ipn']);
|
||||
|
||||
$this->assertTrue(is_a($orderPayment, \OxidEsales\PayPalModule\Model\OrderPayment::class), 'wrong type of object');
|
||||
$this->assertEquals($data['expected_payment_status'], $orderPayment->getStatus(), 'wrong payment status');
|
||||
$this->assertTrue($orderPayment->getIsValid(), 'payment not valid');
|
||||
$this->assertEquals($data['expected_txn_id'], $orderPayment->getTransactionId(), 'wrong transaction id');
|
||||
$this->assertEquals($data['expected_correlation_id'], $orderPayment->getCorrelationId(),
|
||||
'wrong correlation id');
|
||||
$this->assertEquals($data['expected_date'], $orderPayment->getDate(), 'wrong date');
|
||||
|
||||
$orderPaymentParent->load();
|
||||
$this->assertEquals('Completed', $orderPaymentParent->getStatus(), 'wrong payment status');
|
||||
$this->assertEquals('0.00', $orderPaymentParent->getRefundedAmount(), 'wrong refunded amount');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function providerPayPalIPNPaymentBuilderExistingTransaction()
|
||||
{
|
||||
$data['exists'][0]['ipn'] = array(
|
||||
'payment_type' => 'instant',
|
||||
'payment_date' => '00:54:36 Jun 03, 2015 PDT',
|
||||
'payment_status' => 'Refunded',
|
||||
'payer_status' => 'verified',
|
||||
'first_name' => 'Max',
|
||||
'last_name' => 'Muster',
|
||||
'payer_email' => 'buyer@paypalsandbox_com',
|
||||
'payer_id' => 'TESTBUYERID01',
|
||||
'address_name' => 'Max_Muster',
|
||||
'address_city' => 'Freiburg',
|
||||
'address_street' => 'Blafööstraße_123',
|
||||
'charset' => 'UTF-8',
|
||||
'transaction_entity' => 'payment',
|
||||
'address_country_code' => 'DE',
|
||||
'notify_version' => '3_8',
|
||||
'custom' => 'Bestellnummer_8',
|
||||
'parent_txn_id' => '',
|
||||
'txn_id' => self::PAYPAL_AUTHID,
|
||||
'auth_id' => self::PAYPAL_AUTHID,
|
||||
'receiver_email' => 'devbiz@oxid-esales_com',
|
||||
'item_name' => 'Bestellnummer_8',
|
||||
'mc_currency' => 'EUR',
|
||||
'test_ipn' => '1',
|
||||
'auth_amount' => self::PAYMENT_AMOUNT,
|
||||
'mc_gross' => -self::PAYMENT_AMOUNT,
|
||||
'correlation_id' => self::AUTH_CORRELATION_ID,
|
||||
'memo' => 'exists'
|
||||
);
|
||||
$data['exists'][0]['expected_payment_status'] = $data['exists'][0]['ipn']['payment_status'];
|
||||
$data['exists'][0]['expected_txn_id'] = $data['exists'][0]['ipn']['txn_id'];
|
||||
$data['exists'][0]['expected_date'] = '2015-04-01 12:12:12'; //orginal date
|
||||
$data['exists'][0]['expected_correlation_id'] = $data['exists'][0]['ipn']['correlation_id'];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IPN processing, payment building part.
|
||||
*
|
||||
* @dataProvider providerPayPalIPNPaymentBuilderExistingTransaction
|
||||
*/
|
||||
public function testPayPalIPNPaymentBuilderExistingTransaction($data)
|
||||
{
|
||||
$this->prepareFullOrder();
|
||||
$orderPaymentParent = $this->createPayPalOrderPaymentParent();
|
||||
$orderPayment = $this->getPayPalOrderPayment($data['ipn']);
|
||||
|
||||
$this->assertTrue(is_a($orderPayment, \OxidEsales\PayPalModule\Model\OrderPayment::class), 'wrong type of object');
|
||||
$this->assertEquals($data['expected_payment_status'], $orderPayment->getStatus(), 'wrong payment status');
|
||||
$this->assertTrue($orderPayment->getIsValid(), 'payment not valid');
|
||||
$this->assertEquals($data['expected_txn_id'], $orderPayment->getTransactionId(), 'wrong transaction id');
|
||||
$this->assertEquals($data['expected_correlation_id'], $orderPayment->getCorrelationId(),
|
||||
'wrong correlation id');
|
||||
$this->assertEquals($data['expected_date'], $orderPayment->getDate(), 'wrong date');
|
||||
|
||||
$orderPaymentParent->load();
|
||||
$this->assertEquals('0.00', $orderPaymentParent->getRefundedAmount(), 'wrong refunded amount');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function providerPayPalIPNPaymentBuilderRefund()
|
||||
{
|
||||
$data['refund_new'][0]['ipn'] = array(
|
||||
'payment_type' => 'instant',
|
||||
'payment_date' => '00:54:36 Jun 03, 2015 PDT',
|
||||
'payment_status' => 'Refunded',
|
||||
'payer_status' => 'verified',
|
||||
'first_name' => 'Max',
|
||||
'last_name' => 'Muster',
|
||||
'payer_email' => 'buyer@paypalsandbox_com',
|
||||
'payer_id' => 'TESTBUYERID01',
|
||||
'address_name' => 'Max_Muster',
|
||||
'address_city' => 'Freiburg',
|
||||
'address_street' => 'Blafööstraße_123',
|
||||
'charset' => 'UTF-8',
|
||||
'transaction_entity' => 'payment',
|
||||
'address_country_code' => 'DE',
|
||||
'notify_version' => '3_8',
|
||||
'custom' => 'Bestellnummer_8',
|
||||
'parent_txn_id' => self::PAYPAL_AUTHID,
|
||||
'txn_id' => self::PAYPAL_TRANSACTION_ID,
|
||||
'auth_id' => self::PAYPAL_AUTHID,
|
||||
'receiver_email' => 'devbiz@oxid-esales_com',
|
||||
'item_name' => 'Bestellnummer_8',
|
||||
'mc_currency' => 'EUR',
|
||||
'test_ipn' => '1',
|
||||
'auth_amount' => self::PAYMENT_AMOUNT,
|
||||
'mc_gross' => -self::PAYMENT_AMOUNT,
|
||||
'correlation_id' => self::AUTH_CORRELATION_ID,
|
||||
'memo' => 'refund_new'
|
||||
);
|
||||
$data['refund_new'][0]['expected_payment_status'] = $data['refund_new'][0]['ipn']['payment_status'];
|
||||
$data['refund_new'][0]['expected_txn_id'] = $data['refund_new'][0]['ipn']['txn_id'];
|
||||
$data['refund_new'][0]['expected_date'] = '2015-06-03 09:54:36'; //orginal date
|
||||
$data['refund_new'][0]['expected_correlation_id'] = $data['refund_new'][0]['ipn']['correlation_id'];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IPN processing, payment building part.
|
||||
*
|
||||
* @dataProvider providerPayPalIPNPaymentBuilderRefund
|
||||
*/
|
||||
public function testPayPalIPNPaymentBuilderRefund($data)
|
||||
{
|
||||
$this->prepareFullOrder();
|
||||
$orderPaymentParent = $this->createPayPalOrderPaymentParent();
|
||||
$orderPayment = $this->getPayPalOrderPayment($data['ipn']);
|
||||
|
||||
$this->assertTrue(is_a($orderPayment, \OxidEsales\PayPalModule\Model\OrderPayment::class), 'wrong type of object');
|
||||
$this->assertEquals($data['expected_payment_status'], $orderPayment->getStatus(), 'wrong payment status');
|
||||
$this->assertTrue($orderPayment->getIsValid(), 'payment not valid');
|
||||
$this->assertEquals($data['expected_txn_id'], $orderPayment->getTransactionId(), 'wrong transaction id');
|
||||
$this->assertEquals($data['expected_correlation_id'], $orderPayment->getCorrelationId(),
|
||||
'wrong correlation id');
|
||||
$this->assertEquals($data['expected_date'], $orderPayment->getDate(), 'wrong date');
|
||||
|
||||
$orderPaymentParent->load();
|
||||
|
||||
//in case of refund, parent transaction should now have set a refunded amount
|
||||
$this->assertEquals('refund', $orderPayment->getAction(), 'wrong action');
|
||||
$this->assertEquals(-$data['ipn']['mc_gross'], $orderPayment->getAmount(), 'wrong amount');
|
||||
$this->assertEquals($orderPayment->getAmount(), $orderPaymentParent->getRefundedAmount(),
|
||||
'wrong refunded amount');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function providerPayPalIPNPaymentBuilderWrongEntity()
|
||||
{
|
||||
$data['wrong_entity'][0]['ipn'] = array('transaction_entity' => 'no_payment');
|
||||
$data['wrong_entity'][0]['expected_payment_status'] = '';
|
||||
$data['wrong_entity'][0]['expected_txn_id'] = '';
|
||||
$data['wrong_entity'][0]['expected_date'] = '';
|
||||
$data['wrong_entity'][0]['expected_correlation_id'] = '';
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IPN processing, payment building part.
|
||||
*
|
||||
* @dataProvider providerPayPalIPNPaymentBuilderExistingTransaction
|
||||
*/
|
||||
public function testPayPalIPNPaymentBuilderWrongEntity($data)
|
||||
{
|
||||
$this->prepareFullOrder();
|
||||
$orderPayment = $this->getPayPalOrderPayment($data['ipn']);
|
||||
$this->assertNull($orderPayment, 'did not expect order payment object');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function providerPayPalIPNProcessor()
|
||||
{
|
||||
$data = array();
|
||||
$data['complete_capture'][0]['capture'] = array(
|
||||
'payment_type' => 'instant',
|
||||
'payment_date' => '00:54:36 Jun 03, 2015 PDT',
|
||||
'payment_status' => 'Completed',
|
||||
'payer_status' => 'verified',
|
||||
'first_name' => 'Max',
|
||||
'last_name' => 'Muster',
|
||||
'payer_email' => 'buyer@paypalsandbox_com',
|
||||
'payer_id' => 'TESTBUYERID01',
|
||||
'address_name' => 'Max_Muster',
|
||||
'address_city' => 'Freiburg',
|
||||
'address_street' => 'Blafööstraße_123',
|
||||
'charset' => 'UTF-8',
|
||||
'transaction_entity' => 'payment',
|
||||
'address_country_code' => 'DE',
|
||||
'notify_version' => '3_8',
|
||||
'custom' => 'Bestellnummer_8',
|
||||
'parent_txn_id' => self::PAYPAL_AUTHID,
|
||||
'txn_id' => self::PAYPAL_TRANSACTION_ID,
|
||||
'auth_id' => self::PAYPAL_AUTHID,
|
||||
'receiver_email' => 'devbiz@oxid-esales_com',
|
||||
'item_name' => 'Bestellnummer_8',
|
||||
'mc_currency' => 'EUR',
|
||||
'test_ipn' => '1',
|
||||
'auth_amount' => self::PAYMENT_AMOUNT,
|
||||
'mc_gross' => self::PAYMENT_AMOUNT,
|
||||
'correlation_id' => '361b9ebf99999',
|
||||
'auth_status' => 'Completed'
|
||||
);
|
||||
$data['complete_capture'][1]['expected_payment_count'] = 2;
|
||||
$data['complete_capture'][1]['expected_capture_amount'] = self::PAYMENT_AMOUNT;
|
||||
$data['complete_capture'][1]['expected_refunded_amount'] = 0.0;
|
||||
$data['complete_capture'][1]['expected_voided_amount'] = 0.0;
|
||||
|
||||
$data['capture_and_refund'][0]['capture'] = array(
|
||||
'payment_type' => 'instant',
|
||||
'payment_date' => '00:54:36 Jun 03, 2015 PDT',
|
||||
'payment_status' => 'Completed',
|
||||
'payer_status' => 'verified',
|
||||
'first_name' => 'Max',
|
||||
'last_name' => 'Muster',
|
||||
'payer_email' => 'buyer@paypalsandbox_com',
|
||||
'payer_id' => 'TESTBUYERID01',
|
||||
'address_name' => 'Max_Muster',
|
||||
'address_city' => 'Freiburg',
|
||||
'address_street' => 'Blafööstraße_123',
|
||||
'charset' => 'UTF-8',
|
||||
'transaction_entity' => 'payment',
|
||||
'address_country_code' => 'DE',
|
||||
'notify_version' => '3_8',
|
||||
'custom' => 'Bestellnummer_8',
|
||||
'parent_txn_id' => self::PAYPAL_AUTHID,
|
||||
'txn_id' => self::PAYPAL_TRANSACTION_ID,
|
||||
'auth_id' => self::PAYPAL_AUTHID,
|
||||
'receiver_email' => 'devbiz@oxid-esales_com',
|
||||
'item_name' => 'Bestellnummer_8',
|
||||
'mc_currency' => 'EUR',
|
||||
'test_ipn' => '1',
|
||||
'auth_amount' => self::PAYMENT_AMOUNT,
|
||||
'mc_gross' => 0.7 * self::PAYMENT_AMOUNT,
|
||||
'ipn_track_id' => '361b9ebf99999',
|
||||
'auth_status' => 'In_Progress'
|
||||
);
|
||||
|
||||
$data['capture_and_refund'][0]['refund'] = array(
|
||||
'payment_type' => 'instant',
|
||||
'payment_date' => '00:54:36 Jun 03, 2015 PDT',
|
||||
'payment_status' => 'Refunded',
|
||||
'payer_status' => 'verified',
|
||||
'first_name' => 'Max',
|
||||
'last_name' => 'Muster',
|
||||
'payer_email' => 'buyer@paypalsandbox_com',
|
||||
'payer_id' => 'TESTBUYERID01',
|
||||
'address_name' => 'Max_Muster',
|
||||
'address_city' => 'Freiburg',
|
||||
'address_street' => 'Blafööstraße_123',
|
||||
'charset' => 'UTF-8',
|
||||
'transaction_entity' => 'payment',
|
||||
'address_country_code' => 'DE',
|
||||
'notify_version' => '3_8',
|
||||
'custom' => 'Bestellnummer_8',
|
||||
'parent_txn_id' => self::PAYPAL_TRANSACTION_ID,
|
||||
'txn_id' => '5H706430HM1127777',
|
||||
'auth_id' => self::PAYPAL_AUTHID,
|
||||
'receiver_email' => 'devbiz@oxid-esales_com',
|
||||
'item_name' => 'Bestellnummer_8',
|
||||
'mc_currency' => 'EUR',
|
||||
'test_ipn' => '1',
|
||||
'auth_amount' => self::PAYMENT_AMOUNT,
|
||||
'mc_gross' => -0.5 * self::PAYMENT_AMOUNT,
|
||||
'ipn_track_id' => '361b9ebf99988',
|
||||
'auth_status' => 'In_Progress'
|
||||
);
|
||||
|
||||
$data['capture_and_refund'][0]['void'] = array(
|
||||
'payment_type' => 'instant',
|
||||
'payment_date' => '00:54:36 Jun 03, 2015 PDT',
|
||||
'payment_status' => 'Voided',
|
||||
'payer_status' => 'verified',
|
||||
'first_name' => 'Max',
|
||||
'last_name' => 'Muster',
|
||||
'payer_email' => 'buyer@paypalsandbox_com',
|
||||
'payer_id' => 'TESTBUYERID01',
|
||||
'address_name' => 'Max_Muster',
|
||||
'address_city' => 'Freiburg',
|
||||
'address_street' => 'Blafööstraße_123',
|
||||
'charset' => 'UTF-8',
|
||||
'transaction_entity' => 'payment',
|
||||
'address_country_code' => 'DE',
|
||||
'notify_version' => '3_8',
|
||||
'custom' => 'Bestellnummer_8',
|
||||
'parent_txn_id' => '',
|
||||
'txn_id' => self::PAYPAL_AUTHID,
|
||||
'auth_id' => self::PAYPAL_AUTHID,
|
||||
'receiver_email' => 'devbiz@oxid-esales_com',
|
||||
'item_name' => 'Bestellnummer_8',
|
||||
'mc_currency' => 'EUR',
|
||||
'test_ipn' => '1',
|
||||
'auth_amount' => self::PAYMENT_AMOUNT,
|
||||
'mc_gross' => self::PAYMENT_AMOUNT,
|
||||
'ipn_track_id' => '361b9ebf99955',
|
||||
'auth_status' => 'Voided'
|
||||
);
|
||||
|
||||
$data['capture_and_refund'][1]['expected_payment_count'] = 3;
|
||||
$data['capture_and_refund'][1]['expected_capture_amount'] = round(0.7 * self::PAYMENT_AMOUNT, 2);
|
||||
$data['capture_and_refund'][1]['expected_refunded_amount'] = round(0.5 * self::PAYMENT_AMOUNT, 2);
|
||||
$data['capture_and_refund'][1]['expected_voided_amount'] = round(0.3 * self::PAYMENT_AMOUNT, 2);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IPN processing in case that the incoming transaction is not yet known in the shop database.
|
||||
* This happens when actions are done via PayPal backend and not via shop.
|
||||
* Test case :
|
||||
* - authorization mode, authorization was done by shop
|
||||
* - 'capture_for_existing_auth' => incoming IPN is for successful capture of the complete amount
|
||||
* - 'capture_and_refund' => captrue, partial refund and void of the remaining auth amount
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $expectations
|
||||
*
|
||||
* @dataProvider providerPayPalIPNProcessor
|
||||
*/
|
||||
public function testPayPalIPNProcessing($data, $expectations)
|
||||
{
|
||||
$paypalOrder = $this->prepareFullOrder();
|
||||
$this->createPayPalOrderPayment('authorization');
|
||||
$this->processIpn($data);
|
||||
|
||||
//after
|
||||
$paypalOrder->load();
|
||||
$this->assertEquals('completed', $paypalOrder->getPaymentStatus(), 'payment status');
|
||||
$this->assertEquals($expectations['expected_payment_count'], count($paypalOrder->getPaymentList()), 'payment count');
|
||||
$this->assertEquals($expectations['expected_capture_amount'], $paypalOrder->getCapturedAmount(), 'captured amount');
|
||||
$this->assertEquals($expectations['expected_refunded_amount'], $paypalOrder->getRefundedAmount(), 'refunded amount');
|
||||
$this->assertEquals($expectations['expected_voided_amount'], $paypalOrder->getVoidedAmount(), 'voided amount');
|
||||
|
||||
// status of order in table oxorder
|
||||
$order = oxNew(\OxidEsales\Eshop\Application\Model\Order::class);
|
||||
$order->load($this->testOrderId);
|
||||
$this->assertEquals('OK', $order->oxorder__oxtransstatus->value, 'oxorder status');
|
||||
$this->assertNotNull($order->oxorder__oxpaid->value, 'oxpaid date');
|
||||
$this->assertNotEquals('0000-00-00 00:00:00', $order->oxorder__oxpaid->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IPN processing.
|
||||
*/
|
||||
public function testPayPalOrderManager()
|
||||
{ //hier weiter
|
||||
$this->insertUser();
|
||||
$this->createOrder();
|
||||
$this->createPayPalOrder();
|
||||
$orderPaymentAuthorization = $this->createPayPalOrderPayment('authorization');
|
||||
$orderPayment = $this->createPayPalOrderPayment('capture');
|
||||
|
||||
$orderPaymentAuthorization->setStatus('Completed');
|
||||
$orderPaymentAuthorization->save();
|
||||
$this->assertEquals('Completed', $orderPaymentAuthorization->getStatus());
|
||||
|
||||
// status of order in table oxorder
|
||||
$order = oxNew(\OxidEsales\Eshop\Application\Model\Order::class);
|
||||
$order->load($this->testOrderId);
|
||||
$this->assertEquals('NOT_FINISHED', $order->oxorder__oxtransstatus->value);
|
||||
|
||||
//we have the capture paypal transactions that completes the payment
|
||||
//in table oepaypal_orderpayments and need to update oepaypal_order and oxorder__oxtransstatus
|
||||
|
||||
$orderManager = $this->getProxyClass(\OxidEsales\PayPalModule\Model\OrderManager::class);
|
||||
$orderManager->setOrderPayment($orderPayment);
|
||||
$paypalOrder = $orderManager->getOrder();
|
||||
$this->assertTrue(is_a($paypalOrder, \OxidEsales\PayPalModule\Model\PayPalOrder::class));
|
||||
$this->assertEquals($this->testOrderId, $paypalOrder->getId());
|
||||
$this->assertEquals(0.0, $paypalOrder->getCapturedAmount());
|
||||
$this->assertEquals('pending', $paypalOrder->getPaymentStatus());
|
||||
|
||||
//check PayPal transactions for this order
|
||||
$paymentList = $paypalOrder->getPaymentList();
|
||||
$this->assertEquals(2, count($paymentList));
|
||||
$this->assertFalse($paymentList->hasPendingPayment());
|
||||
|
||||
$processSuccess = $orderManager->updateOrderStatus();
|
||||
$this->assertTrue($processSuccess);
|
||||
$this->assertEquals('completed', $paypalOrder->getPaymentStatus());
|
||||
$this->assertEquals(self::PAYMENT_AMOUNT, $paypalOrder->getCapturedAmount());
|
||||
|
||||
$order->load($this->testOrderId);
|
||||
$this->assertEquals('OK', $order->oxorder__oxtransstatus->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test order amount recalculation.
|
||||
*/
|
||||
public function testPayPalOrderManagerOrderRecalculation()
|
||||
{
|
||||
$this->insertUser();
|
||||
$this->createOrder();
|
||||
$this->createPayPalOrder();
|
||||
$orderPaymentAuthorization = $this->createPayPalOrderPayment('authorization');
|
||||
$orderPayment = $this->createPayPalOrderPayment('capture');
|
||||
|
||||
$orderPaymentAuthorization->setStatus('In_Progress');
|
||||
$orderPaymentAuthorization->save();
|
||||
|
||||
$orderPayment->setStatus('Completed');
|
||||
$orderPayment->setAmount(self::PAYMENT_AMOUNT - 10.0);
|
||||
$orderPayment->save();
|
||||
|
||||
$orderManager = $this->getProxyClass(\OxidEsales\PayPalModule\Model\OrderManager::class);
|
||||
$orderManager->setOrderPayment($orderPayment);
|
||||
$paypalOrder = $orderManager->getOrder();
|
||||
|
||||
$paypalOrder = $orderManager->recalculateAmounts($paypalOrder);
|
||||
$this->assertEquals(self::PAYMENT_AMOUNT - 10.0, $paypalOrder->getCapturedAmount());
|
||||
}
|
||||
|
||||
private function getPayPalConfigMock()
|
||||
{
|
||||
$mocks = array(
|
||||
'getUserEmail' => 'devbiz_api1.oxid-efire.com',
|
||||
'isExpressCheckoutInMiniBasketEnabled' => '1',
|
||||
'isStandardCheckoutEnabled' => '1',
|
||||
'isExpressCheckoutEnabled' => '1',
|
||||
'isLoggingEnabled' => '1',
|
||||
'finalizeOrderOnPayPalSide' => '1',
|
||||
'isSandboxEnabled' => '1',
|
||||
'getPassword' => '1382082575',
|
||||
'getSignature' => 'AoRXRr2UPUu8BdpR8rbnhMMeSk9rAmMNTW2T1o9INg0KUgsqW4qcuhS5',
|
||||
'getTransactionMode' => 'AUTHORIZATION',
|
||||
);
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Config::class);
|
||||
$mockBuilder->setMethods(array_keys($mocks));
|
||||
$paypalConfig = $mockBuilder->getMock();
|
||||
|
||||
foreach ($mocks as $method => $returnValue) {
|
||||
$paypalConfig->expects($this->any())->method($method)->will($this->returnValue($returnValue));
|
||||
}
|
||||
|
||||
return $paypalConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create order in database by given ID.
|
||||
*
|
||||
* @param string $status
|
||||
*
|
||||
* @return \OxidEsales\Eshop\Application\Model\Order
|
||||
*/
|
||||
private function createOrder($status = null)
|
||||
{
|
||||
if (is_null($status)) {
|
||||
/** @var \OxidEsales\PayPalModule\Model\Order $order */
|
||||
$order = oxNew(Order::class);
|
||||
$status = $order::OEPAYPAL_TRANSACTION_STATUS_NOT_FINISHED;
|
||||
}
|
||||
|
||||
if (empty($this->testUserId)) {
|
||||
$this->fail('please create related oxuser first');
|
||||
}
|
||||
|
||||
$this->testOrderId = substr_replace(\OxidEsales\Eshop\Core\UtilsObject::getInstance()->generateUId(), '_', 0, 1);
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\Eshop\Application\Model\Order::class);
|
||||
$mockBuilder->setMethods(['validateDeliveryAddress']);
|
||||
$order = $mockBuilder->getMock();
|
||||
$order->setId($this->testOrderId);
|
||||
$order->oxorder__oxshopid = new \OxidEsales\Eshop\Core\Field(1);
|
||||
$order->oxorder__oxuserid = new \OxidEsales\Eshop\Core\Field($this->testUserId);
|
||||
$order->oxorder__oxorderdate = new \OxidEsales\Eshop\Core\Field('2015-05-29 10:41:03');
|
||||
$order->oxorder__oxbillemail = new \OxidEsales\Eshop\Core\Field('not@thepaypalmail.com');
|
||||
$order->oxorder__oxbillfname = new \OxidEsales\Eshop\Core\Field('Max');
|
||||
$order->oxorder__oxbillname = new \OxidEsales\Eshop\Core\Field('Muster');
|
||||
$order->oxorder__oxbillstreet = new \OxidEsales\Eshop\Core\Field('Blafööstraße');
|
||||
$order->oxorder__oxbillstreetnr = new \OxidEsales\Eshop\Core\Field('123');
|
||||
$order->oxorder__oxbillcity = new \OxidEsales\Eshop\Core\Field('Литовские');
|
||||
$order->oxorder__oxbillcountryid = new \OxidEsales\Eshop\Core\Field('a7c40f631fc920687.20179984');
|
||||
$order->oxorder__oxbillzip = new \OxidEsales\Eshop\Core\Field('22769');
|
||||
$order->oxorder__oxbillsal = new \OxidEsales\Eshop\Core\Field('MR');
|
||||
$order->oxorder__oxpaymentid = new \OxidEsales\Eshop\Core\Field('95700b639e4ef5e759bf6e3be4aabd44');
|
||||
$order->oxorder__oxpaymenttype = new \OxidEsales\Eshop\Core\Field('oxidpaypal');
|
||||
$order->oxorder__oxtotalnetsum = new \OxidEsales\Eshop\Core\Field(self::PAYMENT_AMOUNT / 1.19);
|
||||
$order->oxorder__oxtotalbrutsum = new \OxidEsales\Eshop\Core\Field(self::PAYMENT_AMOUNT);
|
||||
$order->oxorder__oxtotalordersum = new \OxidEsales\Eshop\Core\Field(self::PAYMENT_AMOUNT);
|
||||
$order->oxorder__oxartvat = new \OxidEsales\Eshop\Core\Field('19');
|
||||
$order->oxorder__oxvatartprice1 = new \OxidEsales\Eshop\Core\Field('4.77');
|
||||
$order->oxorder__oxcurrency = new \OxidEsales\Eshop\Core\Field('EUR');
|
||||
$order->oxorder__oxfolder = new \OxidEsales\Eshop\Core\Field('ORDERFOLDER_NEW');
|
||||
$order->oxorder__oxdeltype = new \OxidEsales\Eshop\Core\Field('standard');
|
||||
$order->oxorder__oxtransstatus = new \OxidEsales\Eshop\Core\Field($status);
|
||||
$order->oxorder__oxtransid = new \OxidEsales\Eshop\Core\Field(self::PAYPAL_AUTHID, \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$order->save();
|
||||
|
||||
//mocked to circumvent delivery address change md5 check from requestParameter
|
||||
$order->expects($this->any())->method('validateDeliveryAddress')->will($this->returnValue(0));
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create order in database by given ID.
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Model\PayPalOrder
|
||||
*/
|
||||
private function createPayPalOrder()
|
||||
{
|
||||
if (empty($this->testOrderId)) {
|
||||
$this->fail('please create related oxorder first');
|
||||
}
|
||||
|
||||
$paypalOrder = oxNew(\OxidEsales\PayPalModule\Model\PayPalOrder::class);
|
||||
$paypalOrder->setOrderId($this->testOrderId);
|
||||
$paypalOrder->setPaymentStatus('pending');
|
||||
$paypalOrder->setCapturedAmount(0.0);
|
||||
$paypalOrder->setTotalOrderSum(self::PAYMENT_AMOUNT);
|
||||
$paypalOrder->setCurrency(self::PAYMENT_CURRENCY);
|
||||
$paypalOrder->setTransactionMode('Authorization');
|
||||
$paypalOrder->save();
|
||||
|
||||
return $paypalOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create order payment authorization or capture.
|
||||
*
|
||||
* @param string $mode Chose type of orderpayment (authorization or capture)
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Model\OrderPayment::class
|
||||
*/
|
||||
private function createPayPalOrderPayment($mode = 'authorization')
|
||||
{
|
||||
if (empty($this->testOrderId)) {
|
||||
$this->fail('please create related oxorder first');
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data['authorization'] = array(
|
||||
'setAction' => 'authorization',
|
||||
'setTransactionId' => self::PAYPAL_AUTHID,
|
||||
'setAmount' => self::PAYMENT_AMOUNT,
|
||||
'setCurrency' => self::PAYMENT_CURRENCY,
|
||||
'setStatus' => 'Pending',
|
||||
'setCorrelationId' => self::AUTH_CORRELATION_ID,
|
||||
'setDate' => '2015-04-01 12:12:12'
|
||||
);
|
||||
$data['capture'] = array(
|
||||
'setAction' => 'capture',
|
||||
'setTransactionId' => self::PAYPAL_TRANSACTION_ID,
|
||||
'setAmount' => self::PAYMENT_AMOUNT,
|
||||
'setCurrency' => self::PAYMENT_CURRENCY,
|
||||
'setStatus' => 'Completed',
|
||||
'setCorrelationId' => self::PAYMENT_CORRELATION_ID,
|
||||
'setDate' => '2015-04-01 13:13:13'
|
||||
);
|
||||
|
||||
$paypalOrderPayment = oxNew(\OxidEsales\PayPalModule\Model\OrderPayment::class);
|
||||
$paypalOrderPayment->setOrderid($this->testOrderId);
|
||||
|
||||
foreach ($data[$mode] as $function => $argument) {
|
||||
$paypalOrderPayment->$function($argument);
|
||||
}
|
||||
$paypalOrderPayment->save();
|
||||
|
||||
return $paypalOrderPayment;
|
||||
}
|
||||
|
||||
/**
|
||||
* insert test user
|
||||
*/
|
||||
private function insertUser()
|
||||
{
|
||||
$this->testUserId = substr_replace(\OxidEsales\Eshop\Core\UtilsObject::getInstance()->generateUId(), '_', 0, 1);
|
||||
$user = oxNew(\OxidEsales\Eshop\Application\Model\User::class);
|
||||
$user->setId($this->testUserId);
|
||||
$user->oxuser__oxactive = new \OxidEsales\Eshop\Core\Field('1', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxrights = new \OxidEsales\Eshop\Core\Field('user', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxshopid = new \OxidEsales\Eshop\Core\Field(1, \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxusername = new \OxidEsales\Eshop\Core\Field('testuser@oxideshop.dev', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
//password is asdfasdf
|
||||
$user->oxuser__oxpassword = new \OxidEsales\Eshop\Core\Field('c630e7f6dd47f9ad60ece4492468149bfed3da3429940181464baae99941d0ffa5562' .
|
||||
'aaecd01eab71c4d886e5467c5fc4dd24a45819e125501f030f61b624d7d',
|
||||
\OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxpasssalt = new \OxidEsales\Eshop\Core\Field('3ddda7c412dbd57325210968cd31ba86', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxcustnr = new \OxidEsales\Eshop\Core\Field('666', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxfname = new \OxidEsales\Eshop\Core\Field('Max', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxlname = new \OxidEsales\Eshop\Core\Field('Muster', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxstreet = new \OxidEsales\Eshop\Core\Field('blafoostreet', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxstreetnr = new \OxidEsales\Eshop\Core\Field('123', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxcity = new \OxidEsales\Eshop\Core\Field('Freiburg', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxcountryid = new \OxidEsales\Eshop\Core\Field('a7c40f631fc920687.20179984', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxzip = new \OxidEsales\Eshop\Core\Field('22769', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxsal = new \OxidEsales\Eshop\Core\Field('MR', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxactive = new \OxidEsales\Eshop\Core\Field('1', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxboni = new \OxidEsales\Eshop\Core\Field('1000', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxcreate = new \OxidEsales\Eshop\Core\Field('2015-05-20 22:10:51', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxregister = new \OxidEsales\Eshop\Core\Field('2015-05-20 22:10:51', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->oxuser__oxboni = new \OxidEsales\Eshop\Core\Field('1000', \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
$user->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test helper for creating order with PayPal.
|
||||
*
|
||||
* @param array test data
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Model\OrderPayment::class
|
||||
*/
|
||||
private function getPayPalOrderPayment($data)
|
||||
{
|
||||
$paypalConfig = $this->getPayPalConfigMock();
|
||||
$lang = $paypalConfig->getLang();
|
||||
|
||||
//simulates IPN for capture
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Request::class);
|
||||
$mockBuilder->setMethods(['getPost']);
|
||||
$paypalRequest = $mockBuilder->getMock();
|
||||
$paypalRequest->expects($this->any())->method('getPost')->will($this->returnValue($data));
|
||||
|
||||
$paymentBuilder = oxNew(\OxidEsales\PayPalModule\Model\IPNPaymentBuilder::class);
|
||||
$paymentBuilder->setLang($lang);
|
||||
$paymentBuilder->setRequest($paypalRequest);
|
||||
|
||||
//expect the capture transaction to be stored in table oepaypal_orderpayments
|
||||
$orderPayment = $paymentBuilder->buildPayment();
|
||||
|
||||
return $orderPayment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test helper for creating order payment parent transaction with PayPal.
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Model\OrderPayment::class
|
||||
*/
|
||||
private function createPayPalOrderPaymentParent()
|
||||
{
|
||||
$orderPaymentParent = $this->createPayPalOrderPayment('authorization');
|
||||
$this->assertEquals('Pending', $orderPaymentParent->getStatus());
|
||||
return $orderPaymentParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test helper, creates order with paypal payment and all connected database entries.
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Model\PayPalOrder
|
||||
*/
|
||||
private function prepareFullOrder()
|
||||
{
|
||||
$this->insertUser();
|
||||
$this->createOrder();
|
||||
|
||||
$paypalOrder = $this->createPayPalOrder();
|
||||
|
||||
return $paypalOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test helper, processes IPN data.
|
||||
*
|
||||
* @param $data
|
||||
*/
|
||||
private function processIpn($data)
|
||||
{
|
||||
$paypalConfig = $this->getPayPalConfigMock();
|
||||
$lang = $paypalConfig->getLang();
|
||||
|
||||
foreach ($data as $post) {
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Request::class);
|
||||
$mockBuilder->setMethods(['getPost']);
|
||||
$paypalRequest = $mockBuilder->getMock();
|
||||
$paypalRequest->expects($this->any())->method('getPost')->will($this->returnValue($post));
|
||||
$processor = oxNew(\OxidEsales\PayPalModule\Model\IPNProcessor::class);
|
||||
$processor->setLang($lang);
|
||||
$processor->setRequest($paypalRequest);
|
||||
$processor->process();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
<?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\Tests\Integration\IPNRequestHandler;
|
||||
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
|
||||
class IPNHandlerTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/**
|
||||
* Setup: Prepare data - create need tables
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute('DROP TABLE IF EXISTS `oepaypal_order`');
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute('DROP TABLE IF EXISTS `oepaypal_orderpayments`');
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute('DROP TABLE IF EXISTS `oepaypal_orderpaymentcomments`');
|
||||
|
||||
\OxidEsales\PayPalModule\Core\Events::addOrderPaymentsTable();
|
||||
\OxidEsales\PayPalModule\Core\Events::addOrderTable();
|
||||
\OxidEsales\PayPalModule\Core\Events::addOrderPaymentsCommentsTable();
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function providerHandleRequest()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$realShopOwner = $config->getUserEmail();
|
||||
$notRealShopOwner = 'some12a1sd5@oxid-esales.com';
|
||||
|
||||
return array(
|
||||
// Correct values. Payment status changes to given from PayPal. Order status is calculated from payment.
|
||||
array($realShopOwner, array('VERIFIED' => true), true, 'completed', false
|
||||
, '__handleRequest_transaction', 124.45, 'EUR', 'Completed'
|
||||
, '__handleRequest_transaction', 124.45, 'EUR', 'Completed'),
|
||||
|
||||
// PayPal do not verifies request. Nothing changes.
|
||||
array($realShopOwner, array('Not-VERIFIED' => true), false, 'pending', false
|
||||
, '__handleRequest_transaction', 1.45, 'USD', 'Completed'
|
||||
, '__handleRequest_transaction', 124.45, 'EUR', 'Pending'),
|
||||
// Wrong Shop owner from PayPal. Data do not change.
|
||||
array($notRealShopOwner, array('VERIFIED' => true), false, 'pending', false
|
||||
, '__handleRequest_transaction', 121.45, 'EUR', 'Completed'
|
||||
, '__handleRequest_transaction', 124.45, 'EUR', 'Pending'),
|
||||
|
||||
// Wrong amount. Payment status get updated. Payment amount do not change. Order becomes failed.
|
||||
array($realShopOwner, array('VERIFIED' => true), true, 'failed', true
|
||||
, '__handleRequest_transaction', 121.45, 'EUR', 'Completed'
|
||||
, '__handleRequest_transaction', 124.45, 'EUR', 'Completed'),
|
||||
// Wrong currency. Payment status get updated. Payment currency do not change. Order becomes failed.
|
||||
array($realShopOwner, array('VERIFIED' => true), true, 'failed', true
|
||||
, '__handleRequest_transaction', 124.45, 'USD', 'Completed'
|
||||
, '__handleRequest_transaction', 124.45, 'EUR', 'Completed'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerHandleRequest
|
||||
*/
|
||||
public function testHandleRequest($shopOwnerPayPal, $responseFromPayPal, $requestHandledExpected, $OrderStatusAfterRequest, $failureMessageExist
|
||||
, $transactionIdPayPal, $paymentAmountPayPal, $paymentCurrencyPayPal, $paymentStatusPayPal
|
||||
, $transactionIdShop, $paymentAmountShop, $paymentCurrencyShop, $PaymentStatusAfterRequest)
|
||||
{
|
||||
$orderId = '__handleRequest_order';
|
||||
|
||||
$this->preparePayPalRequest($shopOwnerPayPal, $paymentStatusPayPal, $transactionIdPayPal, $paymentAmountPayPal, $paymentCurrencyPayPal);
|
||||
|
||||
$order = $this->createPayPalOrder($orderId);
|
||||
$this->createOrderPayment($orderId, $transactionIdShop, $paymentAmountShop, $paymentCurrencyShop);
|
||||
|
||||
// Mock curl so we do not call PayPal to check if request originally from PayPal.
|
||||
$ipnRequestVerifier = $this->createPayPalResponse($responseFromPayPal);
|
||||
|
||||
$payPalIPNHandler = new \OxidEsales\PayPalModule\Controller\IPNHandler();
|
||||
$payPalIPNHandler->setIPNRequestVerifier($ipnRequestVerifier);
|
||||
$payPalIPNHandler->handleRequest();
|
||||
|
||||
$logHelper = new \OxidEsales\PayPalModule\Tests\Unit\PayPalLogHelper();
|
||||
$logData = $logHelper->getLogData();
|
||||
$lastLogItem = end($logData);
|
||||
$requestHandled = $lastLogItem->data['Result'] == 'true';
|
||||
|
||||
$order->load();
|
||||
$payment = new \OxidEsales\PayPalModule\Model\OrderPayment();
|
||||
$payment->loadByTransactionId($transactionIdShop);
|
||||
$this->assertEquals($requestHandledExpected, $requestHandled, 'Request is not handled as expected.');
|
||||
$this->assertEquals($PaymentStatusAfterRequest, $payment->getStatus(), 'Status did not change to one returned from PayPal.');
|
||||
$this->assertEquals($OrderStatusAfterRequest, $order->getPaymentStatus(), 'Status did not change to one returned from PayPal.');
|
||||
$this->assertEquals($paymentAmountShop, $payment->getAmount(), 'Payment amount should not change to get from PayPal.');
|
||||
$this->assertEquals($paymentCurrencyShop, $payment->getCurrency(), 'Payment currency should not change to get from PayPal.');
|
||||
if (!$failureMessageExist) {
|
||||
$this->assertEquals(0, count($payment->getCommentList()), 'There should be no failure comment.');
|
||||
} else {
|
||||
$comments = $payment->getCommentList();
|
||||
$comments = $comments->getArray();
|
||||
$comment = $comments[0]->getComment();
|
||||
// Failure comment should have all information about request and original payment.
|
||||
$commentHasAllInformation = strpos($comment, (string) $paymentAmountPayPal) !== false
|
||||
&& strpos($comment, (string) $paymentCurrencyPayPal) !== false
|
||||
&& strpos($comment, (string) $paymentAmountShop) !== false
|
||||
&& strpos($comment, (string) $paymentCurrencyShop) !== false;
|
||||
$this->assertEquals(1, count($comments), 'There should failure comment.');
|
||||
$this->assertTrue($commentHasAllInformation, 'Failure comment should have all information about request and original payment: ' . $comment);
|
||||
}
|
||||
}
|
||||
|
||||
public function providerHandlingPendingRequest()
|
||||
{
|
||||
/** @var \OxidEsales\PayPalModule\Model\Order $order */
|
||||
$order = oxNew(Order::class);
|
||||
return array(
|
||||
array('Completed', $order::OEPAYPAL_TRANSACTION_STATUS_OK),
|
||||
array('Pending', $order::OEPAYPAL_TRANSACTION_STATUS_NOT_FINISHED),
|
||||
array('Failed', $order::OEPAYPAL_TRANSACTION_STATUS_NOT_FINISHED),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $payPalResponseStatus PayPal response status. Order transaction status depends on it.
|
||||
* @param string $transactionStatus Order transaction status. Will be checked if as expected.
|
||||
*
|
||||
* @dataProvider providerHandlingPendingRequest
|
||||
*/
|
||||
public function testHandlingTransactionStatusChange($payPalResponseStatus, $transactionStatus)
|
||||
{
|
||||
$config = oxNew(\OxidEsales\PayPalModule\Core\Config::class);
|
||||
$shopOwner = $config->getUserEmail();
|
||||
$transId = '__handleRequest_transaction';
|
||||
$orderId = '__handleRequest_order';
|
||||
|
||||
$this->preparePayPalRequest($shopOwner, $payPalResponseStatus, $transId, 0, '');
|
||||
|
||||
$this->createOrder($orderId, \OxidEsales\PayPalModule\Model\Order::OEPAYPAL_TRANSACTION_STATUS_NOT_FINISHED);
|
||||
$this->createPayPalOrder($orderId);
|
||||
$this->createOrderPayment($orderId, $transId, 0, '');
|
||||
|
||||
// Mock curl so we do not call PayPal to check if request originally from PayPal.
|
||||
$ipnRequestVerifier = $this->createPayPalResponse(array('VERIFIED' => true));
|
||||
|
||||
// Post imitates call from PayPal.
|
||||
$payPalIPNHandler = oxNew(\OxidEsales\PayPalModule\Controller\IPNHandler::class);
|
||||
$payPalIPNHandler->setIPNRequestVerifier($ipnRequestVerifier);
|
||||
$payPalIPNHandler->handleRequest();
|
||||
|
||||
$order = oxNew(\OxidEsales\Eshop\Application\Model\Order::class);
|
||||
$order->load($orderId);
|
||||
$this->assertEquals($transactionStatus, $order->getFieldData('oxtransstatus'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create order in database by given ID.
|
||||
*
|
||||
* @param string $orderId
|
||||
* @param string $status
|
||||
*
|
||||
* @return \OxidEsales\Eshop\Application\Model\Order
|
||||
*/
|
||||
protected function createOrder($orderId, $status)
|
||||
{
|
||||
$order = oxNew(\OxidEsales\Eshop\Application\Model\Order::class);
|
||||
$order->setId($orderId);
|
||||
$order->oxorder__oxtransstatus = new \OxidEsales\Eshop\Core\Field($status);
|
||||
$order->save();
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create order in database by given ID.
|
||||
*
|
||||
* @param string $orderId
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Model\PayPalOrder
|
||||
*/
|
||||
protected function createPayPalOrder($orderId)
|
||||
{
|
||||
/** @var \OxidEsales\PayPalModule\Model\PayPalOrder $order */
|
||||
$order = oxNew(\OxidEsales\PayPalModule\Model\PayPalOrder::class);
|
||||
$order->setOrderId($orderId);
|
||||
$order->setPaymentStatus('pending');
|
||||
$order->save();
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create order payment related with given order and with specific transaction id.
|
||||
*
|
||||
* @param string $orderId
|
||||
* @param string $transactionId
|
||||
* @param double $paymentAmount
|
||||
* @param string $paymentCurrency
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Model\OrderPayment::class
|
||||
*/
|
||||
protected function createOrderPayment($orderId, $transactionId, $paymentAmount, $paymentCurrency)
|
||||
{
|
||||
$orderPayment = oxNew(\OxidEsales\PayPalModule\Model\OrderPayment::class);
|
||||
$orderPayment->setOrderid($orderId);
|
||||
$orderPayment->setTransactionId($transactionId);
|
||||
$orderPayment->setAmount($paymentAmount);
|
||||
$orderPayment->setCurrency($paymentCurrency);
|
||||
$orderPayment->setStatus('Pending');
|
||||
$orderPayment->save();
|
||||
|
||||
return $orderPayment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Communication service do not call PayPal to check if request is from it.
|
||||
*
|
||||
* @param array $responseFromPayPal
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Model\IPNRequestVerifier
|
||||
*/
|
||||
protected function createPayPalResponse($responseFromPayPal)
|
||||
{
|
||||
$curl = $this->getPayPalCommunicationHelper()->getCurl($responseFromPayPal);
|
||||
|
||||
$caller = oxNew(\OxidEsales\PayPalModule\Core\Caller::class);
|
||||
$caller->setCurl($curl);
|
||||
|
||||
$communicationService = oxNew(\OxidEsales\PayPalModule\Core\PayPalService::class);
|
||||
$communicationService->setCaller($caller);
|
||||
|
||||
$ipnRequestVerifier = oxNew(\OxidEsales\PayPalModule\Model\IPNRequestVerifier::class);
|
||||
$ipnRequestVerifier->setCommunicationService($communicationService);
|
||||
|
||||
return $ipnRequestVerifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $shopOwnerPayPal
|
||||
* @param $paymentStatusPayPal
|
||||
* @param $transactionId
|
||||
* @param $paymentAmountPayPal
|
||||
* @param $paymentCurrencyPayPal
|
||||
*/
|
||||
public function preparePayPalRequest($shopOwnerPayPal, $paymentStatusPayPal, $transactionId, $paymentAmountPayPal, $paymentCurrencyPayPal)
|
||||
{
|
||||
$this->setRequestParameter('receiver_email', $shopOwnerPayPal);
|
||||
$this->setRequestParameter('payment_status', $paymentStatusPayPal);
|
||||
$this->setRequestParameter('txn_id', $transactionId);
|
||||
$this->setRequestParameter('mc_gross', $paymentAmountPayPal);
|
||||
$this->setRequestParameter('mc_currency', $paymentCurrencyPayPal);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OxidEsales\PayPalModule\Tests\Integration\Library\CommunicationHelper
|
||||
*/
|
||||
protected function getPayPalCommunicationHelper()
|
||||
{
|
||||
return oxNew(\OxidEsales\PayPalModule\Tests\Integration\Library\CommunicationHelper::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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\Tests\Integration\Library;
|
||||
|
||||
class ArrayAsserts extends \OxidEsales\PayPalModule\Tests\Integration\Library\IntegrationTestHelper
|
||||
{
|
||||
/**
|
||||
* Checks whether array length are equal and array keys and values are equal independent on keys position
|
||||
*
|
||||
* @param $expected
|
||||
* @param $result
|
||||
*/
|
||||
public function assertArraysEqual($expected, $result)
|
||||
{
|
||||
$this->assertArraysContains($expected, $result);
|
||||
$this->assertEquals(count($expected), count($result), 'Failed asserting that expected array has equal amount of elements with result array');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether array array keys and values are equal independent on keys position
|
||||
*
|
||||
* @param $expected
|
||||
* @param $result
|
||||
*/
|
||||
public function assertArraysContains($expected, $result)
|
||||
{
|
||||
$expectedNotMatched = array();
|
||||
$resultNotMatched = array();
|
||||
|
||||
foreach ($expected as $key => $value) {
|
||||
try {
|
||||
$this->assertArrayHasKey($key, $result);
|
||||
$this->assertEquals($value, $result[$key]);
|
||||
} catch (\Exception $exception) {
|
||||
$expectedNotMatched[$key] = $value;
|
||||
$resultNotMatched[$key] = $result[$key];
|
||||
}
|
||||
}
|
||||
$this->assertEquals($expectedNotMatched, $resultNotMatched, 'Values not matched in given arrays');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?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\Tests\Integration\Library;
|
||||
|
||||
class CommunicationHelper extends \OxidEsales\PayPalModule\Tests\Integration\Library\IntegrationTestHelper
|
||||
{
|
||||
/**
|
||||
* Returns loaded Caller object returning given parameters on call
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Core\PayPalService
|
||||
*/
|
||||
public function getCaller($params)
|
||||
{
|
||||
/**
|
||||
* @var \OxidEsales\PayPalModule\Core\Caller $caller
|
||||
*/
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Caller::class);
|
||||
$mockBuilder->setMethods(['call']);
|
||||
$caller = $mockBuilder->getMock();
|
||||
$caller->expects($this->any())->method('call')->will($this->returnValue($params));
|
||||
|
||||
$service = new \OxidEsales\PayPalModule\Core\PayPalService();
|
||||
$service->setCaller($caller);
|
||||
|
||||
return $service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stub curl to return expected result.
|
||||
*
|
||||
* @param array $result
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Core\Curl
|
||||
*/
|
||||
public function getCurl($result)
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Curl::class);
|
||||
$mockBuilder->setMethods(['execute']);
|
||||
$curl = $mockBuilder->getMock();
|
||||
$curl->expects($this->any())->method('execute')->will($this->returnValue($result));
|
||||
|
||||
return $curl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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\Tests\Integration\Library;
|
||||
|
||||
abstract class IntegrationTestHelper extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/**
|
||||
* The only way to skip this helper file with no errors
|
||||
*/
|
||||
public function testSkip()
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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\Tests\Integration\Library;
|
||||
|
||||
class RequestHelper extends \OxidEsales\PayPalModule\Tests\Integration\Library\IntegrationTestHelper
|
||||
{
|
||||
/**
|
||||
* Returns loaded \OxidEsales\PayPalModule\Core\Request object with given parameters
|
||||
*
|
||||
* @param array $postParams
|
||||
* @param array $getParams
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Core\Request
|
||||
*/
|
||||
public function getRequest($postParams = null, $getParams = null)
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Request::class);
|
||||
$mockBuilder->setMethods(['getPost', 'getGet']);
|
||||
$request = $mockBuilder->getMock();
|
||||
$request->expects($this->any())->method('getPost')->will($this->returnValue($postParams));
|
||||
$request->expects($this->any())->method('getGet')->will($this->returnValue($getParams));
|
||||
|
||||
return $request;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,725 @@
|
||||
<?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\Tests\Integration\Library;
|
||||
|
||||
use OxidEsales\Eshop\Application\Model\Basket;
|
||||
|
||||
class ShopConstruct
|
||||
{
|
||||
/**
|
||||
* @var \OxidEsales\Eshop\Application\Model\User
|
||||
*/
|
||||
protected $_oParams = null;
|
||||
|
||||
/**
|
||||
* @var \OxidEsales\Eshop\Application\Model\User
|
||||
*/
|
||||
protected $_oUser = null;
|
||||
|
||||
/**
|
||||
* @var null
|
||||
*/
|
||||
protected $_oGroups = null;
|
||||
|
||||
/**
|
||||
* Sets constructor parameters
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function setParams($params)
|
||||
{
|
||||
$this->_oParams = $params;
|
||||
$this->setConfigParameters();
|
||||
$this->setSessionParameters();
|
||||
$this->setRequestParameters();
|
||||
$this->setServerParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets constructor parameters
|
||||
*
|
||||
* @param null $key
|
||||
*
|
||||
* @return \OxidEsales\Eshop\Application\Model\User
|
||||
*/
|
||||
public function getParams($key = null)
|
||||
{
|
||||
if (!is_null($key)) {
|
||||
return $this->_oParams[$key];
|
||||
}
|
||||
|
||||
return $this->_oParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \OxidEsales\Eshop\Application\Model\User $user
|
||||
*/
|
||||
public function setUser($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OxidEsales\Eshop\Application\Model\User
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
if (is_null($this->user)) {
|
||||
$user = $this->getParams('user');
|
||||
if ($user === false) {
|
||||
return null;
|
||||
}
|
||||
if (!$user) {
|
||||
$user = $this->getDefaultUserData();
|
||||
}
|
||||
$this->setUser($this->createUser($user));
|
||||
}
|
||||
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \OxidEsales\Eshop\Application\Model\User $groups
|
||||
*/
|
||||
public function setGroups($groups)
|
||||
{
|
||||
$this->_oGroups = $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OxidEsales\Eshop\Application\Model\User
|
||||
*/
|
||||
public function getGroups()
|
||||
{
|
||||
if (is_null($this->_oGroups)) {
|
||||
$groups = $this->getParams('groups');
|
||||
if ($groups === false) {
|
||||
return null;
|
||||
}
|
||||
if (!$groups) {
|
||||
$groups = $this->getDefaultGroupsData();
|
||||
}
|
||||
$this->setGroups($this->createGroups($groups));
|
||||
}
|
||||
|
||||
return $this->_oGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set config options
|
||||
*/
|
||||
public function setConfigParameters()
|
||||
{
|
||||
$config = \OxidEsales\Eshop\Core\Registry::getConfig();
|
||||
$params = $this->getParams('config');
|
||||
if (!empty($params)) {
|
||||
foreach ($params as $key => $value) {
|
||||
$config->setConfigParam($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set config options
|
||||
*/
|
||||
public function setSessionParameters()
|
||||
{
|
||||
$session = \OxidEsales\Eshop\Core\Registry::getSession();
|
||||
$params = $this->getParams('session');
|
||||
if (is_array($params)) {
|
||||
foreach ($params as $name => $value) {
|
||||
$session->setVariable($name, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set config options
|
||||
*/
|
||||
public function setRequestParameters()
|
||||
{
|
||||
$params = $this->getParams('requestToShop');
|
||||
if (is_array($params)) {
|
||||
$_POST = $params;
|
||||
$_GET = $params;
|
||||
$_COOKIE = $params;
|
||||
$_REQUEST = $params;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set config options
|
||||
*/
|
||||
public function setServerParameters()
|
||||
{
|
||||
if ($serverParams = $this->getParams('serverParams')) {
|
||||
foreach ($serverParams as $key => $value) {
|
||||
$_SERVER[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns prepared basket, user and config.
|
||||
*
|
||||
* @return \OxidEsales\Eshop\Application\Model\Basket
|
||||
*/
|
||||
public function getBasket()
|
||||
{
|
||||
$this->createCats($this->getParams('categories'));
|
||||
$this->setDiscounts($this->getParams('discounts'));
|
||||
|
||||
$costs = $this->getParams('costs');
|
||||
$deliverySetId = $this->setDeliveryCosts($costs['delivery']);
|
||||
$payment = $this->setPayments($costs['payment']);
|
||||
$voucherIDs = $this->setVouchers($costs['voucherserie']);
|
||||
|
||||
$basket = oxNew(Basket::class);
|
||||
|
||||
$basket->setBasketUser($this->getUser());
|
||||
|
||||
$this->getGroups();
|
||||
|
||||
$artsForBasket = $this->createArticles($this->getParams('articles'));
|
||||
$wrap = $this->setWrappings($costs['wrapping']);
|
||||
foreach ($artsForBasket as $art) {
|
||||
if (!$art['amount']) {
|
||||
continue;
|
||||
}
|
||||
$item = $basket->addToBasket($art['id'], $art['amount']);
|
||||
|
||||
if (!empty($wrap)) {
|
||||
$item->setWrapping($wrap[$art['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
$wrap['card'] ? $basket->setCardId($wrap['card']) : '';
|
||||
|
||||
if (!empty($deliverySetId) && !$costs['delivery']['oxdeliveryset']['createOnly']) {
|
||||
$basket->setShipping($deliverySetId);
|
||||
}
|
||||
|
||||
if (!empty($payment)) {
|
||||
$basket->setPayment($payment[0]);
|
||||
}
|
||||
|
||||
$basket->setSkipVouchersChecking(true);
|
||||
if (!empty($voucherIDs)) {
|
||||
$count = count($voucherIDs);
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$basket->addVoucher($voucherIDs[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$basket->calculateBasket();
|
||||
|
||||
return $basket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates articles from array
|
||||
*
|
||||
* @param array $articleDataSet
|
||||
*
|
||||
* @return array $result of id's and basket amounts of created articles
|
||||
*/
|
||||
public function createArticles($articleDataSet)
|
||||
{
|
||||
$result = array();
|
||||
if (empty($articleDataSet)) {
|
||||
return $result;
|
||||
}
|
||||
foreach ($articleDataSet as $articleData) {
|
||||
$article = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
|
||||
$article->setId($articleData['oxid']);
|
||||
foreach ($articleData as $key => $value) {
|
||||
if (strstr($key, "ox")) {
|
||||
$field = "oxarticles__{$key}";
|
||||
$article->$field = new \OxidEsales\Eshop\Core\Field($articleData[$key]);
|
||||
}
|
||||
}
|
||||
$article->save();
|
||||
if ($articleData['scaleprices']) {
|
||||
$this->createScalePrices(array($articleData['scaleprices']));
|
||||
}
|
||||
if ($articleData['field2shop']) {
|
||||
$this->createField2Shop($article, $articleData['field2shop']);
|
||||
}
|
||||
$result[$articleData['oxid']] = array(
|
||||
'id' => $articleData['oxid'],
|
||||
'amount' => $articleData['amount'],
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create user
|
||||
*
|
||||
* @param array $userData user data
|
||||
*
|
||||
* @return \OxidEsales\Eshop\Application\Model\User
|
||||
*/
|
||||
protected function createUser($userData)
|
||||
{
|
||||
/** @var \OxidEsales\Eshop\Application\Model\User $user */
|
||||
$user = $this->createObj($userData, \OxidEsales\Eshop\Application\Model\User::class, "oxuser");
|
||||
if (isset($userData['address'])) {
|
||||
$userData['address']['oxuserid'] = $user->getId();
|
||||
$this->createObj($userData['address'], \OxidEsales\Eshop\Application\Model\Address::class, "oxaddress");
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create categories with assigning articles
|
||||
*
|
||||
* @param array $categories category data
|
||||
*/
|
||||
protected function createCats($categories)
|
||||
{
|
||||
if (empty($categories)) {
|
||||
return;
|
||||
}
|
||||
foreach ($categories as $key => $cat) {
|
||||
$cat = $this->createObj($cat, \OxidEsales\Eshop\Application\Model\Category::class, ' oxcategories');
|
||||
if (!empty($cat['oxarticles'])) {
|
||||
$cnt = count($cat['oxarticles']);
|
||||
for ($i = 0; $i < $cnt; $i++) {
|
||||
$data = array(
|
||||
'oxcatnid' => $cat->getId(),
|
||||
'oxobjectid' => $cat['oxarticles'][$i]
|
||||
);
|
||||
$this->createObj2Obj($data, 'oxprice2article');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates price 2 article connection needed for scale prices
|
||||
*
|
||||
* @param array $scalePrices of scale prices needed db fields
|
||||
*/
|
||||
protected function createScalePrices($scalePrices)
|
||||
{
|
||||
$this->createObj2Obj($scalePrices, "oxprice2article");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates price 2 article connection needed for scale prices
|
||||
*
|
||||
* @param \OxidEsales\Eshop\Application\Model\Article $art
|
||||
* @param array $options
|
||||
*/
|
||||
protected function createField2Shop($art, $options)
|
||||
{
|
||||
$field2Shop = oxNew(\OxidEsales\Eshop\Application\Model\Field2Shop::class);
|
||||
$field2Shop->setProductData($art);
|
||||
if (!isset($options['oxartid'])) {
|
||||
$options['oxartid'] = new \OxidEsales\Eshop\Core\Field($art->getId());
|
||||
}
|
||||
foreach ($options as $key => $value) {
|
||||
if (strstr($key, "ox")) {
|
||||
$field = "oxfield2shop__{$key}";
|
||||
$field2Shop->$field = new \OxidEsales\Eshop\Core\Field($options[$key]);
|
||||
}
|
||||
}
|
||||
$field2Shop->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply discounts.
|
||||
* Creates discounts and assign them to according objects.
|
||||
*
|
||||
* @param array $discountDataSet discount data
|
||||
*/
|
||||
public function setDiscounts($discountDataSet)
|
||||
{
|
||||
if (empty($discountDataSet)) {
|
||||
return;
|
||||
}
|
||||
foreach ($discountDataSet as $discountData) {
|
||||
// add discounts
|
||||
$discount = oxNew(\OxidEsales\Eshop\Application\Model\Discount::class);
|
||||
$discount->setId($discountData['oxid']);
|
||||
foreach ($discountData as $key => $value) {
|
||||
if (!is_array($value)) {
|
||||
$field = "oxdiscount__" . $key;
|
||||
$discount->$field = new \OxidEsales\Eshop\Core\Field("{$value}");
|
||||
} // if $value is not empty array then create oxobject2discount
|
||||
$discount->save();
|
||||
if (is_array($value) && !empty($value)) {
|
||||
foreach ($value as $artId) {
|
||||
$data = array(
|
||||
'oxid' => $discount->getId() . "_" . $artId,
|
||||
'oxdiscountid' => $discount->getId(),
|
||||
'oxobjectid' => $artId,
|
||||
'oxtype' => $key
|
||||
);
|
||||
$this->createObj2Obj($data, "oxobject2discount");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates wrappings
|
||||
*
|
||||
* @param array $wrappings
|
||||
*
|
||||
* @return false|array of wrapping id's
|
||||
*/
|
||||
protected function setWrappings($wrappings)
|
||||
{
|
||||
if (empty($wrappings)) {
|
||||
return false;
|
||||
}
|
||||
$wrap = array();
|
||||
foreach ($wrappings as $wrapping) {
|
||||
$card = oxNew(\OxidEsales\Eshop\Core\Model\BaseModel::class);
|
||||
$card->init('oxwrapping');
|
||||
foreach ($wrapping as $key => $mxValue) {
|
||||
if (!is_array($mxValue)) {
|
||||
$field = "oxwrapping__" . $key;
|
||||
$card->$field = new \OxidEsales\Eshop\Core\Field($mxValue, \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
}
|
||||
}
|
||||
$card->save();
|
||||
if ($wrapping['oxarticles']) {
|
||||
foreach ($wrapping['oxarticles'] as $artId) {
|
||||
$wrap[$artId] = $card->getId();
|
||||
}
|
||||
} else {
|
||||
$wrap['card'] = $card->getId();
|
||||
}
|
||||
}
|
||||
|
||||
return $wrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates deliveries
|
||||
*
|
||||
* @param array $deliveryCostDataSet
|
||||
*
|
||||
* @return null|array of delivery id's
|
||||
*/
|
||||
protected function setDeliveryCosts($deliveryCostDataSet)
|
||||
{
|
||||
if (empty($deliveryCostDataSet)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($deliveryCostDataSet['oxdeliveryset'])) {
|
||||
$data = $deliveryCostDataSet['oxdeliveryset'];
|
||||
unset($deliveryCostDataSet['oxdeliveryset']);
|
||||
} else {
|
||||
$data = array(
|
||||
'oxactive' => 1
|
||||
);
|
||||
}
|
||||
$deliverySet = $this->createObj($data, \OxidEsales\Eshop\Application\Model\DeliverySet::class, 'oxdeliveryset');
|
||||
|
||||
foreach ($deliveryCostDataSet as $deliveryCostData) {
|
||||
$delivery = oxNew(\OxidEsales\Eshop\Application\Model\Delivery::class);
|
||||
foreach ($deliveryCostData as $key => $value) {
|
||||
if (!is_array($value)) {
|
||||
$field = "oxdelivery__" . $key;
|
||||
$delivery->$field = new \OxidEsales\Eshop\Core\Field("{$value}");
|
||||
}
|
||||
}
|
||||
$delivery->save();
|
||||
$data = array(
|
||||
'oxdelid' => $delivery->getId(),
|
||||
'oxdelsetid' => $deliverySet->getId(),
|
||||
);
|
||||
$this->createObj2Obj($data, "oxdel2delset");
|
||||
}
|
||||
|
||||
return $deliverySet->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates payments
|
||||
*
|
||||
* @param array $paymentDataSet
|
||||
*
|
||||
* @return false|array of payment id's
|
||||
*/
|
||||
protected function setPayments($paymentDataSet)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
if (empty($paymentDataSet)) {
|
||||
return false;
|
||||
}
|
||||
$payments = array();
|
||||
foreach ($paymentDataSet as $paymentData) {
|
||||
// add discounts
|
||||
$payment = oxNew(\OxidEsales\Eshop\Application\Model\Payment::class);
|
||||
if (isset($paymentData['oxid'])) {
|
||||
$payment->setId($paymentData['oxid']);
|
||||
}
|
||||
foreach ($paymentData as $key => $value) {
|
||||
if (!is_array($value)) {
|
||||
$field = "oxpayments__" . $key;
|
||||
$payment->$field = new \OxidEsales\Eshop\Core\Field("{$value}");
|
||||
}
|
||||
}
|
||||
$payment->save();
|
||||
$result[] = $payment->getId();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates voucherserie and it's vouchers
|
||||
*
|
||||
* @param array $voucherSeriesDataSet voucherserie and voucher data
|
||||
*
|
||||
* @return array of voucher id's
|
||||
*/
|
||||
protected function setVouchers($voucherSeriesDataSet)
|
||||
{
|
||||
$voucherIDs = array();
|
||||
|
||||
$voucherSeriesDataSet = (array) $voucherSeriesDataSet;
|
||||
foreach ($voucherSeriesDataSet as $voucherSeriesData) {
|
||||
$voucherSeries = oxNew('oxBase');
|
||||
$voucherSeries->init('oxvoucherseries');
|
||||
foreach ($voucherSeriesData as $key => $value) {
|
||||
$field = "oxvoucherseries__" . $key;
|
||||
$voucherSeries->$field = new \oxField($value, \oxField::T_RAW);
|
||||
}
|
||||
$voucherSeries->save();
|
||||
// inserting vouchers
|
||||
for ($i = 1; $i <= $voucherSeriesData['voucher_count']; $i++) {
|
||||
$data = array(
|
||||
'oxreserved' => 0,
|
||||
'oxvouchernr' => md5(uniqid(rand(), true)),
|
||||
'oxvoucherserieid' => $voucherSeries->getId()
|
||||
);
|
||||
$voucher = $this->createObj($data, 'oxvoucher', 'oxvouchers');
|
||||
$voucherIDs[] = $voucher->getId();
|
||||
}
|
||||
}
|
||||
|
||||
return $voucherIDs;
|
||||
}
|
||||
|
||||
protected function getDefaultUserData()
|
||||
{
|
||||
$user = array(
|
||||
'oxid' => 'checkoutTestUser',
|
||||
'oxrights' => 'malladmin',
|
||||
'oxactive' => '1',
|
||||
'oxusername' => 'admin',
|
||||
'oxpassword' => 'f6fdffe48c908deb0f4c3bd36c032e72',
|
||||
'oxpasssalt' => '61646D696E',
|
||||
'oxcompany' => 'Your Company Name',
|
||||
'oxfname' => 'John',
|
||||
'oxlname' => 'Doe',
|
||||
'oxstreet' => 'Maple Street',
|
||||
'oxstreetnr' => '10',
|
||||
'oxcity' => 'Any City',
|
||||
'oxcountryid' => 'a7c40f631fc920687.20179984',
|
||||
'oxzip' => '9041',
|
||||
'oxfon' => '217-8918712',
|
||||
'oxfax' => '217-8918713',
|
||||
'oxstateid' => null,
|
||||
'oxaddinfo' => null,
|
||||
'oxustid' => null,
|
||||
'oxsal' => 'MR',
|
||||
'oxustidstatus' => '0',
|
||||
);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
protected function getDefaultGroupsData()
|
||||
{
|
||||
$group = array(
|
||||
0 => array(
|
||||
'oxid' => 'checkoutTestGroup',
|
||||
'oxactive' => 1,
|
||||
'oxtitle' => 'checkoutTestGroup',
|
||||
'oxobject2group' => array('checkoutTestUser', 'oxidpaypal'),
|
||||
),
|
||||
);
|
||||
|
||||
return $group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting articles
|
||||
*
|
||||
* @param array $arts of article objects
|
||||
*
|
||||
* @return created articles id's
|
||||
*/
|
||||
public function getArticles($arts)
|
||||
{
|
||||
return $this->_getArticles($arts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply discounts
|
||||
*
|
||||
* @param array $discounts of discount data
|
||||
*/
|
||||
public function DELETEsetDiscounts($discounts)
|
||||
{
|
||||
$this->setDiscounts($discounts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create object 2 object connection in databse
|
||||
*
|
||||
* @param array $data db fields and values
|
||||
* @param string $obj2ObjTable table name
|
||||
*/
|
||||
public function createObj2Obj($data, $obj2ObjTable)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return;
|
||||
}
|
||||
$count = count($data);
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if ($obj2ObjTable === 'oxobject2group') {
|
||||
$object = oxNew(\OxidEsales\Eshop\Application\Model\Object2Group::class);
|
||||
} else {
|
||||
$object = oxNew(\OxidEsales\Eshop\Core\Model\BaseModel::class);
|
||||
}
|
||||
$object->init($obj2ObjTable);
|
||||
if ($count < 2) {
|
||||
$objectData = $data[$i];
|
||||
} else {
|
||||
$objectData = $data;
|
||||
}
|
||||
foreach ($objectData as $key => $value) {
|
||||
$field = $obj2ObjTable . "__" . $key;
|
||||
$object->$field = new \OxidEsales\Eshop\Core\Field($value, \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
}
|
||||
$object->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create group and assign
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function createGroups($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return;
|
||||
}
|
||||
foreach ($data as $key => $groupData) {
|
||||
$group = $this->createObj($groupData, \OxidEsales\Eshop\Application\Model\Groups::class, ' oxgroups');
|
||||
if (!empty($groupData['oxobject2group'])) {
|
||||
$cnt = count($groupData['oxobject2group']);
|
||||
for ($i = 0; $i < $cnt; $i++) {
|
||||
$con = array(
|
||||
'oxgroupsid' => $group->getId(),
|
||||
'oxobjectid' => $groupData['oxobject2group'][$i]
|
||||
);
|
||||
$this->createObj2Obj($con, 'oxobject2group');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard object creator
|
||||
*
|
||||
* @param array $data data
|
||||
* @param string $object object name
|
||||
* @param string $table table name
|
||||
*
|
||||
* @return null|object $obj
|
||||
*/
|
||||
public function createObj($data, $object, $table)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return;
|
||||
}
|
||||
$obj = new $object();
|
||||
if ($data['oxid']) {
|
||||
$obj->setId($data['oxid']);
|
||||
}
|
||||
foreach ($data as $key => $value) {
|
||||
if (!is_array($value)) {
|
||||
$field = $table . "__" . $key;
|
||||
$obj->$field = new \OxidEsales\Eshop\Core\Field($value, \OxidEsales\Eshop\Core\Field::T_RAW);
|
||||
}
|
||||
}
|
||||
$obj->save();
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create shop.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function createShop($data)
|
||||
{
|
||||
$activeShopId = 1;
|
||||
$shopCnt = count($data);
|
||||
for ($i = 0; $i < $shopCnt; $i++) {
|
||||
$params = array();
|
||||
foreach ($data[$i] as $key => $value) {
|
||||
$field = "oxshops__" . $key;
|
||||
$params[$field] = $value;
|
||||
}
|
||||
$shop = oxNew(\OxidEsales\Eshop\Application\Model\Shop::class);
|
||||
$shop->assign($params);
|
||||
$shop->save();
|
||||
$shop->generateViews();
|
||||
if ($data[$i]['activeshop']) {
|
||||
$activeShopId = $shop->getId();
|
||||
}
|
||||
}
|
||||
|
||||
return $activeShopId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting active shop
|
||||
*
|
||||
* @param int $shopId
|
||||
*/
|
||||
public function setActiveShop($shopId)
|
||||
{
|
||||
if ($shopId) {
|
||||
\OxidEsales\Eshop\Core\Registry::getConfig()->setShopId($shopId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
<?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\Tests\Integration\Library;
|
||||
|
||||
class TestCaseParser
|
||||
{
|
||||
/**
|
||||
* Directory where to search for test cases
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_sDirectory = null;
|
||||
|
||||
/**
|
||||
* Test cases filter. Specify names of cases which should be run
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_aTestCases = array();
|
||||
|
||||
/** @var string */
|
||||
protected $_sTestCasesPath = '';
|
||||
|
||||
/**
|
||||
* Array of replacements for test values.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_aReplacements = array();
|
||||
|
||||
/**
|
||||
* Sets directory to search for test cases
|
||||
*
|
||||
* @param string $directory
|
||||
*/
|
||||
public function setDirectory($directory)
|
||||
{
|
||||
$this->_sDirectory = $directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns directory to search for test cases
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDirectory()
|
||||
{
|
||||
return $this->_sDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets test cases to be run
|
||||
*
|
||||
* @param array $testCases
|
||||
*/
|
||||
public function setTestCases($testCases)
|
||||
{
|
||||
$this->_aTestCases = $testCases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns test cases to be run
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTestCases()
|
||||
{
|
||||
return $this->_aTestCases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Replacement
|
||||
*
|
||||
* @param array $replacements
|
||||
*/
|
||||
public function setReplacements($replacements)
|
||||
{
|
||||
$this->_aReplacements = $replacements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Replacement
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReplacements()
|
||||
{
|
||||
return $this->_aReplacements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting test cases from specified
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
$testCasesData = array();
|
||||
$directory = $this->getDirectory();
|
||||
$testCases = $this->getTestCases();
|
||||
|
||||
$files = $this->getDirectoryTestCasesFiles($directory, $testCases);
|
||||
print(count($files) . " test files found\r\n");
|
||||
foreach ($files as $filename) {
|
||||
$data = $this->getDataFromFile($filename);
|
||||
$data = $this->parseTestData($data);
|
||||
$testCasesData[$filename] = array($data);
|
||||
}
|
||||
|
||||
return $testCasesData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns directory files. If test cases is passed - only those files is checked in given directory
|
||||
*
|
||||
* @param $dir
|
||||
* @param $testCases
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getDirectoryTestCasesFiles($dir, $testCases)
|
||||
{
|
||||
$path = $this->_sTestCasesPath . $dir . "/";
|
||||
print("Scanning dir {$path}\r\n");
|
||||
$files = array();
|
||||
if (empty($testCases)) {
|
||||
$files = $this->getFilesInDirectory($path);
|
||||
} else {
|
||||
foreach ($testCases as $testCase) {
|
||||
$files[] = $path . $testCase;
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns php files list from given directory and all subdirectories
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getFilesInDirectory($path)
|
||||
{
|
||||
$files = array();
|
||||
foreach (new \DirectoryIterator($path) as $file) {
|
||||
if ($file->isDir() && !$file->isDot()) {
|
||||
$files = array_merge($files, $this->getFilesInDirectory($file->getPathname()));
|
||||
}
|
||||
if ($file->isFile() && preg_match('/\.php$/', $file->getFilename())) {
|
||||
$files[] = $file->getPathname();
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads data from file
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getDataFromFile($filename)
|
||||
{
|
||||
$data = array();
|
||||
include($filename);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses given data
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function parseTestData($data)
|
||||
{
|
||||
foreach ($data as &$value) {
|
||||
$value = $this->parseTestValue($value);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses given test case value
|
||||
*
|
||||
* @param $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function parseTestValue($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
return $this->parseTestData($value);
|
||||
}
|
||||
if (is_string($value)) {
|
||||
$replacements = $this->getReplacements();
|
||||
$value = str_replace(array_keys($replacements), $replacements, $value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
<?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\Tests\Integration;
|
||||
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
|
||||
class OrderActionTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute('DROP TABLE IF EXISTS `oepaypal_orderpaymentcomments`');
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute('DROP TABLE IF EXISTS `oepaypal_orderpayments`');
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute('DROP TABLE IF EXISTS `oepaypal_order`');
|
||||
|
||||
\OxidEsales\PayPalModule\Core\Events::addOrderPaymentsCommentsTable();
|
||||
\OxidEsales\PayPalModule\Core\Events::addOrderPaymentsTable();
|
||||
\OxidEsales\PayPalModule\Core\Events::addOrderTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\OrderCaptureAction::process
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\Handler\OrderCaptureActionHandler::getPayPalResponse
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\Handler\OrderCaptureActionHandler::getPayPalRequest
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\Data\OrderCaptureActionData::getAmount
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\Data\OrderCaptureActionData::getType
|
||||
*/
|
||||
public function testActionCapture()
|
||||
{
|
||||
$requestParams = array(
|
||||
'capture_amount' => '200.99',
|
||||
'capture_type' => 'Complete'
|
||||
);
|
||||
$responseParams = array(
|
||||
'TRANSACTIONID' => 'TransactionId',
|
||||
'PAYMENTSTATUS' => 'Pending',
|
||||
'AMT' => '99.87',
|
||||
'CURRENCYCODE' => 'EUR',
|
||||
);
|
||||
|
||||
$action = $this->createAction('capture', 'testOrderId', $requestParams, $responseParams);
|
||||
|
||||
$action->process();
|
||||
|
||||
$order = $this->getOrder('testOrderId');
|
||||
$this->assertEquals('99.87', $order->getCapturedAmount());
|
||||
|
||||
$paymentList = $order->getPaymentList()->getArray();
|
||||
$this->assertEquals(1, count($paymentList));
|
||||
|
||||
$payment = array_shift($paymentList);
|
||||
$this->assertEquals('capture', $payment->getAction());
|
||||
$this->assertEquals('testOrderId', $payment->getOrderId());
|
||||
$this->assertEquals('99.87', $payment->getAmount());
|
||||
$this->assertEquals('Pending', $payment->getStatus());
|
||||
$this->assertEquals('EUR', $payment->getCurrency());
|
||||
|
||||
$payment->delete();
|
||||
$order->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\OrderRefundAction::process
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\Handler\OrderRefundActionHandler::getPayPalResponse
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\Handler\OrderRefundActionHandler::getPayPalRequest
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\Data\OrderRefundActionData::getAmount
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\Data\OrderRefundActionData::getType
|
||||
*/
|
||||
public function testActionRefund()
|
||||
{
|
||||
$requestParams = array(
|
||||
'refund_amount' => '10',
|
||||
'refund_type' => 'Complete',
|
||||
'transaction_id' => 'capturedTransaction'
|
||||
);
|
||||
$responseParams = array(
|
||||
'REFUNDTRANSACTIONID' => 'TransactionId',
|
||||
'REFUNDSTATUS' => 'Pending',
|
||||
'GROSSREFUNDAMT' => '9.01',
|
||||
'CURRENCYCODE' => 'EUR',
|
||||
);
|
||||
|
||||
$capturedPayment = new \OxidEsales\PayPalModule\Model\OrderPayment();
|
||||
$capturedPayment->setOrderId('testOrderId');
|
||||
$capturedPayment->setTransactionId('capturedTransaction');
|
||||
$capturedPayment->save();
|
||||
|
||||
$action = $this->createAction('refund', 'testOrderId', $requestParams, $responseParams);
|
||||
|
||||
$action->process();
|
||||
|
||||
$order = $this->getOrder('testOrderId');
|
||||
$this->assertEquals('9.01', $order->getRefundedAmount());
|
||||
|
||||
$paymentList = $order->getPaymentList()->getArray();
|
||||
$this->assertEquals(2, count($paymentList));
|
||||
|
||||
$payment = array_shift($paymentList);
|
||||
$this->assertEquals('refund', $payment->getAction());
|
||||
$this->assertEquals('testOrderId', $payment->getOrderId());
|
||||
$this->assertEquals('9.01', $payment->getAmount());
|
||||
$this->assertEquals('Pending', $payment->getStatus());
|
||||
$this->assertEquals('EUR', $payment->getCurrency());
|
||||
|
||||
$capturedPayment = array_shift($paymentList);
|
||||
$this->assertEquals('9.01', $capturedPayment->getRefundedAmount());
|
||||
|
||||
$payment->delete();
|
||||
$capturedPayment->delete();
|
||||
$order->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers oePayPalOrderReauthorizeAction::process
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\Handler\OrderReauthorizeActionHandler::getPayPalResponse
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\Handler\OrderReauthorizeActionHandler::getPayPalRequest
|
||||
*/
|
||||
public function ___testActionReauthorize()
|
||||
{
|
||||
$responseParams = array(
|
||||
'AUTHORIZATIONID' => 'AuthorizationId',
|
||||
'PAYMENTSTATUS' => 'Complete',
|
||||
);
|
||||
|
||||
$action = $this->createAction('reauthorize', 'testOrderId', array(), $responseParams);
|
||||
$action->process();
|
||||
|
||||
$order = $this->getOrder('testOrderId');
|
||||
|
||||
$paymentList = $order->getPaymentList()->getArray();
|
||||
$this->assertEquals(1, count($paymentList));
|
||||
|
||||
$payment = array_shift($paymentList);
|
||||
$this->assertEquals('re-authorization', $payment->getAction());
|
||||
$this->assertEquals('testOrderId', $payment->getOrderId());
|
||||
$this->assertEquals('0.00', $payment->getAmount());
|
||||
$this->assertEquals('Complete', $payment->getStatus());
|
||||
|
||||
$payment->delete();
|
||||
$order->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\OrderVoidAction::process
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\Handler\OrderVoidActionHandler::getPayPalResponse
|
||||
* @covers \OxidEsales\PayPalModule\Model\Action\Handler\OrderVoidActionHandler::getPayPalRequest
|
||||
*/
|
||||
public function testActionVoid()
|
||||
{
|
||||
$responseParams = array(
|
||||
'AUTHORIZATIONID' => 'AuthorizationId',
|
||||
);
|
||||
|
||||
$action = $this->createAction('void', 'testOrderId', array(), $responseParams);
|
||||
$action->process();
|
||||
|
||||
$order = $this->getOrder('testOrderId');
|
||||
|
||||
$paymentList = $order->getPaymentList()->getArray();
|
||||
$this->assertEquals(1, count($paymentList));
|
||||
|
||||
$payment = array_shift($paymentList);
|
||||
$this->assertEquals('void', $payment->getAction());
|
||||
$this->assertEquals('testOrderId', $payment->getOrderId());
|
||||
$this->assertEquals('0.00', $payment->getAmount());
|
||||
$this->assertEquals('Voided', $payment->getStatus());
|
||||
|
||||
$payment->delete();
|
||||
$order->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns loaded \OxidEsales\PayPalModule\Model\Action\OrderAction object
|
||||
*
|
||||
* @param string $action
|
||||
* @param string $orderId
|
||||
* @param array $requestParams
|
||||
* @param array $responseParams
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Model\Action\OrderAction
|
||||
*/
|
||||
protected function createAction($action, $orderId, $requestParams, $responseParams)
|
||||
{
|
||||
$order = $this->getOrder($orderId);
|
||||
$request = $this->getRequestHelper()->getRequest($requestParams);
|
||||
|
||||
$actionFactory = $this->getActionFactory($request, $order);
|
||||
$action = $actionFactory->createAction($action);
|
||||
|
||||
$service = $this->getPayPalCommunicationHelper()->getCaller($responseParams);
|
||||
$captureHandler = $action->getHandler();
|
||||
$captureHandler->setPayPalService($service);
|
||||
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OxidEsales\PayPalModule\Tests\Integration\Library\RequestHelper
|
||||
*/
|
||||
protected function getRequestHelper()
|
||||
{
|
||||
return new \OxidEsales\PayPalModule\Tests\Integration\Library\RequestHelper();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OxidEsales\PayPalModule\Tests\Integration\Library\CommunicationHelper
|
||||
*/
|
||||
protected function getPayPalCommunicationHelper()
|
||||
{
|
||||
return new \OxidEsales\PayPalModule\Tests\Integration\Library\CommunicationHelper();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns loaded \OxidEsales\PayPalModule\Model\PayPalOrder object with given id
|
||||
*
|
||||
* @param string $orderId
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Model\PayPalOrder
|
||||
*/
|
||||
protected function getOrder($orderId)
|
||||
{
|
||||
$order = new \OxidEsales\PayPalModule\Model\PayPalOrder();
|
||||
$order->setOrderId($orderId);
|
||||
$order->load();
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \OxidEsales\PayPalModule\Core\Request $request
|
||||
* @param \OxidEsales\PayPalModule\Model\PayPalOrder $payPalOrder
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Model\Action\OrderActionFactory
|
||||
*/
|
||||
protected function getActionFactory($request, $payPalOrder)
|
||||
{
|
||||
$order = $this->_createStub(Order::class, array('getPayPalOrder' => $payPalOrder));
|
||||
|
||||
$actionFactory = new \OxidEsales\PayPalModule\Model\Action\OrderActionFactory($request, $order);
|
||||
|
||||
return $actionFactory;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?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\Eshop\PayPalModule\Tests\Integration;
|
||||
|
||||
use OxidEsales\Eshop\Application\Model\Basket;
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
use OxidEsales\PayPalModule\Tests\Unit\AdminUserTrait;
|
||||
|
||||
class OrderFinalizationTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
use AdminUserTrait;
|
||||
|
||||
public function providerFinalizeOrder_TransStatusNotChange()
|
||||
{
|
||||
/** @var \OxidEsales\PayPalModule\Model\Order $order */
|
||||
$order = oxNew(Order::class);
|
||||
return array(
|
||||
array('Pending', $order::OEPAYPAL_TRANSACTION_STATUS_NOT_FINISHED),
|
||||
array('Failed', $order::OEPAYPAL_TRANSACTION_STATUS_NOT_FINISHED),
|
||||
array('Complete', $order::OEPAYPAL_TRANSACTION_STATUS_OK)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* After order is finalized and PayPal order status is not 'complete',
|
||||
* order transaction status should also stay 'NOT FINISHED'.
|
||||
*
|
||||
* @dataProvider providerFinalizeOrder_TransStatusNotChange
|
||||
*
|
||||
* @param string $payPalReturnStatus
|
||||
* @param string $transactionStatus
|
||||
*/
|
||||
public function testFinalizeOrder_TransactionStatus($payPalReturnStatus, $transactionStatus)
|
||||
{
|
||||
$this->getSession()->setVariable('sess_challenge', '_testOrderId');
|
||||
$this->getSession()->setVariable('paymentid', 'oxidpaypal');
|
||||
|
||||
/** @var \OxidEsales\PayPalModule\Model\Basket $basket */
|
||||
$basket = oxNew(Basket::class);
|
||||
|
||||
$paymentGateway = $this->getPaymentGateway($payPalReturnStatus);
|
||||
|
||||
/** @var \OxidEsales\PayPalModule\Model\Order $order */
|
||||
$mockBuilder = $this->getMockBuilder(Order::class);
|
||||
$mockBuilder->setMethods(['_getGateway', '_sendOrderByEmail', 'validateOrder']);
|
||||
$order = $mockBuilder->getMock();
|
||||
$order->expects($this->any())->method('_getGateway')->will($this->returnValue($paymentGateway));
|
||||
|
||||
$order->setId('_testOrderId');
|
||||
$order->finalizeOrder($basket, $this->getUser());
|
||||
|
||||
$updatedOrder = oxNew(Order::class);
|
||||
$updatedOrder->load('_testOrderId');
|
||||
$this->assertEquals($transactionStatus, $updatedOrder->getFieldData('oxtransstatus'));
|
||||
$updatedOrder->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Payment Gateway with mocked PayPal call. Result returns provided return status.
|
||||
*
|
||||
* @param string $payPalReturnStatus
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Model\PaymentGateway
|
||||
*/
|
||||
protected function getPaymentGateway($payPalReturnStatus)
|
||||
{
|
||||
/** @var \OxidEsales\PayPalModule\Model\Response\ResponseDoExpressCheckoutPayment $result */
|
||||
$result = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseDoExpressCheckoutPayment::class);
|
||||
$result->setData(array('PAYMENTINFO_0_PAYMENTSTATUS' => $payPalReturnStatus));
|
||||
|
||||
/** @var \OxidEsales\PayPalModule\Core\PayPalService $service */
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\PayPalService::class);
|
||||
$mockBuilder->setMethods(['doExpressCheckoutPayment']);
|
||||
$service = $mockBuilder->getMock();
|
||||
$service->expects($this->any())->method('doExpressCheckoutPayment')->will($this->returnValue($result));
|
||||
|
||||
/** @var \OxidEsales\PayPalModule\Model\PaymentGateway $payPalPaymentGateway */
|
||||
$payPalPaymentGateway = oxNew(\OxidEsales\Eshop\Application\Model\PaymentGateway::class);
|
||||
$payPalPaymentGateway->setPayPalCheckoutService($service);
|
||||
|
||||
return $payPalPaymentGateway;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OxidEsales\PayPalModule\Model\User
|
||||
*/
|
||||
protected function getUser()
|
||||
{
|
||||
/** @var \OxidEsales\PayPalModule\Model\User $user */
|
||||
$user = oxNew(\OxidEsales\Eshop\Application\Model\User::class);
|
||||
$user->load('oxdefaultadmin');
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OxidEsales\PayPalModule\Tests\Unit;
|
||||
|
||||
trait AdminUserTrait
|
||||
{
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDB()->execute(
|
||||
"REPLACE INTO `oxuser` (`OXID`, `OXACTIVE`, `OXRIGHTS`, `OXSHOPID`, `OXUSERNAME`, `OXPASSWORD`, `OXPASSSALT`, `OXCUSTNR`, `OXUSTID`, `OXCOMPANY`, `OXFNAME`, `OXLNAME`, `OXSTREET`, `OXSTREETNR`, `OXADDINFO`, `OXCITY`, `OXCOUNTRYID`, `OXSTATEID`, `OXZIP`, `OXFON`, `OXFAX`, `OXSAL`, `OXBONI`, `OXCREATE`, `OXREGISTER`, `OXPRIVFON`, `OXMOBFON`, `OXBIRTHDATE`, `OXURL`, `OXUPDATEKEY`, `OXUPDATEEXP`, `OXPOINTS`) VALUES ('oxdefaultadmin', 1, 'malladmin', 1, 'admin', 'e3a8a383819630e42d9ef90be2347ea70364b5efbb11dfc59adbf98487e196fffe4ef4b76174a7be3f2338581e507baa61c852b7d52f4378e21bd2de8c1efa5e', '61646D696E61646D696E61646D696E', 1, '', 'Your Company Name', 'John', 'Doe', 'Maple Street', '2425', '', 'Any City', 'a7c40f631fc920687.20179984', '', '9041', '217-8918712', '217-8918713', 'MR', 1000, '2003-01-01 00:00:00', '2003-01-01 00:00:00', '', '', '0000-00-00', '', '', 0, 0);"
|
||||
);
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDB()->execute(
|
||||
"DELETE FROM `oxuser` where OXID = 'oxdefaultadmin'"
|
||||
);
|
||||
}
|
||||
}
|
||||
52
shop/source/modules/oe/oepaypal/Tests/Unit/BaseUnitTest.php
Normal file
52
shop/source/modules/oe/oepaypal/Tests/Unit/BaseUnitTest.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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\Tests\Unit\Core;
|
||||
|
||||
abstract class BaseUnitTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/**
|
||||
* @param string $needle
|
||||
* @param string $haystack
|
||||
* @param string $message
|
||||
*/
|
||||
protected function doAssertStringContainsString($needle, $haystack, $message = '')
|
||||
{
|
||||
if (method_exists($this, 'assertStringContainsString')) {
|
||||
parent::assertStringContainsString($needle, $haystack, $message);
|
||||
} else {
|
||||
parent::assertContains($needle, $haystack, $message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $needle
|
||||
* @param string $haystack
|
||||
* @param string $message
|
||||
*/
|
||||
protected function doAssertStringNotContainsString($needle, $haystack, $message = '')
|
||||
{
|
||||
if (method_exists($this, 'assertStringNotContainsString')) {
|
||||
parent::assertStringNotContainsString($needle, $haystack, $message);
|
||||
} else {
|
||||
parent::assertNotContains($needle, $haystack, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?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\Tests\Unit\Component;
|
||||
|
||||
use OxidEsales\Eshop\Application\Component\BasketComponent;
|
||||
|
||||
class BasketComponentTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
public function providerActionExpressCheckoutFromDetailsPage()
|
||||
{
|
||||
$url = $this->getConfig()->getCurrentShopUrl(false) . 'index.php?cl=start';
|
||||
|
||||
return array(
|
||||
// Article valid
|
||||
array(true, 1, 'oepaypalexpresscheckoutdispatcher?fnc=setExpressCheckout&displayCartInPayPal=0&oePayPalCancelURL=' . urlencode($url)),
|
||||
// Article not valid
|
||||
array(false, 1, null),
|
||||
// Article not not valid- amount is zero
|
||||
array(false, 0, 'start?')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if action returns correct url when article is valid and is not valid
|
||||
*
|
||||
* @param $isArticleValid
|
||||
* @param $expectedUrl
|
||||
* @param $articleAmount
|
||||
*
|
||||
* @dataProvider providerActionExpressCheckoutFromDetailsPage
|
||||
*/
|
||||
public function testActionExpressCheckoutFromDetailsPage($isArticleValid, $articleAmount, $expectedUrl)
|
||||
{
|
||||
$this->getConfig()->setConfigParam('blSeoMode', false);
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Model\ArticleToExpressCheckoutValidator::class);
|
||||
$mockBuilder->setMethods(['isArticleValid']);
|
||||
$validator = $mockBuilder->getMock();
|
||||
$validator->expects($this->any())->method('isArticleValid')->will($this->returnValue($isArticleValid));
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Model\ArticleToExpressCheckoutCurrentItem::class);
|
||||
$mockBuilder->setMethods(['getArticleAmount']);
|
||||
$currentItem = $mockBuilder->getMock();
|
||||
$currentItem->expects($this->any())->method('getArticleAmount')->will($this->returnValue($articleAmount));
|
||||
|
||||
/** @var BasketComponent $cmpBasket */
|
||||
$mockBuilder = $this->getMockBuilder(BasketComponent::class);
|
||||
$mockBuilder->setMethods(['getValidator', 'getCurrentArticle']);
|
||||
$cmpBasket = $mockBuilder->getMock();
|
||||
$cmpBasket->expects($this->any())->method('getValidator')->will($this->returnValue($validator));
|
||||
$cmpBasket->expects($this->any())->method('getCurrentArticle')->will($this->returnValue($currentItem));
|
||||
|
||||
$this->assertEquals($expectedUrl, $cmpBasket->actionExpressCheckoutFromDetailsPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if action returns correct url with cancel URL
|
||||
*/
|
||||
public function testActionExpressCheckoutFromDetailsPage_CheckCancelUrl()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('blSeoMode', false);
|
||||
|
||||
$url = $this->getConfig()->getCurrentShopUrl(false) . 'index.php?cl=start';
|
||||
$cancelURL = urlencode($url);
|
||||
$expectedURL = 'oepaypalexpresscheckoutdispatcher?fnc=setExpressCheckout&displayCartInPayPal=0&oePayPalCancelURL=' . $cancelURL;
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Model\ArticleToExpressCheckoutValidator::class);
|
||||
$mockBuilder->setMethods(['isArticleValid']);
|
||||
$validator = $mockBuilder->getMock();
|
||||
$validator->expects($this->any())->method('isArticleValid')->will($this->returnValue(true));
|
||||
|
||||
/** @var BasketComponent $cmpBasket */
|
||||
$mockBuilder = $this->getMockBuilder(BasketComponent::class);
|
||||
$mockBuilder->setMethods(['getValidator']);
|
||||
$cmpBasket = $mockBuilder->getMock();
|
||||
$cmpBasket->expects($this->any())->method('getValidator')->will($this->returnValue($validator));
|
||||
|
||||
$this->assertEquals($expectedURL, $cmpBasket->actionExpressCheckoutFromDetailsPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if action returns correct URL part
|
||||
*/
|
||||
public function testActionNotAddToBasketAndGoToCheckout()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('blSeoMode', false);
|
||||
|
||||
$url = $this->getConfig()->getCurrentShopUrl(false) . 'index.php?cl=start';
|
||||
$cancelURL = urlencode($url);
|
||||
$expectedUrl = 'oepaypalexpresscheckoutdispatcher?fnc=setExpressCheckout&displayCartInPayPal=0&oePayPalCancelURL=' . $cancelURL;
|
||||
|
||||
$cmpBasket = oxNew(BasketComponent::class);
|
||||
|
||||
$this->assertEquals($expectedUrl, $cmpBasket->actionNotAddToBasketAndGoToCheckout());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?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\Tests\Unit\Component\Widget;
|
||||
|
||||
class ArticleDetailsTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
protected function createDetailsMock($articleInfo, $showECSPopUp = 0)
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\Eshop\Application\Component\BasketComponent::class);
|
||||
$mockBuilder->setMethods(['getCurrentArticleInfo', 'shopECSPopUp']);
|
||||
$basketComponent = $mockBuilder->getMock();
|
||||
$basketComponent->expects($this->any())->method('getCurrentArticleInfo')->will($this->returnValue($articleInfo));
|
||||
$basketComponent->expects($this->any())->method('shopECSPopUp')->will($this->returnValue($showECSPopUp));
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\Eshop\Application\Component\Widget\ArticleDetails::class);
|
||||
$mockBuilder->setMethods(['oePayPalGetRequest', 'getComponent']);
|
||||
$details = $mockBuilder->getMock();
|
||||
$details->expects($this->any())->method('getComponent')->will($this->returnValue($basketComponent));
|
||||
|
||||
return $details;
|
||||
}
|
||||
|
||||
public function providerOePayPalGetArticleAmount()
|
||||
{
|
||||
return array(
|
||||
// Given amount 5
|
||||
array(array('am' => 5), 5),
|
||||
// Not given any amount
|
||||
array('', 1)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if returns correct amount
|
||||
*
|
||||
* @param $articleInfo
|
||||
* @param $expectedResult
|
||||
*
|
||||
* @dataProvider providerOePayPalGetArticleAmount
|
||||
*/
|
||||
public function testOePayPalGetArticleAmount($articleInfo, $expectedResult)
|
||||
{
|
||||
$details = $this->createDetailsMock($articleInfo);
|
||||
|
||||
$this->assertEquals($expectedResult, $details->oePayPalGetArticleAmount());
|
||||
}
|
||||
|
||||
public function providerOePayPalShowECSPopup()
|
||||
{
|
||||
return array(
|
||||
array(true, true),
|
||||
array(false, false),
|
||||
array('', false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if function gets parameter and returns correct result
|
||||
*
|
||||
* @param $showPopUp
|
||||
* @param $expectedResult
|
||||
*
|
||||
* @dataProvider providerOePayPalShowECSPopup
|
||||
*/
|
||||
public function testOePayPalShowECSPopup($showPopUp, $expectedResult)
|
||||
{
|
||||
$details = $this->createDetailsMock(array(), $showPopUp);
|
||||
|
||||
$this->assertEquals($expectedResult, $details->oePayPalShowECSPopup());
|
||||
}
|
||||
|
||||
public function providerOePayPalGetPersistentParam()
|
||||
{
|
||||
return array(
|
||||
array(array('persparam' => array('details' => 'aa')), 'aa'),
|
||||
array(array('persparam' => null), null),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if function returns correct persistent param
|
||||
*
|
||||
* @param $articleInfo
|
||||
* @param $expectedResult
|
||||
*
|
||||
* @dataProvider providerOePayPalGetPersistentParam
|
||||
*/
|
||||
public function testOePayPalGetPersistentParam($articleInfo, $expectedResult)
|
||||
{
|
||||
$details = $this->createDetailsMock($articleInfo);
|
||||
|
||||
$this->assertEquals($expectedResult, $details->oePayPalGetPersistentParam());
|
||||
}
|
||||
|
||||
public function providerOePayPalGetSelection()
|
||||
{
|
||||
return array(
|
||||
array(array('sel' => array(1, 0)), array(1, 0)),
|
||||
array(array('sel' => null), null),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if returns correct selection lists values
|
||||
*
|
||||
* @param $articleInfo
|
||||
* @param $expectedResult
|
||||
*
|
||||
* @dataProvider providerOePayPalGetSelection
|
||||
*/
|
||||
public function testOePayPalGetSelection($articleInfo, $expectedResult)
|
||||
{
|
||||
$details = $this->createDetailsMock($articleInfo);
|
||||
|
||||
$this->assertEquals($expectedResult, $details->oePayPalGetSelection());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
<?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\Tests\Unit\Controller\Admin;
|
||||
|
||||
class DeliverySetMainTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute("delete from oxconfig where oxvarname = 'sOEPayPalMECDefaultShippingId' and oxmodule = 'module:oepaypal'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides with different shipping ids to be set as already stored and result if match current shipment.
|
||||
*/
|
||||
public function providerRender_DefaultShippingSet()
|
||||
{
|
||||
return array(
|
||||
// Same delivery stored as current.
|
||||
array('standard', true),
|
||||
// Different delivery stored as current.
|
||||
array('standard2', false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if checkbox value for PayPal mobile delivery set has correct value.
|
||||
*
|
||||
* @dataProvider providerRender_DefaultShippingSet
|
||||
*/
|
||||
public function testRender_DefaultShippingSet($mobileECDefaultShippingId, $markAsDefaultPaymentExpected)
|
||||
{
|
||||
$deliverySetId = 'standard';
|
||||
|
||||
$payPalModuleId = 'module:oepaypal';
|
||||
$this->getConfig()->saveShopConfVar('string', 'sOEPayPalMECDefaultShippingId', $mobileECDefaultShippingId, null, $payPalModuleId);
|
||||
|
||||
$payPalDeliverySet_Main = oxNew(\OxidEsales\Eshop\Application\Controller\Admin\DeliverySetMain::class);
|
||||
$payPalDeliverySet_Main->setEditObjectId($deliverySetId);
|
||||
$payPalDeliverySet_Main->render();
|
||||
|
||||
$viewData = $payPalDeliverySet_Main->getViewData();
|
||||
$this->assertEquals($markAsDefaultPaymentExpected, $viewData['isPayPalDefaultMobilePayment']);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testSave_SameShippingIdExistsDeliverySetMarkedAsSet_ShippingIdSame()
|
||||
{
|
||||
$this->setRequestParameter('isPayPalDefaultMobilePayment', true);
|
||||
|
||||
$payPalDeliverySet_Main = $this->getDeliverySet();
|
||||
$deliverySetId1 = $payPalDeliverySet_Main->getEditObjectId();
|
||||
|
||||
$payPalModuleId = 'module:oepaypal';
|
||||
$this->getConfig()->saveShopConfVar('string', 'sOEPayPalMECDefaultShippingId', $deliverySetId1, null, $payPalModuleId);
|
||||
|
||||
$payPalDeliverySet_Main = $this->getDeliverySet($deliverySetId1);
|
||||
|
||||
$payPalConfig = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$mobileECDefaultShippingId = $payPalConfig->getMobileECDefaultShippingId();
|
||||
|
||||
$this->assertEquals($deliverySetId1, $mobileECDefaultShippingId);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testSave_NotSameShippingIdExistsDeliverySetMarkedAsSet_ShippingIdNew()
|
||||
{
|
||||
$this->setRequestParameter('isPayPalDefaultMobilePayment', true);
|
||||
|
||||
$payPalModuleId = 'module:oepaypal';
|
||||
$this->getConfig()->saveShopConfVar('string', 'sOEPayPalMECDefaultShippingId', 'standard', null, $payPalModuleId);
|
||||
|
||||
$payPalDeliverySet_Main = $this->getDeliverySet();
|
||||
$deliverySetId2 = $payPalDeliverySet_Main->getEditObjectId();
|
||||
|
||||
$payPalConfig = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$mobileECDefaultShippingId = $payPalConfig->getMobileECDefaultShippingId();
|
||||
|
||||
$this->assertEquals($deliverySetId2, $mobileECDefaultShippingId);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testSave_ShippingIdDoNotExistsDeliverySetMarkedAsSet_ShippingIdNew()
|
||||
{
|
||||
$this->setRequestParameter('isPayPalDefaultMobilePayment', true);
|
||||
|
||||
$payPalDeliverySet_Main = $this->getDeliverySet();
|
||||
$deliverySetId2 = $payPalDeliverySet_Main->getEditObjectId();
|
||||
|
||||
$payPalConfig = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$mobileECDefaultShippingId = $payPalConfig->getMobileECDefaultShippingId();
|
||||
|
||||
$this->assertEquals($deliverySetId2, $mobileECDefaultShippingId);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testSave_SameShippingIdExistsDeliverySetNotMarkedAsSet_ShippingIdCleared()
|
||||
{
|
||||
$payPalDeliverySet_Main = $this->getDeliverySet();
|
||||
$deliverySetId1 = $payPalDeliverySet_Main->getEditObjectId();
|
||||
|
||||
$payPalModuleId = 'module:oepaypal';
|
||||
$this->getConfig()->saveShopConfVar('string', 'sOEPayPalMECDefaultShippingId', $deliverySetId1, null, $payPalModuleId);
|
||||
|
||||
$payPalDeliverySet_Main = $this->getDeliverySet($deliverySetId1);
|
||||
|
||||
$payPalConfig = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$mobileECDefaultShippingId = $payPalConfig->getMobileECDefaultShippingId();
|
||||
|
||||
$this->assertEquals('', $mobileECDefaultShippingId);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testSave_NotSameShippingIdExistsDeliverySetNotMarkedAsSet_ShippingIdSame()
|
||||
{
|
||||
$payPalModuleId = 'module:oepaypal';
|
||||
$this->getConfig()->saveShopConfVar('string', 'sOEPayPalMECDefaultShippingId', 'standard', null, $payPalModuleId);
|
||||
|
||||
$payPalDeliverySet_Main = $this->getDeliverySet();
|
||||
$deliverySetId2 = $payPalDeliverySet_Main->getEditObjectId();
|
||||
|
||||
$payPalConfig = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$mobileECDefaultShippingId = $payPalConfig->getMobileECDefaultShippingId();
|
||||
|
||||
$this->assertEquals('standard', $mobileECDefaultShippingId);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testSave_ShippingIdDoNotExistsDeliverySetNotMarkedAsSet_ShippingIdEmpty()
|
||||
{
|
||||
$payPalDeliverySet_Main = $this->getDeliverySet();
|
||||
|
||||
$payPalConfig = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$mobileECDefaultShippingId = $payPalConfig->getMobileECDefaultShippingId();
|
||||
|
||||
$this->assertEquals('', $mobileECDefaultShippingId);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
protected function getDeliverySet($deliverySetid = -1)
|
||||
{
|
||||
$payPalDeliverySet_Main = oxNew(\OxidEsales\PayPalModule\Controller\Admin\DeliverySetMain::class);
|
||||
$payPalDeliverySet_Main->setEditObjectId($deliverySetid);
|
||||
$payPalDeliverySet_Main->save();
|
||||
|
||||
return $payPalDeliverySet_Main;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?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\Tests\Unit\Controller\Admin;
|
||||
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
|
||||
class OrderPayPalTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/**
|
||||
* Setup: Prepare data - create need tables
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute('TRUNCATE `oepaypal_order`');
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds order to oepaypal_order and oxorder tables and checks if order is created using current PayPal module.
|
||||
* Expected result- true
|
||||
*/
|
||||
public function testIsNewPayPalOrder_True()
|
||||
{
|
||||
$soxId = '_testOrderId';
|
||||
|
||||
$payPalOrderModel = new \OxidEsales\PayPalModule\Model\PayPalOrder();
|
||||
$payPalOrderModel->setOrderId($soxId);
|
||||
$payPalOrderModel->save();
|
||||
|
||||
$payPalOrderModel->load();
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(Order::class);
|
||||
$mockBuilder->setMethods(['getPayPalOrder']);
|
||||
$payPalOxOrder = $mockBuilder->getMock();
|
||||
$payPalOxOrder->expects($this->any())->method('getPayPalOrder')->will($this->returnValue($payPalOrderModel));
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Controller\Admin\OrderController::class);
|
||||
$mockBuilder->setMethods(['getEditObject', 'isPayPalOrder']);
|
||||
$payPalOrder = $mockBuilder->getMock();
|
||||
$payPalOrder->expects($this->any())->method('getEditObject')->will($this->returnValue($payPalOxOrder));
|
||||
$payPalOrder->expects($this->once())->method('isPayPalOrder')->will($this->returnValue(true));
|
||||
|
||||
$this->assertTrue($payPalOrder->isNewPayPalOrder());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if order is created using current PayPal module.
|
||||
* Expected result- false
|
||||
*/
|
||||
public function testIsNewPayPalOrder_False()
|
||||
{
|
||||
$soxId = '_testOrderId';
|
||||
|
||||
$payPalOrderModel = new \OxidEsales\PayPalModule\Model\PayPalOrder();
|
||||
$payPalOrderModel->setOrderId($soxId);
|
||||
$payPalOrderModel->save();
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Model\Order::class);
|
||||
$mockBuilder->setMethods(['getPayPalOrder']);
|
||||
$payPalOxOrder = $mockBuilder->getMock();
|
||||
$payPalOxOrder->expects($this->any())->method('getPayPalOrder')->will($this->returnValue($payPalOrderModel));
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Controller\Admin\OrderController::class);
|
||||
$mockBuilder->setMethods(['getEditObject', 'isPayPalOrder']);
|
||||
$payPalOrder = $mockBuilder->getMock();
|
||||
$payPalOrder->expects($this->any())->method('getEditObject')->will($this->returnValue($payPalOxOrder));
|
||||
$payPalOrder->expects($this->once())->method('isPayPalOrder')->will($this->returnValue(false));
|
||||
|
||||
$this->assertFalse($payPalOrder->isNewPayPalOrder());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if order was made using PayPal payment method.
|
||||
* Expected result- true
|
||||
*/
|
||||
public function testIsPayPalOrder_True()
|
||||
{
|
||||
$payPalOrder = new \OxidEsales\PayPalModule\Controller\Admin\OrderController();
|
||||
$soxId = '_testOrderId';
|
||||
|
||||
$session = oxNew(\OxidEsales\Eshop\Core\Session::class);
|
||||
$session->setVariable('saved_oxid', $soxId);
|
||||
|
||||
$order = oxNew(\OxidEsales\Eshop\Application\Model\Order::class);
|
||||
$order->setId($soxId);
|
||||
$order->oxorder__oxpaymenttype = new \OxidEsales\Eshop\Core\Field('oxidpaypal');
|
||||
$order->save();
|
||||
|
||||
$this->assertTrue($payPalOrder->isPayPalOrder());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if order was made using PayPal payment method.
|
||||
* Expected result- false
|
||||
*/
|
||||
public function testIsPayPalOrder_False()
|
||||
{
|
||||
$payPalOrder = new \OxidEsales\PayPalModule\Controller\Admin\OrderController();
|
||||
$soxId = '_testOrderId';
|
||||
|
||||
$session = oxNew(\OxidEsales\Eshop\Core\Session::class);
|
||||
$session->setVariable('saved_oxid', $soxId);
|
||||
|
||||
$order = oxNew(\OxidEsales\Eshop\Application\Model\Order::class);
|
||||
$order->setId($soxId);
|
||||
$order->oxorder__oxpaymenttype = new \OxidEsales\Eshop\Core\Field('other');
|
||||
$order->save();
|
||||
|
||||
$this->assertFalse($payPalOrder->isPayPalOrder());
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,93 @@
|
||||
<?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\Tests\Unit\Controller;
|
||||
|
||||
/**
|
||||
* Testing OxidEsales\PayPalModule\Controller\FrontendController class.
|
||||
*/
|
||||
class FrontendControllerTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Controller\FrontendController::getRequest()
|
||||
*/
|
||||
public function testGetRequest()
|
||||
{
|
||||
$controller = new \OxidEsales\PayPalModule\Controller\FrontendController();
|
||||
$this->assertTrue($controller->getRequest() instanceof \OxidEsales\PayPalModule\Core\Request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Controller\FrontendController::getLogger()
|
||||
*/
|
||||
public function testGetLogger()
|
||||
{
|
||||
$controller = new \OxidEsales\PayPalModule\Controller\FrontendController();
|
||||
$this->assertTrue($controller->getLogger() instanceof \OxidEsales\PayPalModule\Core\Logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Controller\FrontendController::getPayPalConfig()
|
||||
*/
|
||||
public function testGetPayPalConfig()
|
||||
{
|
||||
$controller = new \OxidEsales\PayPalModule\Controller\FrontendController();
|
||||
$this->assertTrue($controller->getPayPalConfig() instanceof \OxidEsales\PayPalModule\Core\Config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Controller\FrontendController::log()
|
||||
*/
|
||||
public function testLog_LoggingEnabled()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('blPayPalLoggerEnabled', true);
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Logger::class);
|
||||
$mockBuilder->setMethods(['log']);
|
||||
$payPalLogger = $mockBuilder->getMock();
|
||||
$payPalLogger->expects($this->once())->method('log');
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Controller\FrontendController::class);
|
||||
$mockBuilder->setMethods(['getLogger']);
|
||||
$controller = $mockBuilder->getMock();
|
||||
$controller->expects($this->once())->method('getLogger')->will($this->returnValue($payPalLogger));
|
||||
|
||||
$controller->log('logMessage');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Controller\FrontendController::log()
|
||||
*/
|
||||
public function testLog_LoggingDisabled()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('blPayPalLoggerEnabled', false);
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Logger::class);
|
||||
$mockBuilder->setMethods(['log']);
|
||||
$payPalLogger = $mockBuilder->getMock();
|
||||
$payPalLogger->expects($this->never())->method('log');
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Controller\FrontendController::class);
|
||||
$mockBuilder->setMethods(['getLogger']);
|
||||
$controller = $mockBuilder->getMock();
|
||||
$controller->expects($this->never())->method('getLogger')->will($this->returnValue($payPalLogger));
|
||||
|
||||
$controller->log('logMessage');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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\Tests\Unit\Controller;
|
||||
|
||||
|
||||
/**
|
||||
* Testing \OxidEsales\PayPalModule\Controller\IPNHandler class.
|
||||
*/
|
||||
class IPNHandlerTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
public function testGetPayPalRequest()
|
||||
{
|
||||
$payPalHandler = new \OxidEsales\PayPalModule\Controller\IPNHandler();
|
||||
$payPalRequest = $payPalHandler->getPayPalRequest();
|
||||
$this->assertTrue(is_a($payPalRequest, \OxidEsales\PayPalModule\Core\Request::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Controller\IPNHandler::handleRequest()
|
||||
* Handler should return false if called without PayPal request data.
|
||||
*/
|
||||
public function testHandleRequest_emptyData_false()
|
||||
{
|
||||
$payPalIPNHandler = new \OxidEsales\PayPalModule\Controller\IPNHandler();
|
||||
$payPalIPNHandler->handleRequest();
|
||||
|
||||
$logHelper = new \OxidEsales\PayPalModule\Tests\Unit\PayPalLogHelper();
|
||||
$logData = $logHelper->getLogData();
|
||||
$lastLogItem = end($logData);
|
||||
$requestHandled = $lastLogItem->data['Result'] == 'true';
|
||||
|
||||
$this->assertEquals(false, $requestHandled);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?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\Tests\Unit\Controller;
|
||||
|
||||
use OxidEsales\Eshop\Application\Controller\OrderController;
|
||||
use OxidEsales\PayPalModule\Tests\Unit\AdminUserTrait;
|
||||
|
||||
if (!class_exists('oePayPalOrder_parent')) {
|
||||
class oePayPalOrder_parent extends \OxidEsales\Eshop\Application\Controller\OrderController
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing oePayPaleOrder class.
|
||||
*/
|
||||
class OrderControllerTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
use AdminUserTrait;
|
||||
|
||||
/**
|
||||
* Tear down the fixture.
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDB()->execute("delete from oxpayments where OXID = 'oxidpaypal' ");
|
||||
|
||||
$this->cleanUpTable('oxuser', 'oxid');
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for OrderController::isPayPal()
|
||||
*/
|
||||
public function testIsPayPal()
|
||||
{
|
||||
$view = oxNew(OrderController::class);
|
||||
|
||||
$this->getSession()->setVariable("paymentid", "oxidpaypal");
|
||||
$this->assertTrue($view->isPayPal());
|
||||
|
||||
$this->getSession()->setVariable("paymentid", "testPayment");
|
||||
$this->assertFalse($view->isPayPal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for getUser test
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function providerGetUser()
|
||||
{
|
||||
return array(
|
||||
array('oxidpaypal', '_testPayPalUser', 'oxdefaultadmin', '_testPayPalUser'),
|
||||
array('oxidpaypal', null, 'oxdefaultadmin', 'oxdefaultadmin'),
|
||||
array('nonpaypalpayment', '_testPayPalUser', 'oxdefaultadmin', 'oxdefaultadmin'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* PayPal active, PayPal user is set, PayPal user loaded
|
||||
*
|
||||
* @dataProvider providerGetUser
|
||||
*/
|
||||
public function testGetUser($paymentId, $payPalUserId, $defaultUserId, $expectedUserId)
|
||||
{
|
||||
$user = oxNew(\OxidEsales\Eshop\Application\Model\User::class);
|
||||
$user->setId($payPalUserId);
|
||||
$user->save();
|
||||
|
||||
$this->getSession()->setVariable("paymentid", $paymentId);
|
||||
$this->getSession()->setVariable("oepaypal-userId", $payPalUserId);
|
||||
$this->getSession()->setVariable('usr', $defaultUserId);
|
||||
|
||||
$order = oxNew(\OxidEsales\Eshop\Application\Controller\OrderController::class);
|
||||
$order->setUser(null);
|
||||
$user = $order->getUser();
|
||||
|
||||
$this->assertEquals($expectedUserId, $user->oxuser__oxid->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* PayPal active, PayPal user is set, PayPal user loaded
|
||||
*
|
||||
* @dataProvider providerGetUser
|
||||
*/
|
||||
public function testGetUser_NonExistingPayPalUser_DefaultUserReturned()
|
||||
{
|
||||
$this->getSession()->setVariable("paymentid", 'oxidpaypal');
|
||||
$this->getSession()->setVariable("oepaypal-userId", 'nonExistingUser');
|
||||
$this->getSession()->setVariable('usr', 'oxdefaultadmin');
|
||||
|
||||
$order = oxNew(\OxidEsales\Eshop\Application\Controller\OrderController::class);
|
||||
$user = $order->getUser();
|
||||
|
||||
$this->assertEquals('oxdefaultadmin', $user->oxuser__oxid->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for OrderController::getPayment()
|
||||
*/
|
||||
public function testGetPayment()
|
||||
{
|
||||
$this->getSession()->setVariable("oepaypal", "0");
|
||||
|
||||
$view = oxNew(\OxidEsales\Eshop\Application\Controller\OrderController::class);
|
||||
$payment = $view->getPayment();
|
||||
$this->assertFalse($payment);
|
||||
|
||||
$this->getSession()->setVariable("paymentid", "oxidpaypal");
|
||||
|
||||
$query = "INSERT INTO `oxpayments` (`OXID`, `OXACTIVE`, `OXDESC`) VALUES ('oxidpaypal', 1, 'PayPal')";
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute($query);
|
||||
|
||||
$view = oxNew(\OxidEsales\Eshop\Application\Controller\OrderController::class);
|
||||
$payment = $view->getPayment();
|
||||
|
||||
$this->assertNotNull($payment);
|
||||
$this->assertEquals("oxidpaypal", $payment->getId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?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\Tests\Unit\Controller;
|
||||
|
||||
use OxidEsales\Eshop\Application\Controller\PaymentController;
|
||||
|
||||
/**
|
||||
* Testing PaymentController class.
|
||||
*/
|
||||
class PaymentControllerTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/**
|
||||
* Test case for PaymentController::validatePayment()
|
||||
* Test validatePayment
|
||||
*/
|
||||
public function testValidatePayment()
|
||||
{
|
||||
// forcing payment id
|
||||
$this->setRequestParameter("paymentid", null);
|
||||
|
||||
$view = oxNew(PaymentController::class);
|
||||
$this->assertNull($view->validatePayment());
|
||||
|
||||
// forcing payment id
|
||||
$this->setRequestParameter("paymentid", "oxidpaypal");
|
||||
$this->setRequestParameter("displayCartInPayPal", 1);
|
||||
|
||||
$view = new \OxidEsales\PayPalModule\Controller\PaymentController();
|
||||
$this->assertEquals("oepaypalstandarddispatcher?fnc=setExpressCheckout&displayCartInPayPal=1", $view->validatePayment());
|
||||
$this->assertEquals("oxidpaypal", $this->getSession()->getVariable("paymentid"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test, that the method validatePayment if the order was already checked by paypal.
|
||||
*/
|
||||
public function testValidatePaymentIfCheckedByPayPal()
|
||||
{
|
||||
// forcing payment id
|
||||
$this->setRequestParameter("paymentid", "oxidpaypal");
|
||||
$this->setRequestParameter("displayCartInPayPal", 1);
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Controller\PaymentController::class);
|
||||
$mockBuilder->setMethods(['isConfirmedByPayPal']);
|
||||
$view = $mockBuilder->getMock();
|
||||
$view->expects($this->once())->method("isConfirmedByPayPal")->will($this->returnValue(true));
|
||||
|
||||
$this->assertNull($view->validatePayment());
|
||||
$this->assertNull($this->getSession()->getVariable("paymentid"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for PaymentController::isConfirmedByPayPal()
|
||||
* Test isConfirmedByPayPal
|
||||
*/
|
||||
public function testIsConfirmedByPayPal()
|
||||
{
|
||||
// forcing payment id
|
||||
$this->setRequestParameter("paymentid", "oxidpaypal");
|
||||
$this->getSession()->setVariable("oepaypal-basketAmount", 129.00);
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\Eshop\Core\Price::class);
|
||||
$mockBuilder->setMethods(['getBruttoPrice']);
|
||||
$price = $mockBuilder->getMock();
|
||||
$price->expects($this->once())->method("getBruttoPrice")->will($this->returnValue(129.00));
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\Eshop\Application\Model\Basket::class);
|
||||
$mockBuilder->setMethods(['getPrice']);
|
||||
$basket = $mockBuilder->getMock();
|
||||
$basket->expects($this->once())->method("getPrice")->will($this->returnValue($price));
|
||||
|
||||
$view = new \OxidEsales\PayPalModule\Controller\PaymentController();
|
||||
|
||||
$this->assertTrue($view->isConfirmedByPayPal($basket));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
<?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\Tests\Unit\Controller;
|
||||
|
||||
class StandardDispatcherTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
// fix for state ID compatability between editions
|
||||
$sqlState = "REPLACE INTO `oxstates` (`OXID`, `OXCOUNTRYID`, `OXTITLE`, `OXISOALPHA2`, `OXTITLE_1`, `OXTITLE_2`, `OXTITLE_3`, `OXTIMESTAMP`) " .
|
||||
"VALUES ('333', '8f241f11096877ac0.98748826', 'USA last state', 'SS', 'USA last state', '', '', CURRENT_TIMESTAMP);";
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute($sqlState);
|
||||
}
|
||||
|
||||
public function testSetGetPayPalCheckoutService()
|
||||
{
|
||||
$payPalCheckoutService = new \OxidEsales\PayPalModule\Core\PayPalService();
|
||||
|
||||
$payPalStandardDispatcher = new \OxidEsales\PayPalModule\Controller\StandardDispatcher();
|
||||
$payPalStandardDispatcher->setPayPalCheckoutService($payPalCheckoutService);
|
||||
|
||||
$this->assertEquals($payPalCheckoutService, $payPalStandardDispatcher->getPayPalCheckoutService(), 'Getter should return what is set in setter.');
|
||||
}
|
||||
|
||||
public function testGetPayPalCheckoutService()
|
||||
{
|
||||
$payPalStandardDispatcher = new \OxidEsales\PayPalModule\Controller\StandardDispatcher();
|
||||
|
||||
$this->assertTrue(
|
||||
$payPalStandardDispatcher->getPayPalCheckoutService() instanceof \OxidEsales\PayPalModule\Core\PayPalService,
|
||||
'Getter should create correct type of object.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for oepaypalstandarddispatcher::getExpressCheckoutDetails()
|
||||
*/
|
||||
public function testGetExpressCheckoutDetails()
|
||||
{
|
||||
// preparing session, inputs etc.
|
||||
$session = $this->getSession();
|
||||
$session->setVariable("oepaypal-token", "111");
|
||||
$detailsData = ["PAYERID" => "111"];
|
||||
$details = new \OxidEsales\PayPalModule\Model\Response\ResponseGetExpressCheckoutDetails();
|
||||
$details->setData($detailsData);
|
||||
|
||||
// preparing config
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Config::class);
|
||||
$mockBuilder->setMethods(['finalizeOrderOnPayPalSide']);
|
||||
$payPalConfig = $mockBuilder->getMock();
|
||||
$payPalConfig->expects($this->once())->method('finalizeOrderOnPayPalSide')->will($this->returnValue(true));
|
||||
|
||||
// preparing service
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\PayPalService::class);
|
||||
$mockBuilder->setMethods(['getExpressCheckoutDetails']);
|
||||
$payPalService = $mockBuilder->getMock();
|
||||
$payPalService->expects($this->once())->method("getExpressCheckoutDetails")->will($this->returnValue($details));
|
||||
|
||||
// prepare user
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\Eshop\Application\Model\User::class);
|
||||
$mockBuilder->setMethods(['getEncodedDeliveryAddress']);
|
||||
$user = $mockBuilder->getMock();
|
||||
$user->expects($this->once())->method("getEncodedDeliveryAddress")->will($this->returnValue("encodeddeliveryaddress123"));
|
||||
|
||||
// preparing
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Controller\StandardDispatcher::class);
|
||||
$mockBuilder->setMethods(["getPayPalCheckoutService", "getPayPalConfig", "getUser"]);
|
||||
$dispatcher = $mockBuilder->getMock();
|
||||
$dispatcher->expects($this->once())->method("getPayPalCheckoutService")->will($this->returnValue($payPalService));
|
||||
$dispatcher->expects($this->once())->method("getPayPalConfig")->will($this->returnValue($payPalConfig));
|
||||
$dispatcher->expects($this->once())->method("getUser")->will($this->returnValue($user));
|
||||
|
||||
// testing
|
||||
$this->assertEquals("order?fnc=execute&sDeliveryAddressMD5=encodeddeliveryaddress123&stoken=" . $session->getSessionChallengeToken(), $dispatcher->getExpressCheckoutDetails());
|
||||
$this->assertEquals("111", $session->getVariable("oepaypal-payerId"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for oepaypalstandarddispatcher::getExpressCheckoutDetails()
|
||||
*/
|
||||
public function testGetExpressCheckoutDetailsError()
|
||||
{
|
||||
$excp = oxNew(\OxidEsales\Eshop\Core\Exception\StandardException::class);
|
||||
|
||||
// preparing config
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Config::class);
|
||||
$mockBuilder->setMethods(['finalizeOrderOnPayPalSide']);
|
||||
$payPalConfig = $mockBuilder->getMock();
|
||||
$payPalConfig->expects($this->never())->method('finalizeOrderOnPayPalSide');
|
||||
|
||||
// preparing paypal service
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\PayPalService::class);
|
||||
$mockBuilder->setMethods(['getExpressCheckoutDetails']);
|
||||
$payPalService = $mockBuilder->getMock();
|
||||
$payPalService->expects($this->once())->method("getExpressCheckoutDetails")->will($this->throwException($excp));
|
||||
|
||||
// preparing utils view
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\Eshop\Core\UtilsView::class);
|
||||
$mockBuilder->setMethods(['addErrorToDisplay']);
|
||||
$utilsView = $mockBuilder->getMock();
|
||||
$utilsView->expects($this->once())->method("addErrorToDisplay")->with($this->equalTo($excp));
|
||||
|
||||
// preparing
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Controller\StandardDispatcher::class);
|
||||
$mockBuilder->setMethods(['getPayPalCheckoutService', 'getPayPalConfig', 'getUtilsView']);
|
||||
$dispatcher = $mockBuilder->getMock();
|
||||
$dispatcher->expects($this->once())->method("getPayPalCheckoutService")->will($this->returnValue($payPalService));
|
||||
$dispatcher->expects($this->once())->method("getUtilsView")->will($this->returnValue($utilsView));
|
||||
$dispatcher->expects($this->never())->method("getPayPalConfig");
|
||||
|
||||
// testing
|
||||
$this->assertEquals("payment", $dispatcher->getExpressCheckoutDetails());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Controller\Dispatcher::setExpressCheckout()
|
||||
* Main functionality
|
||||
*/
|
||||
public function testSetExpressCheckout_onSuccess()
|
||||
{
|
||||
$result = new \OxidEsales\PayPalModule\Model\Response\ResponseSetExpressCheckout();
|
||||
$result->setData(array('TOKEN' => 'token'));
|
||||
|
||||
$url = "https://www.sandbox.paypal.com/cgi-bin/webscr&cmd=_express-checkout&token=token";
|
||||
|
||||
//utils
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\Eshop\Core\Utils::class);
|
||||
$mockBuilder->setMethods(['redirect']);
|
||||
$utils = $mockBuilder->getMock();
|
||||
$utils->expects($this->once())->method("redirect")->with($this->equalTo($url), $this->equalTo(false));
|
||||
|
||||
//config
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Config::class);
|
||||
$mockBuilder->setMethods(['getPayPalCommunicationUrl']);
|
||||
$payPalConfig = $mockBuilder->getMock();
|
||||
$payPalConfig->expects($this->once())->method("getPayPalCommunicationUrl")->with($this->equalTo($result->getToken()))->will($this->returnValue($url));
|
||||
|
||||
// preparing service
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\PayPalService::class);
|
||||
$mockBuilder->setMethods(['setExpressCheckout', 'setParameter']);
|
||||
$payPalService = $mockBuilder->getMock();
|
||||
$payPalService->expects($this->once())->method("setExpressCheckout")->will($this->returnValue($result));
|
||||
|
||||
// preparing
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Controller\StandardDispatcher::class);
|
||||
$mockBuilder->setMethods(['getPayPalCheckoutService', 'getUtils', 'getPayPalConfig']);
|
||||
$dispatcher = $mockBuilder->getMock();
|
||||
$dispatcher->expects($this->once())->method("getPayPalCheckoutService")->will($this->returnValue($payPalService));
|
||||
$dispatcher->expects($this->any())->method("getPayPalConfig")->will($this->returnValue($payPalConfig));
|
||||
$dispatcher->expects($this->once())->method("getUtils")->will($this->returnValue($utils));
|
||||
|
||||
// testing
|
||||
$dispatcher->setExpressCheckout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Controller\Dispatcher::setExpressCheckout()
|
||||
* On error
|
||||
*/
|
||||
public function testSetExpressCheckout_onError()
|
||||
{
|
||||
$excp = oxNew(\OxidEsales\Eshop\Core\Exception\StandardException::class);
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Config::class);
|
||||
$mockBuilder->setMethods(['getPaypalUrl']);
|
||||
$payPalConfig = $mockBuilder->getMock();
|
||||
$payPalConfig->expects($this->never())->method("getPaypalUrl");
|
||||
|
||||
// preparing paypal service
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\PayPalService::class);
|
||||
$mockBuilder->setMethods(['setExpressCheckout']);
|
||||
$payPalService= $mockBuilder->getMock();
|
||||
$payPalService->expects($this->once())->method("setExpressCheckout")->will($this->throwException($excp));
|
||||
|
||||
// preparing utils view
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\Eshop\Core\UtilsView::class);
|
||||
$mockBuilder->setMethods(['addErrorToDisplay']);
|
||||
$utilsView = $mockBuilder->getMock();
|
||||
$utilsView->expects($this->once())->method("addErrorToDisplay")->with($this->equalTo($excp));
|
||||
|
||||
// preparing
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Controller\StandardDispatcher::class);
|
||||
$mockBuilder->setMethods(['getPayPalCheckoutService', 'getUtilsView']);
|
||||
$dispatcher = $mockBuilder->getMock();
|
||||
$dispatcher->expects($this->once())->method("getPayPalCheckoutService")->will($this->returnValue($payPalService));
|
||||
$dispatcher->expects($this->once())->method("getUtilsView")->will($this->returnValue($utilsView));
|
||||
|
||||
// testing
|
||||
$this->assertEquals("basket", $dispatcher->setExpressCheckout());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?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\Tests\Unit\Controller;
|
||||
|
||||
/**
|
||||
* Testing WrappingController class.
|
||||
*/
|
||||
class WrappingControllerTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/**
|
||||
* Test case for WrappingController::isPayPal()
|
||||
*/
|
||||
public function testIsPayPal()
|
||||
{
|
||||
$view = oxNew(\OxidEsales\Eshop\Application\Controller\WrappingController::class);
|
||||
|
||||
$this->getSession()->setVariable("paymentid", "oxidpaypal");
|
||||
$this->assertTrue($view->isPayPal());
|
||||
|
||||
$this->getSession()->setVariable("paymentid", "notoxidpaypal");
|
||||
$this->assertFalse($view->isPayPal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for WrappingController::changeWrapping() - express chekcout
|
||||
*/
|
||||
public function testChangeWrapping_expressCheckout()
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Controller\WrappingController::class);
|
||||
$mockBuilder->setMethods(['isPayPal']);
|
||||
$view = $mockBuilder->getMock();
|
||||
$view->expects($this->once())->method("isPayPal")->will($this->returnValue(true));
|
||||
|
||||
$this->getSession()->setVariable("oepaypal", "2");
|
||||
$this->assertEquals("basket", $view->changeWrapping());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for WrappingController::changeWrapping() - standart chekout
|
||||
*/
|
||||
public function testChangeWrapping_standardCheckout()
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Controller\WrappingController::class);
|
||||
$mockBuilder->setMethods(['isPayPal']);
|
||||
$view = $mockBuilder->getMock();
|
||||
$view->expects($this->once())->method("isPayPal")->will($this->returnValue(true));
|
||||
|
||||
$this->getSession()->setVariable("oepaypal", "1");
|
||||
$this->assertEquals("payment", $view->changeWrapping());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for WrappingController::changeWrapping() - PayPal not active
|
||||
*/
|
||||
public function testChangeWrapping_PayPalNotActive()
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Controller\WrappingController::class);
|
||||
$mockBuilder->setMethods(['isPayPal']);
|
||||
$view = $mockBuilder->getMock();
|
||||
$view->expects($this->once())->method("isPayPal")->will($this->returnValue(false));
|
||||
|
||||
$this->assertEquals("order", $view->changeWrapping());
|
||||
}
|
||||
}
|
||||
361
shop/source/modules/oe/oepaypal/Tests/Unit/Core/CallerTest.php
Normal file
361
shop/source/modules/oe/oepaypal/Tests/Unit/Core/CallerTest.php
Normal file
@@ -0,0 +1,361 @@
|
||||
<?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\Tests\Unit\Core;
|
||||
|
||||
use OxidEsales\PayPalModule\Core\Caller;
|
||||
use OxidEsales\PayPalModule\Core\Exception\PayPalResponseException;
|
||||
use OxidEsales\PayPalModule\Core\Logger;
|
||||
|
||||
/**
|
||||
* Testing PayPal caller class.
|
||||
*/
|
||||
class CallerTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::setParameter()
|
||||
*/
|
||||
public function testSetParameter_setParameter_addedToSetOfParameters()
|
||||
{
|
||||
$service = new \OxidEsales\PayPalModule\Core\Caller();
|
||||
$service->setParameter("testParam", "testValue");
|
||||
$parameters = array("testParam" => "testValue");
|
||||
$this->assertEquals($parameters, $service->getParameters());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::setParameters()
|
||||
*/
|
||||
public function testSetParameters_setOneOrMoreParameters_addedToSetOfParameters()
|
||||
{
|
||||
$service = new \OxidEsales\PayPalModule\Core\Caller();
|
||||
|
||||
$service->setParameter("testParam", "testValue");
|
||||
$service->setParameters(array("testParam" => "testValue2", "testParam3" => "testValue3", "testParam4" => "testValue4"));
|
||||
$service->setParameter("testParam4", "testValue5");
|
||||
|
||||
$result["testParam"] = "testValue2";
|
||||
$result["testParam3"] = "testValue3";
|
||||
$result["testParam4"] = "testValue5";
|
||||
|
||||
$this->assertEquals($result, $service->getParameters());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::call()
|
||||
*/
|
||||
public function testCall_withMethodSuccessful_returnResponseArray()
|
||||
{
|
||||
$params = array();
|
||||
$params["testParam"] = "testValue";
|
||||
|
||||
$curlParams = $params;
|
||||
$curlParams["METHOD"] = "testMethod";
|
||||
|
||||
$url = 'http://url.com';
|
||||
$charset = 'latin';
|
||||
|
||||
$response = array('parameter', 'value');
|
||||
|
||||
$caller = new \OxidEsales\PayPalModule\Core\Caller();
|
||||
$caller->setParameters($params);
|
||||
|
||||
$caller->setCurl($this->prepareCurl($response, $curlParams, $url, $charset));
|
||||
|
||||
$this->assertEquals($response, $caller->call("testMethod"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::call()
|
||||
*/
|
||||
public function testCall_withoutMethod_returnResponseArray()
|
||||
{
|
||||
$params = array();
|
||||
$params["testParam"] = "testValue";
|
||||
|
||||
$curlParams = $params;
|
||||
|
||||
$url = 'http://url.com';
|
||||
$charset = 'latin';
|
||||
|
||||
$response = array('parameter', 'value');
|
||||
|
||||
$caller = new \OxidEsales\PayPalModule\Core\Caller();
|
||||
$caller->setParameters($params);
|
||||
|
||||
$caller->setCurl($this->prepareCurl($response, $curlParams, $url, $charset));
|
||||
|
||||
$this->assertEquals($response, $caller->call());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::call()
|
||||
*
|
||||
* @dataProvider callMethodNotSuccessfulProvider
|
||||
*/
|
||||
public function testCall_withMethodNotSuccessful_throwException(string $status)
|
||||
{
|
||||
$this->expectException(PayPalResponseException::class);
|
||||
|
||||
$response = [
|
||||
'ACK' => $status,
|
||||
'L_LONGMESSAGE0' => 'message',
|
||||
'L_ERRORCODE0' => 1
|
||||
];
|
||||
|
||||
$caller = $this->prepareCaller($response);
|
||||
$this->assertEquals($response, $caller->call());
|
||||
}
|
||||
|
||||
public function callMethodNotSuccessfulProvider(): array
|
||||
{
|
||||
return [
|
||||
['status' => 'Failure'],
|
||||
['status' => 'FailureWithWarning']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::call()
|
||||
*
|
||||
* @dataProvider callMethodWithWarningProvider
|
||||
*/
|
||||
public function testCall_withWarning(string $status, bool $expectException)
|
||||
{
|
||||
if ($expectException) {
|
||||
$this->expectException(PayPalResponseException::class);
|
||||
}
|
||||
|
||||
$response = [
|
||||
'ACK' => $status,
|
||||
'L_LONGMESSAGE0' => 'message',
|
||||
'L_ERRORCODE0' => 1
|
||||
];
|
||||
|
||||
$caller = $this->prepareCaller($response);
|
||||
|
||||
$logger = $this
|
||||
->getMockBuilder(Logger::class)
|
||||
->getMock();
|
||||
$logger
|
||||
->expects($this->at(4))
|
||||
->method('setTitle')
|
||||
->with('Response with warning from PayPal');
|
||||
$logger
|
||||
->expects($this->at(5))
|
||||
->method('log')
|
||||
->with($response);
|
||||
|
||||
$caller->setLogger($logger);
|
||||
|
||||
$this->assertEquals($response, $caller->call());
|
||||
|
||||
}
|
||||
|
||||
public function callMethodWithWarningProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'status' => 'SuccessWithWarning',
|
||||
'expectException' => false
|
||||
],
|
||||
[
|
||||
'status' => 'FailureWithWarning',
|
||||
'expectException' => true
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function prepareCaller(array $response): Caller
|
||||
{
|
||||
$params = [
|
||||
'testParam' => 'testValue'
|
||||
];
|
||||
|
||||
$caller = new Caller();
|
||||
$caller->setParameters($params);
|
||||
$caller->setCurl($this->prepareCurl($response, $params, 'http://url.com', 'latin'));
|
||||
|
||||
return $caller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::getCallBackResponse()
|
||||
*/
|
||||
public function testGetCallBackResponse_setParameters_getResponse()
|
||||
{
|
||||
$params = array(
|
||||
'param1' => 'value1',
|
||||
'param2' => 'value2',
|
||||
);
|
||||
|
||||
$caller = new \OxidEsales\PayPalModule\Core\Caller();
|
||||
$caller->setParameters($params);
|
||||
|
||||
$params['METHOD'] = 'CallbackResponse';
|
||||
$params = http_build_query($params);
|
||||
|
||||
$this->assertEquals($params, $caller->getCallBackResponse('CallbackResponse'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::getPayPalCurl()
|
||||
*/
|
||||
public function testGetCurl_notSet_returnedNewCreated()
|
||||
{
|
||||
$payPalCaller = new \OxidEsales\PayPalModule\Core\Caller();
|
||||
$payPalCurl = $payPalCaller->getCurl();
|
||||
$this->assertTrue(is_a($payPalCurl, \OxidEsales\PayPalModule\Core\Curl::class), 'Getter should create PayPal Curl object on request.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::getCurl()
|
||||
*/
|
||||
public function testSetCurl_setCurl_returnedSet()
|
||||
{
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$curl->setConnectionCharset('latin');
|
||||
|
||||
$caller = new \OxidEsales\PayPalModule\Core\Caller();
|
||||
$caller->setCurl($curl);
|
||||
$curl = $caller->getCurl();
|
||||
$this->assertTrue($curl instanceof \OxidEsales\PayPalModule\Core\Curl);
|
||||
$this->assertEquals('latin', $curl->getConnectionCharset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::getPayPalCurl()
|
||||
*/
|
||||
public function testSetRequest_RequestDataSetAsParameters()
|
||||
{
|
||||
$request = new \OxidEsales\PayPalModule\Model\PayPalRequest\PayPalRequest();
|
||||
$request->setData(array('param' => 'data'));
|
||||
|
||||
$caller = new \OxidEsales\PayPalModule\Core\Caller();
|
||||
|
||||
$caller->setRequest($request);
|
||||
$this->assertEquals(array('param' => 'data'), $caller->getParameters());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::getCharset()
|
||||
*/
|
||||
public function testGetLogger_notSet_null()
|
||||
{
|
||||
$caller = new \OxidEsales\PayPalModule\Core\Caller();
|
||||
$this->assertNull($caller->getLogger());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::getCharset()
|
||||
*/
|
||||
public function testGetLogger_setLogger_Logger()
|
||||
{
|
||||
$caller = new \OxidEsales\PayPalModule\Core\Caller();
|
||||
$caller->setLogger(new \OxidEsales\PayPalModule\Core\Logger());
|
||||
$this->assertTrue($caller->getLogger() instanceof \OxidEsales\PayPalModule\Core\Logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::log()
|
||||
*/
|
||||
public function testLog_notSetLogger_LoggerNotUsed()
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Caller::class);
|
||||
$mockBuilder->setMethods(['getLogger']);
|
||||
$caller = $mockBuilder->getMock();
|
||||
$caller->expects($this->once())->method('getLogger')->will($this->returnValue(null));
|
||||
$caller->log('logMassage');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::log()
|
||||
*/
|
||||
public function testLog_setLogger_LoggerUsed()
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Logger::class);
|
||||
$mockBuilder->setMethods(['log']);
|
||||
$logger = $mockBuilder->getMock();
|
||||
$logger->expects($this->once())->method('log')->with($this->equalTo('logMassage'));
|
||||
|
||||
$caller = new \OxidEsales\PayPalModule\Core\Caller();
|
||||
$caller->setLogger($logger);
|
||||
$caller->log('logMassage');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::log() usage in oePayPalCaller::call()
|
||||
*/
|
||||
public function testLogUsage_onCallMethod_atLeastOnce()
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Logger::class);
|
||||
$mockBuilder->setMethods(['log']);
|
||||
$logger = $mockBuilder->getMock();
|
||||
$logger->expects($this->atLeastOnce())->method('log');
|
||||
|
||||
$caller = new \OxidEsales\PayPalModule\Core\Caller();
|
||||
$caller->setLogger($logger);
|
||||
$caller->setParameters(array('k' => 'val'));
|
||||
$caller->setCurl($this->prepareCurl(array(), array('k' => 'val'), 'http://url.com', 'utf8'));
|
||||
|
||||
$caller->call();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Caller::log() usage in oePayPalCaller::getCallBackResponse()
|
||||
*/
|
||||
public function testLogUsage_onGetCallBackResponseMethod_atLeastOnce()
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Logger::class);
|
||||
$mockBuilder->setMethods(['log']);
|
||||
$logger = $mockBuilder->getMock();
|
||||
$logger->expects($this->atLeastOnce())->method('log');
|
||||
|
||||
$caller = new \OxidEsales\PayPalModule\Core\Caller();
|
||||
$caller->setLogger($logger);
|
||||
$caller->setParameters(array('k' => 'val'));
|
||||
$caller->setCurl($this->prepareCurl(array(), array('k' => 'val'), 'http://url.com', 'utf8'));
|
||||
$caller->call();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare curl stub
|
||||
*
|
||||
* @param array $response response
|
||||
* @param array $paramsCurl params
|
||||
* @param string $url url
|
||||
* @param string $charset charset
|
||||
*
|
||||
* @return \OxidEsales\PayPalModule\Core\Curl
|
||||
*/
|
||||
protected function prepareCurl($response, $paramsCurl, $url, $charset)
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Curl::class);
|
||||
$mockBuilder->setMethods(['execute', 'setUrlToCall', 'setParameters', 'setDataCharset']);
|
||||
$curl = $mockBuilder->getMock();
|
||||
$curl->expects($this->once())->method("execute")->will($this->returnValue($response));
|
||||
$curl->setDataCharset($charset);
|
||||
$curl->setParameters($paramsCurl);
|
||||
$curl->setUrlToCall($url);
|
||||
|
||||
return $curl;
|
||||
}
|
||||
}
|
||||
|
||||
762
shop/source/modules/oe/oepaypal/Tests/Unit/Core/ConfigTest.php
Normal file
762
shop/source/modules/oe/oepaypal/Tests/Unit/Core/ConfigTest.php
Normal file
@@ -0,0 +1,762 @@
|
||||
<?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\Tests\Unit\Core;
|
||||
|
||||
use OxidEsales\Eshop\Core\Language;
|
||||
use OxidEsales\Eshop\Core\Utils;
|
||||
|
||||
/**
|
||||
* Testing \OxidEsales\PayPalModule\Core\Config class.
|
||||
*/
|
||||
class ConfigTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/**
|
||||
* Cleans oxConfig table and calls parent::tearDown();
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute("delete from oxconfig where oxvarname like 'paypal_%'");
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans out the images that are created before image tests
|
||||
*/
|
||||
protected function cleanUp()
|
||||
{
|
||||
$imgDir = $this->getConfig()->getImageDir();
|
||||
if (!$shopLogo = $this->getConfig()->getConfigParam('sShopLogo')) {
|
||||
return;
|
||||
}
|
||||
$logoDir = $imgDir . "resized_$shopLogo";
|
||||
if (!file_exists($logoDir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
unlink($logoDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if gets correct module id.
|
||||
*/
|
||||
public function testGetModuleId()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$PayPalId = $config->getModuleId();
|
||||
$this->assertEquals('oepaypal', $PayPalId, 'PayPal module should be oepaypal not ' . $PayPalId);
|
||||
}
|
||||
|
||||
public function providerGetBrandName()
|
||||
{
|
||||
return array(
|
||||
array('', '', ''),
|
||||
array('', 'testShopName', 'testShopName'),
|
||||
array('testPayPalShopName', 'testBrandName', 'testPayPalShopName'),
|
||||
array('testPayPalShopName', '', 'testPayPalShopName'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Config::getBrandName()
|
||||
*
|
||||
* @dataProvider providerGetBrandName
|
||||
*
|
||||
* @param string $paramName
|
||||
* @param string $shopName
|
||||
* @param string $resultName
|
||||
*/
|
||||
public function testGetBrandName($paramName, $shopName, $resultName)
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('sOEPayPalBrandName', $paramName);
|
||||
|
||||
$shop = $this->getConfig()->getActiveShop();
|
||||
$shop->oxshops__oxname = new \OxidEsales\Eshop\Core\Field($shopName);
|
||||
$shop->save();
|
||||
|
||||
$this->assertEquals($resultName, $config->getBrandName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for \OxidEsales\PayPalModule\Core\Config::sendOrderInfoToPayPal()
|
||||
*/
|
||||
public function testSendOrderInfoToPayPal()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSendToPayPal', true);
|
||||
$this->assertTrue($config->sendOrderInfoToPayPal());
|
||||
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSendToPayPal', false);
|
||||
$this->assertFalse($config->sendOrderInfoToPayPal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::isGuestBuyEnabled()
|
||||
*/
|
||||
public function testIsGuestBuyEnabled()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('blOEPayPalGuestBuyRole', true);
|
||||
$this->assertTrue($config->isGuestBuyEnabled());
|
||||
|
||||
$this->getConfig()->setConfigParam('blOEPayPalGuestBuyRole', false);
|
||||
$this->assertFalse($config->isGuestBuyEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::isGiroPayEnabled()
|
||||
*/
|
||||
public function testIsGiroPayEnabled()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertFalse($config->isGiroPayEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::isSandboxEnabled()
|
||||
*/
|
||||
public function testIsSandboxEnabled()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', true);
|
||||
$this->assertTrue($config->isSandboxEnabled());
|
||||
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', false);
|
||||
$this->assertFalse($config->isSandboxEnabled());
|
||||
}
|
||||
|
||||
public function providerGetPayPalHost()
|
||||
{
|
||||
return array(
|
||||
// Default PayPal sandbox host
|
||||
array(true, null, null, 'api-3t.sandbox.paypal.com'),
|
||||
// Default PayPal host.
|
||||
array(false, null, null, 'api-3t.paypal.com'),
|
||||
// Sandbox on; PayPal sandbox host NOT set; PayPal host set; Sandbox default host return.
|
||||
array(true, null, 'paypalApiUrl', 'api-3t.sandbox.paypal.com'),
|
||||
// Sandbox off; PayPal sandbox host set; PayPal host NOT set; PayPal default host return.
|
||||
array(false, 'sandboxApiUrl', null, 'api-3t.paypal.com'),
|
||||
// Sandbox on; PayPal sandbox host set; PayPal host set; PayPal set sandbox host return.
|
||||
array(true, 'sandboxApiUrl', 'paypalApiUrl', 'sandboxApiUrl'),
|
||||
// Sandbox off; PayPal sandbox host set; PayPal host set; PayPal set host return.
|
||||
array(false, 'sandboxApiUrl', 'paypalApiUrl', 'paypalApiUrl'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if return what is set in setter.
|
||||
* Test ir return default value if not set in setter.
|
||||
*
|
||||
* @dataProvider providerGetPayPalHost
|
||||
*/
|
||||
public function testGetHost($sandboxEnabled, $payPalSandboxHost, $payPalHost, $result)
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', $sandboxEnabled);
|
||||
|
||||
if (!empty($payPalSandboxHost)) {
|
||||
$config->setPayPalSandboxHost($payPalSandboxHost);
|
||||
}
|
||||
if (!empty($payPalHost)) {
|
||||
$config->setPayPalHost($payPalHost);
|
||||
}
|
||||
|
||||
$this->assertEquals($result, $config->getHost());
|
||||
}
|
||||
|
||||
public function testGetPayPalHost_setWithSetter_setValue()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$config->setPayPalHost('PayPalHost');
|
||||
|
||||
$this->assertEquals('PayPalHost', $config->getPayPalHost(), 'Getter must return what is set in setter.');
|
||||
}
|
||||
|
||||
public function testGetPayPalHost_default_definedClassAttribute()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals('api-3t.paypal.com', $config->getPayPalHost());
|
||||
}
|
||||
|
||||
public function testGetPayPalHost_overrideWithConfig_configValue()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('sPayPalHost', 'configHost');
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals('configHost', $config->getPayPalHost());
|
||||
}
|
||||
|
||||
public function testGetPayPalSandboxHost_setWithSetter_setValue()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$config->setPayPalSandboxHost('PayPalSandboxHost');
|
||||
|
||||
$this->assertEquals('PayPalSandboxHost', $config->getPayPalSandboxHost());
|
||||
}
|
||||
|
||||
public function testGetPayPalSandboxHost_default_definedClassAttribute()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals('api-3t.sandbox.paypal.com', $config->getPayPalSandboxHost());
|
||||
}
|
||||
|
||||
public function testGetPayPalSandboxHost_overrideWithConfig_configValue()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('sPayPalSandboxHost', 'configHost');
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals('configHost', $config->getPayPalSandboxHost());
|
||||
}
|
||||
|
||||
|
||||
public function providerGetApiUrl()
|
||||
{
|
||||
return array(
|
||||
array(true, null, null, 'https://api-3t.sandbox.paypal.com/nvp'),
|
||||
array(false, null, null, 'https://api-3t.paypal.com/nvp'),
|
||||
array(true, null, 'paypalApiUrl', 'https://api-3t.sandbox.paypal.com/nvp'),
|
||||
array(false, 'sandboxApiUrl', null, 'https://api-3t.paypal.com/nvp'),
|
||||
array(true, 'sandboxApiUrl', 'paypalApiUrl', 'sandboxApiUrl'),
|
||||
array(false, 'sandboxApiUrl', 'paypalApiUrl', 'paypalApiUrl'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::getEndPointUrl()
|
||||
*
|
||||
* @dataProvider providerGetApiUrl
|
||||
*/
|
||||
public function testApiUrl($sandBoxEnabled, $sandBoxApiUrl, $apiUrl, $result)
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', $sandBoxEnabled);
|
||||
|
||||
if (!empty($sandBoxApiUrl)) {
|
||||
$config->setPayPalSandboxApiUrl($sandBoxApiUrl);
|
||||
}
|
||||
if (!empty($apiUrl)) {
|
||||
$config->setPayPalApiUrl($apiUrl);
|
||||
}
|
||||
|
||||
$this->assertEquals($result, $config->getApiUrl());
|
||||
}
|
||||
|
||||
public function testGetPayPalSandboxApiUrl_setWithSetter_setValue()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$config->setPayPalSandboxApiUrl('ApiPayPalSandboxHost');
|
||||
|
||||
$this->assertEquals('ApiPayPalSandboxHost', $config->getPayPalSandboxApiUrl());
|
||||
}
|
||||
|
||||
public function testGetPayPalSandboxApiUrl_default_definedClassAttribute()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals('https://api-3t.sandbox.paypal.com/nvp', $config->getPayPalSandboxApiUrl());
|
||||
}
|
||||
|
||||
public function testGetPayPalSandboxApiUrl_overrideWithConfig_configValue()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('sPayPalSandboxApiUrl', 'apiConfigHost');
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals('apiConfigHost', $config->getPayPalSandboxApiUrl());
|
||||
}
|
||||
|
||||
public function testGetPayPalApiUrl_setWithSetter_setValue()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$config->setPayPalApiUrl('ApiPayPalSandboxHost');
|
||||
|
||||
$this->assertEquals('ApiPayPalSandboxHost', $config->getPayPalApiUrl());
|
||||
}
|
||||
|
||||
public function testGetPayPalApiUrl_default_definedClassAttribute()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals('https://api-3t.paypal.com/nvp', $config->getPayPalApiUrl());
|
||||
}
|
||||
|
||||
public function testGetPayPalApiUrl_overrideWithConfig_configValue()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('sPayPalApiUrl', 'apiConfigHost');
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals('apiConfigHost', $config->getPayPalApiUrl());
|
||||
}
|
||||
|
||||
public function testGetPayPalSandboxUrl_setWithSetter_setValue()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$config->setPayPalSandboxUrl('ApiPayPalSandboxHost');
|
||||
|
||||
$this->assertEquals('ApiPayPalSandboxHost', $config->getPayPalSandboxUrl());
|
||||
}
|
||||
|
||||
public function testGetPayPalSandboxUrl_default_definedClassAttribute()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals('https://www.sandbox.paypal.com/cgi-bin/webscr', $config->getPayPalSandboxUrl());
|
||||
}
|
||||
|
||||
public function testGetPayPalSandboxUrl_overrideWithConfig_configValue()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('sPayPalSandboxUrl', 'ConfigHost');
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals('ConfigHost', $config->getPayPalSandboxUrl());
|
||||
}
|
||||
|
||||
public function testGetPayPalUrl_setWithSetter_setValue()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$config->setPayPalUrl('ApiPayPalSandboxHost');
|
||||
|
||||
$this->assertEquals('ApiPayPalSandboxHost', $config->getPayPalUrl());
|
||||
}
|
||||
|
||||
public function testGetPayPalUrl_default_definedClassAttribute()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals('https://www.paypal.com/cgi-bin/webscr', $config->getPayPalUrl());
|
||||
}
|
||||
|
||||
public function testGetPayPalUrl_overrideWithConfig_configValue()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('sPayPalUrl', 'ConfigUrl');
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals('ConfigUrl', $config->getPayPalUrl());
|
||||
}
|
||||
|
||||
public function providerGetPayPalCommunicationUrl()
|
||||
{
|
||||
return array(
|
||||
array(true, null, null, 'TestToken', 'continue', 'https://www.sandbox.paypal.com/cgi-bin/webscr&cmd=_express-checkout&token=TestToken&useraction=continue'),
|
||||
array(false, null, null, 'TestToken', 'commit', 'https://www.paypal.com/cgi-bin/webscr&cmd=_express-checkout&token=TestToken&useraction=commit'),
|
||||
array(true, null, 'paypalApiUrl', 'TestToken1', 'commit', 'https://www.sandbox.paypal.com/cgi-bin/webscr&cmd=_express-checkout&token=TestToken1&useraction=commit'),
|
||||
array(false, 'sandboxApiUrl', null, 'TestToken1', 'continue', 'https://www.paypal.com/cgi-bin/webscr&cmd=_express-checkout&token=TestToken1&useraction=continue'),
|
||||
array(true, 'sandboxApiUrl', 'paypalApiUrl', 'TestToken2', 'action', 'sandboxApiUrl&cmd=_express-checkout&token=TestToken2&useraction=action'),
|
||||
array(false, 'sandboxApiUrl', 'paypalApiUrl', 'TestToken2', 'action', 'paypalApiUrl&cmd=_express-checkout&token=TestToken2&useraction=action'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::getUrl()
|
||||
*
|
||||
* @dataProvider providerGetPayPalCommunicationUrl
|
||||
*/
|
||||
public function testGetPayPalCommunicationUrl($sandBoxEnabled, $sandBoxApiUrl, $apiUrl, $token, $userAction, $result)
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', $sandBoxEnabled);
|
||||
|
||||
if (!empty($sandBoxApiUrl)) {
|
||||
$config->setPayPalSandboxUrl($sandBoxApiUrl);
|
||||
}
|
||||
if (!empty($apiUrl)) {
|
||||
$config->setPayPalUrl($apiUrl);
|
||||
}
|
||||
|
||||
$this->assertEquals($result, $config->getPayPalCommunicationUrl($token, $userAction));
|
||||
}
|
||||
|
||||
public function providerGetTextConfig()
|
||||
{
|
||||
return array(
|
||||
array(true, 'text1', 'text2', 'text1'),
|
||||
array(false, 'text1', 'text2', 'text2'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::getPassword()
|
||||
*
|
||||
* @dataProvider providerGetTextConfig
|
||||
*/
|
||||
public function testGetPassword($sandBoxEnabled, $sandBoxPassword, $password, $result)
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', $sandBoxEnabled);
|
||||
$this->getConfig()->setConfigParam('sOEPayPalSandboxPassword', $sandBoxPassword);
|
||||
$this->getConfig()->setConfigParam('sOEPayPalPassword', $password);
|
||||
$this->assertEquals($result, $config->getPassword());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::getUserName()
|
||||
*
|
||||
* @dataProvider providerGetTextConfig
|
||||
*/
|
||||
public function testGetUserName($sandBoxEnabled, $sandBoxUsername, $username, $result)
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', $sandBoxEnabled);
|
||||
$this->getConfig()->setConfigParam('sOEPayPalSandboxUsername', $sandBoxUsername);
|
||||
$this->getConfig()->setConfigParam('sOEPayPalUsername', $username);
|
||||
$this->assertEquals($result, $config->getUserName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::getSignature()
|
||||
*
|
||||
* @dataProvider providerGetTextConfig
|
||||
*/
|
||||
public function testGetSignature($sandBoxEnabled, $sandBoxSignature, $signature, $result)
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', $sandBoxEnabled);
|
||||
$this->getConfig()->setConfigParam('sOEPayPalSandboxSignature', $sandBoxSignature);
|
||||
$this->getConfig()->setConfigParam('sOEPayPalSignature', $signature);
|
||||
$this->assertEquals($result, $config->getSignature());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::getTransactionMode()
|
||||
*/
|
||||
public function testGetTransactionMode()
|
||||
{
|
||||
$transMode = 'Sale';
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('sOEPayPalTransactionMode', $transMode);
|
||||
|
||||
$this->assertEquals($transMode, $config->getTransactionMode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::isLoggingEnabled()
|
||||
*/
|
||||
public function testIsLoggingEnabled()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('blPayPalLoggerEnabled', true);
|
||||
$this->assertTrue($config->isLoggingEnabled());
|
||||
|
||||
$this->getConfig()->setConfigParam('blPayPalLoggerEnabled', false);
|
||||
$this->assertFalse($config->isLoggingEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::isLoggingEnabled()
|
||||
*/
|
||||
public function testIsExpressCheckoutInMiniBasketEnabled()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('blOEPayPalECheckoutInMiniBasket', true);
|
||||
$this->assertTrue($config->isExpressCheckoutInMiniBasketEnabled());
|
||||
|
||||
$this->getConfig()->setConfigParam('blOEPayPalECheckoutInMiniBasket', false);
|
||||
$this->assertFalse($config->isExpressCheckoutInMiniBasketEnabled());
|
||||
}
|
||||
|
||||
|
||||
public function providerGetShopLogoUrl()
|
||||
{
|
||||
$shopImageLocation = $this->getConfig()->getImageUrl();
|
||||
|
||||
return array(
|
||||
array("noLogo", "logo.png", "", false),
|
||||
array("shopLogo", "logo.png", "logo_ee.png", $shopImageLocation . "resized_logo.png"),
|
||||
array("customLogo", "logo.png", "logo.png", $shopImageLocation . "resized_logo.png"),
|
||||
array("shopLogo", "login-fb.png", "logo.png", $shopImageLocation . "login-fb.png"),
|
||||
array("customLogo", "logo.png", "login-fb.png", $shopImageLocation . "login-fb.png"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if correct shop logo is returned with various options
|
||||
*
|
||||
* @dataProvider providerGetShopLogoUrl
|
||||
*
|
||||
* @param string $option
|
||||
* @param string $shopLogoImage
|
||||
* @param string $customLogoImage
|
||||
* @param string $expected
|
||||
*/
|
||||
public function testGetShopLogoUrl($option, $shopLogoImage, $customLogoImage, $expected)
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam("sOEPayPalLogoImageOption", $option);
|
||||
$this->getConfig()->setConfigParam("sOEPayPalCustomShopLogoImage", $customLogoImage);
|
||||
$this->getConfig()->setConfigParam("sShopLogo", $shopLogoImage);
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\Eshop\Core\UtilsPic::class);
|
||||
$mockBuilder->setMethods(['resizeImage']);
|
||||
$utilsUrl = $mockBuilder->getMock();
|
||||
$utilsUrl->expects($this->any())->method('resizeImage')->will($this->returnValue(true));
|
||||
\OxidEsales\Eshop\Core\Registry::set(\OxidEsales\Eshop\Core\UtilsPic::class, $utilsUrl);
|
||||
|
||||
$this->assertEquals($expected, $config->getLogoUrl());
|
||||
$this->cleanUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Incorrect file name provider
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function providerGetShopLogoUrlIncorrectFilename()
|
||||
{
|
||||
return array(
|
||||
array("shopLogo", "", "notexisting.png"),
|
||||
array("customLogo", "notexisting.png", ""),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that getLogoUrl returns false when filename is incorrect
|
||||
*
|
||||
* @dataProvider providerGetShopLogoUrlIncorrectFilename
|
||||
*/
|
||||
public function testGetShopLogoUrlIncorrectFilename($option, $shopLogoImage, $customLogoImage)
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam("sOEPayPalLogoImageOption", $option);
|
||||
$this->getConfig()->setConfigParam("sOEPayPalCustomShopLogoImage", $customLogoImage);
|
||||
$this->getConfig()->setConfigParam("sShopLogo", $shopLogoImage);
|
||||
|
||||
$this->assertFalse($config->getLogoUrl());
|
||||
$this->cleanUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::getIPNCallbackUrl
|
||||
*/
|
||||
public function testGetIPNCallbackUrl()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$callbackBaseUrl = $config->getIPNCallbackUrl();
|
||||
$this->assertEquals($callbackBaseUrl, $this->getConfig()->getCurrentShopUrl() . "index.php?cl=oepaypalipnhandler&fnc=handleRequest&shp=" . $this->getConfig()->getShopId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::getIPNUrl()
|
||||
*/
|
||||
public function testGetIPNResponseUrl_sandboxOFF_usePayPalUrl()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', false);
|
||||
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals($config->getIPNResponseUrl(), 'https://www.paypal.com/cgi-bin/webscr&cmd=_notify-validate');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::getIPNUrl()
|
||||
*/
|
||||
public function testGetIPNResponseUrl_sandboxON_useSandboxUrl()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', true);
|
||||
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals($config->getIPNResponseUrl(), 'https://www.sandbox.paypal.com/cgi-bin/webscr&cmd=_notify-validate');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::getIPNUrl()
|
||||
*/
|
||||
public function testGetUrl_sandboxOFF_returnPayPalUrl()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', false);
|
||||
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals($config->getUrl(), 'https://www.paypal.com/cgi-bin/webscr');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::getIPNUrl()
|
||||
*/
|
||||
public function testGetUrl_sandboxON_returnSandboxUrl()
|
||||
{
|
||||
$this->getConfig()->setConfigParam('blOEPayPalSandboxMode', true);
|
||||
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals($config->getUrl(), 'https://www.sandbox.paypal.com/cgi-bin/webscr');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::getShopUrl
|
||||
*/
|
||||
public function testGetShopUrl()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$shopUrl = $config->getShopUrl();
|
||||
$this->assertEquals($shopUrl, $this->getConfig()->getCurrentShopUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::getLang
|
||||
*/
|
||||
public function testGetLang()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$lang = $config->getLang();
|
||||
|
||||
$this->assertTrue(is_a($lang, Language::class), 'Method getLang() should return language object.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for Config::getUtils
|
||||
*/
|
||||
public function testGetUtils()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$utils = $config->getUtils();
|
||||
|
||||
$this->assertTrue(is_a($utils, Utils::class), 'Method getUtils() should return utils object.');
|
||||
}
|
||||
|
||||
public function providerIsExpressCheckoutInDetailsPage()
|
||||
{
|
||||
return array(
|
||||
array(true),
|
||||
array(false)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test blOEPayPalECheckoutInDetails config
|
||||
*
|
||||
* @dataProvider providerIsExpressCheckoutInDetailsPage
|
||||
*/
|
||||
public function testIsExpressCheckoutInDetailsPage($oEPayPalECheckoutInDetails)
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('blOEPayPalECheckoutInDetails', $oEPayPalECheckoutInDetails);
|
||||
$this->assertEquals($oEPayPalECheckoutInDetails, $config->isExpressCheckoutInDetailsPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if method returns current URL
|
||||
*/
|
||||
public function testGetCurrentUrl()
|
||||
{
|
||||
$currentUrl = 'http://oxideshop.com/test';
|
||||
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\Eshop\Core\UtilsUrl::class);
|
||||
$mockBuilder->setMethods(['getCurrentUrl']);
|
||||
$utilsUrl = $mockBuilder->getMock();
|
||||
$utilsUrl->expects($this->any())->method('getCurrentUrl')->will($this->returnValue($currentUrl));
|
||||
\OxidEsales\Eshop\Core\Registry::set(\OxidEsales\Eshop\Core\UtilsUrl::class, $utilsUrl);
|
||||
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals($currentUrl, $config->getCurrentUrl());
|
||||
}
|
||||
|
||||
|
||||
public function providerGetMaxPayPalDeliveryAmount()
|
||||
{
|
||||
return array(
|
||||
array(40.5, 40.5),
|
||||
array(-0.51, -0.51)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks max delivery amount setting.
|
||||
*
|
||||
* @dataProvider providerGetMaxPayPalDeliveryAmount
|
||||
*/
|
||||
public function testGetMaxPayPalDeliveryAmount_configSetWithProperValues_configValue($maxAmount, $expectedAmount)
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('dMaxPayPalDeliveryAmount', $maxAmount);
|
||||
$this->assertEquals($expectedAmount, $config->getMaxPayPalDeliveryAmount());
|
||||
}
|
||||
|
||||
public function providerGetMaxPayPalDeliveryAmountBadConfigs()
|
||||
{
|
||||
return array(
|
||||
array(null, 30),
|
||||
array(0, 30),
|
||||
array(false, 30),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks max delivery amount setting.
|
||||
*
|
||||
* @dataProvider providerGetMaxPayPalDeliveryAmountBadConfigs
|
||||
*/
|
||||
public function testGetMaxPayPalDeliveryAmount_configSetWithFalseValues_30($maxAmount, $expectedAmount)
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('dMaxPayPalDeliveryAmount', $maxAmount);
|
||||
$this->assertEquals($expectedAmount, $config->getMaxPayPalDeliveryAmount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks max delivery amount setting.
|
||||
*
|
||||
* @dataProvider providerGetMaxPayPalDeliveryAmount
|
||||
*/
|
||||
public function testGetMaxPayPalDeliveryAmount_default_30()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals(30, $config->getMaxPayPalDeliveryAmount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if partner code is returned correct.
|
||||
* Testing non-shortcut partner codes here.
|
||||
*/
|
||||
public function testGetPartnerCode()
|
||||
{
|
||||
$config = $this->getConfig();
|
||||
$result = 'O3SHOP_Cart_CommunityECS';
|
||||
$payPalConfig = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals($result, $payPalConfig->getPartnerCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if partner code is returned correct in case the shortcut was used.
|
||||
*/
|
||||
public function testGetShortcutPartnerCode()
|
||||
{
|
||||
\OxidEsales\Eshop\Core\Registry::getSession()->setVariable(\OxidEsales\PayPalModule\Core\Config::OEPAYPAL_TRIGGER_NAME,
|
||||
\OxidEsales\PayPalModule\Core\Config::OEPAYPAL_SHORTCUT);
|
||||
$expected = 'O3SHOP_Cart_ECS_Shortcut';
|
||||
|
||||
$payPalConfig = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertEquals($expected, $payPalConfig->getPartnerCode());
|
||||
}
|
||||
|
||||
public function testGetMobileECDefaultShippingId_notSet_null()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertNull($config->getMobileECDefaultShippingId());
|
||||
}
|
||||
|
||||
public function testGetMobileECDefaultShippingId_setPayment_paymentId()
|
||||
{
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->getConfig()->setConfigParam('sOEPayPalMECDefaultShippingId', 'shippingId');
|
||||
$this->assertEquals('shippingId', $config->getMobileECDefaultShippingId());
|
||||
}
|
||||
|
||||
public function testIsMobile_mobileDevice_true()
|
||||
{
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3';
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertTrue($config->isDeviceMobile());
|
||||
}
|
||||
|
||||
public function testIsMobile_notMobileDevice_false()
|
||||
{
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0';
|
||||
$config = new \OxidEsales\PayPalModule\Core\Config();
|
||||
$this->assertFalse($config->isDeviceMobile());
|
||||
}
|
||||
}
|
||||
309
shop/source/modules/oe/oepaypal/Tests/Unit/Core/CurlTest.php
Normal file
309
shop/source/modules/oe/oepaypal/Tests/Unit/Core/CurlTest.php
Normal file
@@ -0,0 +1,309 @@
|
||||
<?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\Tests\Unit\Core;
|
||||
|
||||
/**
|
||||
* Testing curl class.
|
||||
*/
|
||||
class CurlTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/**
|
||||
* Checks if function returns null when nothing is set.
|
||||
*/
|
||||
public function testGetHost_notSet_null()
|
||||
{
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$this->assertNull($curl->getHost(), 'Default value must be null.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if getter returns what is set in setter.
|
||||
*/
|
||||
public function testGetHost_setHost_host()
|
||||
{
|
||||
$host = 'someHost';
|
||||
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$curl->setHost($host);
|
||||
|
||||
$this->assertEquals($host, $curl->getHost(), 'Check if getter returns what is set in setter.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if returned header is correct when header was not set and host was set.
|
||||
*/
|
||||
public function testGetHeader_headerNotSetAndHostSet_headerWithHost()
|
||||
{
|
||||
$host = 'someHost';
|
||||
$expectedHeader = array(
|
||||
'POST /cgi-bin/webscr HTTP/1.1',
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'Host: ' . $host,
|
||||
'Connection: close'
|
||||
);
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$curl->setHost($host);
|
||||
|
||||
$this->assertEquals($expectedHeader, $curl->getHeader(), 'Header must be formed from set host.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if returned header is correct when header was not set and host was not set.
|
||||
*/
|
||||
public function testGetHeader_headerNotSetAndHostNotSet_headerWithoutHost()
|
||||
{
|
||||
$expectedHeader = array(
|
||||
'POST /cgi-bin/webscr HTTP/1.1',
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'Connection: close'
|
||||
);
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
|
||||
$this->assertEquals($expectedHeader, $curl->getHeader(), 'Header must be without host as host not set.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if returned header is correct when header was set and host was set.
|
||||
*/
|
||||
public function testGetHeader_headerSetAndHostSet_headerFromSet()
|
||||
{
|
||||
$host = 'someHost';
|
||||
$header = array('Test header');
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$curl->setHost($host);
|
||||
$curl->setHeader($header);
|
||||
|
||||
$this->assertEquals($header, $curl->getHeader(), 'Header must be same as set header.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if returned header is correct when header was set and host was not set.
|
||||
*/
|
||||
public function testGetHeader_headerSetAndHostNotSet_headerWithoutHost()
|
||||
{
|
||||
$header = array('Test header');
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$curl->setHeader($header);
|
||||
|
||||
$this->assertEquals($header, $curl->getHeader(), 'Header must be same as set header.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::setConnectionCharset()
|
||||
*/
|
||||
public function testSetConnectionCharset_set_get()
|
||||
{
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$curl->setConnectionCharset('ISO-8859-1');
|
||||
|
||||
$this->assertEquals('ISO-8859-1', $curl->getConnectionCharset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::getConnectionCharset()
|
||||
*/
|
||||
public function testGetConnectionCharset_notSet_UTF()
|
||||
{
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$this->assertEquals('UTF-8', $curl->getConnectionCharset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::setDataCharset()
|
||||
*/
|
||||
public function testSetDataCharset_set_get()
|
||||
{
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$curl->setDataCharset('ISO-8859-1');
|
||||
|
||||
$this->assertEquals('ISO-8859-1', $curl->getDataCharset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::getDataCharset()
|
||||
*/
|
||||
public function testGetDataCharset_notSet_UTF()
|
||||
{
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$this->assertEquals('UTF-8', $curl->getDataCharset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::setEnvironmentParameter()
|
||||
*/
|
||||
public function testSetEnvironmentParameter_setParameter_addedToParameterSet()
|
||||
{
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$curl->setEnvironmentParameter('param', 'value');
|
||||
|
||||
$expectedParameters = array(
|
||||
'CURLOPT_VERBOSE' => 0,
|
||||
'CURLOPT_SSL_VERIFYPEER' => false,
|
||||
'CURLOPT_SSL_VERIFYHOST' => false,
|
||||
'CURLOPT_SSLVERSION' => 6,
|
||||
'CURLOPT_RETURNTRANSFER' => 1,
|
||||
'CURLOPT_POST' => 1,
|
||||
'CURLOPT_HTTP_VERSION' => 2,
|
||||
'param' => 'value'
|
||||
);
|
||||
|
||||
$this->assertEquals($expectedParameters, $curl->getEnvironmentParameters());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::getEnvironmentParameters()
|
||||
*/
|
||||
public function testGetEnvironmentParameters_default_returnDefaultSet()
|
||||
{
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
|
||||
$expectedParameters = array(
|
||||
'CURLOPT_VERBOSE' => 0,
|
||||
'CURLOPT_SSL_VERIFYPEER' => false,
|
||||
'CURLOPT_SSL_VERIFYHOST' => false,
|
||||
'CURLOPT_SSLVERSION' => 6,
|
||||
'CURLOPT_RETURNTRANSFER' => 1,
|
||||
'CURLOPT_POST' => 1,
|
||||
'CURLOPT_HTTP_VERSION' => 2,
|
||||
);
|
||||
|
||||
$this->assertEquals($expectedParameters, $curl->getEnvironmentParameters());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::getParameters()
|
||||
*/
|
||||
public function testGetParameters_default_null()
|
||||
{
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$this->assertNull($curl->getParameters());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::getParameters()
|
||||
*/
|
||||
public function testGetParameters_set_returnSet()
|
||||
{
|
||||
$parameters = array('parameter' => 'value');
|
||||
|
||||
$curl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$curl->setParameters($parameters);
|
||||
$this->assertEquals($parameters, $curl->getParameters());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::setUrlToCall()
|
||||
* Test Curl::getUrlToCall()
|
||||
*/
|
||||
public function testGetUrlToCall_urlSet_setReturned()
|
||||
{
|
||||
$endpointUrl = 'http://www.oxid-esales.com/index.php?anid=article';
|
||||
|
||||
$payPalCurl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$payPalCurl->setUrlToCall($endpointUrl);
|
||||
$urlToCall = $payPalCurl->getUrlToCall();
|
||||
|
||||
$this->assertEquals($endpointUrl, $urlToCall, 'Url should be same as provided from config.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::getUrlToCall()
|
||||
*/
|
||||
public function testGetUrlToCall_notSet_null()
|
||||
{
|
||||
$payPalCurl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$this->assertNull($payPalCurl->getUrlToCall());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::setUrlToCall()
|
||||
* Test Curl::getUrlToCall()
|
||||
*/
|
||||
public function testGetUrlToCall_badUrlSet_Exception()
|
||||
{
|
||||
$this->expectException(\OxidEsales\PayPalModule\Core\Exception\PayPalException::class);
|
||||
|
||||
$endpointUrl = 'url';
|
||||
$payPalCurl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$payPalCurl->setUrlToCall($endpointUrl);
|
||||
|
||||
$this->assertEquals($endpointUrl, $payPalCurl->getUrlToCall());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::setQuery()
|
||||
*/
|
||||
public function testSetQuery_set_get()
|
||||
{
|
||||
$payPalCurl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$payPalCurl->setQuery('param1=value1¶m2=values2');
|
||||
|
||||
$this->assertEquals('param1=value1¶m2=values2', $payPalCurl->getQuery());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::getQuery()
|
||||
*/
|
||||
public function testGetQuery_setParameter_getQueryFromParameters()
|
||||
{
|
||||
$payPalCurl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$payPalCurl->setParameters(array('param1' => 'value1', 'param2' => 'values2'));
|
||||
|
||||
$this->assertEquals('param1=value1¶m2=values2', $payPalCurl->getQuery());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::getQuery()
|
||||
*/
|
||||
public function testGetQuery_setParameterNotUtf_getQueryFromParameters()
|
||||
{
|
||||
$payPalCurl = new \OxidEsales\PayPalModule\Core\Curl();
|
||||
$payPalCurl->setDataCharset('ISO-8859-1');
|
||||
$payPalCurl->setParameters(array('param1' => 'J<>ger', 'param2' => 'values2'));
|
||||
|
||||
$pramsUtf = array('param1' => utf8_encode('J<>ger'), 'param2' => 'values2');
|
||||
|
||||
$this->assertEquals(http_build_query($pramsUtf), $payPalCurl->getQuery());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Curl::execute()
|
||||
*/
|
||||
public function testExecute_setParameters_getResponseArray()
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder(\OxidEsales\PayPalModule\Core\Curl::class);
|
||||
$mockBuilder->setMethods(['curlExecute', 'setOption', 'parseResponse', 'close']);
|
||||
$payPalCurl = $mockBuilder->getMock();
|
||||
|
||||
$payPalCurl->expects($this->any())->method('setOption');
|
||||
$payPalCurl->expects($this->once())->method('curlExecute')->will($this->returnValue('rParam1=rValue1'));
|
||||
$payPalCurl->expects($this->once())->method('parseResponse')
|
||||
->with($this->equalTo('rParam1=rValue1'))
|
||||
->will($this->returnValue(array('rParam1' => 'rValue1')));
|
||||
$payPalCurl->expects($this->once())->method('close');
|
||||
|
||||
$payPalCurl->setParameters(array('param1' => 'value1', 'param2' => 'values2'));
|
||||
$payPalCurl->setUrlToCall('http://url');
|
||||
|
||||
$this->assertEquals(array('rParam1' => 'rValue1'), $payPalCurl->execute());
|
||||
}
|
||||
// public function testExecute_getParameters
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?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\Tests\Unit\Core;
|
||||
|
||||
/**
|
||||
* Testing \OxidEsales\PayPalModule\Core\Escape class.
|
||||
*/
|
||||
class EscapeTest extends \OxidEsales\TestingLibrary\UnitTestCase
|
||||
{
|
||||
/**
|
||||
* Testing input processor. Checking 3 cases - passing object, array, string.
|
||||
*/
|
||||
public function testCheckParamSpecialChars()
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$object->xxx = 'yyy';
|
||||
$array = array('&\\o<x>i"\'d' . chr(0));
|
||||
$string = '&\\o<x>i"\'d' . chr(0);
|
||||
$payPalRequest = new \OxidEsales\PayPalModule\Core\Request();
|
||||
|
||||
// object must came back the same
|
||||
$this->assertEquals($object, $payPalRequest->escapeSpecialChars($object));
|
||||
|
||||
// array items comes fixed
|
||||
$this->assertEquals(array('&\o<x>i"'d'), $payPalRequest->escapeSpecialChars($array));
|
||||
|
||||
// string comes fixed
|
||||
$this->assertEquals('&\o<x>i"'d', $payPalRequest->escapeSpecialChars($string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testCheckParamSpecialCharsAlsoFixesArrayKeys()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function providerCheckParamSpecialCharsAlsoFixesArrayKeys()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array('asd&' => 'a%&'),
|
||||
array('asd&' => 'a%&'),
|
||||
),
|
||||
array(
|
||||
'asd&',
|
||||
'asd&',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if checkParamSpecialChars also can fix arrays
|
||||
*
|
||||
* @dataProvider providerCheckParamSpecialCharsAlsoFixesArrayKeys
|
||||
*/
|
||||
public function testCheckParamSpecialCharsAlsoFixesArrayKeys($checkData, $checkExpectedResult)
|
||||
{
|
||||
$payPalRequest = new \OxidEsales\PayPalModule\Core\Request();
|
||||
$this->assertEquals($checkExpectedResult, $payPalRequest->escapeSpecialChars($checkData));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user