Skip to content

Commit

Permalink
Merge pull request #255 from OXID-eSales/b-7.0.x-apple-cert-UNZER-323
Browse files Browse the repository at this point in the history
B 7.0.x apple cert unzer 323
  • Loading branch information
dmitriivolkhinoxid authored Apr 23, 2024
2 parents 9e78b29 + e20d4fd commit 3426d34
Show file tree
Hide file tree
Showing 27 changed files with 284 additions and 324 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,6 @@ jobs:
docker compose exec -T php composer require oxid-esales/apex-theme:dev-b-7.0.x --no-update
docker compose exec -T php composer require oxid-esales/oxideshop-demodata-ce:dev-b-7.0.x --no-update
docker compose exec -T php composer require twig/twig:v3.8.0 --no-update
- name: Composer install
run: |
docker compose exec -T php composer update --no-interaction
- name: Activate theme
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Trigger
on:
pull_request:
push:
schedule:
- cron: '0 6 * * 1-5'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -24,4 +26,4 @@ jobs:
secrets: inherit
with:
php: '8.1'
mysql: '8.0'
mysql: '8.0'
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [2.2.0] - 2024-??-??

### NEW
Expand Down
67 changes: 40 additions & 27 deletions src/Controller/Admin/ModuleConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,28 +183,21 @@ public function transferApplePayPaymentProcessingData(): void
}
}

/**
* @throws GuzzleException
*/
public function getApplePayPaymentProcessingKeyExists(): bool
{
$keyExists = false;
$keyId = $this->moduleSettings->getApplePayPaymentKeyId();
if ($this->moduleSettings->getApplePayMerchantCertKey() && $keyId) {
try {
$keyExists = $this->getServiceFromContainer(ApiClient::class)
->requestApplePayPaymentKey($keyId)
->getStatusCode()
=== 200;
$response = $this->getServiceFromContainer(ApiClient::class)
->requestApplePayPaymentCert($keyId);
if (!$response) {
$this->addErrorTransmittingKey();
return false;
}
$keyExists = $response->getStatusCode() === 200;
} catch (GuzzleException $guzzleException) {
Registry::getUtilsView()->addErrorToDisplay(
oxNew(
UnzerException::class,
$this->translator->translate(
'OSCUNZER_ERROR_TRANSMITTING_APPLEPAY_PAYMENT_GET_KEY'
)
)
);
$this->addErrorTransmittingKey();
}
}
return $keyExists;
Expand All @@ -219,19 +212,15 @@ public function getApplePayPaymentProcessingCertExists(): bool
$certId = $this->moduleSettings->getApplePayPaymentCertificateId();
if ($this->moduleSettings->getApplePayMerchantCert() && $certId) {
try {
$certExists = $this->getServiceFromContainer(ApiClient::class)
->requestApplePayPaymentCert($certId)
->getStatusCode()
=== 200;
$response = $this->getServiceFromContainer(ApiClient::class)
->requestApplePayPaymentCert($certId);
if (!$response) {
$this->addErrorTransmittingCertificate();
return false;
}
$certExists = $response->getStatusCode() === 200;
} catch (GuzzleException $guzzleException) {
Registry::getUtilsView()->addErrorToDisplay(
oxNew(
UnzerException::class,
$this->translator->translate(
'OSCUNZER_ERROR_TRANSMITTING_APPLEPAY_PAYMENT_GET_CERT'
)
)
);
$this->addErrorTransmittingCertificate();
}
}
return $certExists;
Expand Down Expand Up @@ -286,4 +275,28 @@ public function saveConfVars()
$this->registerWebhooks();
}
}

private function addErrorTransmittingCertificate(): void
{
Registry::getUtilsView()->addErrorToDisplay(
oxNew(
UnzerException::class,
$this->translator->translate(
'OSCUNZER_ERROR_TRANSMITTING_APPLEPAY_PAYMENT_GET_CERT'
)
)
);
}

private function addErrorTransmittingKey(): void
{
Registry::getUtilsView()->addErrorToDisplay(
oxNew(
UnzerException::class,
$this->translator->translate(
'OSCUNZER_ERROR_TRANSMITTING_APPLEPAY_PAYMENT_GET_KEY'
)
)
);
}
}
34 changes: 17 additions & 17 deletions tests/Codeception/Acceptance/AlipayCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class AlipayCest extends BaseCest
/**
* @return string
*/
protected function _getOXID(): array
protected function getOXID(): array
{
return ['oscunzer_alipay'];
}
Expand All @@ -34,28 +34,28 @@ protected function _getOXID(): array
* @param AcceptanceTester $I
* @group AlipayPaymentTest
*/
private function _prepareAlipayTest(AcceptanceTester $I)
private function prepareAlipayTest(AcceptanceTester $I)
{
$this->_initializeTest();
$this->_choosePayment($this->alipayPaymentLabel);
$this->_submitOrder();
$this->initializeTest();
$this->choosePayment($this->alipayPaymentLabel);
$this->submitOrder();
}

/**
* @param AcceptanceTester $I
* @group AlipayPaymentTest
*/
private function _checkAlipayPayment(int $methodNumber)
private function checkAlipayPayment(int $methodNumber)
{
$price = str_replace(',', '.', $this->_getPrice());
$price = str_replace(',', '.', $this->getPrice());
$alipayClientData = Fixtures::get('alipay_client');
$alipayPage = new LocalPaymentMethodsSimulatorPage($this->_getAcceptance());
$alipayPage = new LocalPaymentMethodsSimulatorPage($this->getAcceptance());

$alipayPage->login($alipayClientData['username'], $alipayClientData['password'], $price);
$alipayPage->choosePaymentMethod($methodNumber);
$alipayPage->paymentSuccessful($price);

$this->_checkSuccessfulPayment();
$this->checkSuccessfulPayment();
}

/**
Expand All @@ -65,8 +65,8 @@ private function _checkAlipayPayment(int $methodNumber)
public function checkWalletBalancePaymentWorks(AcceptanceTester $I)
{
$I->wantToTest('Test Alipay Wallet Balance payment works');
$this->_prepareAlipayTest($I);
$this->_checkAlipayPayment(1);
$this->prepareAlipayTest($I);
$this->checkAlipayPayment(1);
}

/**
Expand All @@ -76,8 +76,8 @@ public function checkWalletBalancePaymentWorks(AcceptanceTester $I)
public function checkSomeLPMPaymentWorks(AcceptanceTester $I)
{
$I->wantToTest('Test Alipay Some LPM payment works');
$this->_prepareAlipayTest($I);
$this->_checkAlipayPayment(2);
$this->prepareAlipayTest($I);
$this->checkAlipayPayment(2);
}

/**
Expand All @@ -87,8 +87,8 @@ public function checkSomeLPMPaymentWorks(AcceptanceTester $I)
public function checkAnotherLPMPaymentWorks(AcceptanceTester $I)
{
$I->wantToTest('Test Alipay Another LPM Alipay payment works');
$this->_prepareAlipayTest($I);
$this->_checkAlipayPayment(3);
$this->prepareAlipayTest($I);
$this->checkAlipayPayment(3);
}

/**
Expand All @@ -98,7 +98,7 @@ public function checkAnotherLPMPaymentWorks(AcceptanceTester $I)
public function checkOneMoreLPMPaymentWorks(AcceptanceTester $I)
{
$I->wantToTest('Test Alipay One more LPM Alipay payment works');
$this->_prepareAlipayTest($I);
$this->_checkAlipayPayment(4);
$this->prepareAlipayTest($I);
$this->checkAlipayPayment(4);
}
}
60 changes: 30 additions & 30 deletions tests/Codeception/Acceptance/BancontactCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function _after(AcceptanceTester $I): void
);
}

protected function _getOXID(): array
protected function getOXID(): array
{
return ['oscunzer_bancontact'];
}
Expand All @@ -58,43 +58,43 @@ protected function _getOXID(): array
* @param AcceptanceTester $I
* @return void
*/
private function _prepareBancontactTest(AcceptanceTester $I)
private function prepareBancontactTest(AcceptanceTester $I)
{
$this->_initializeTest();
$this->initializeTest();

$this->_choosePayment($this->bancontactLabel);
$this->_submitOrder();
$this->choosePayment($this->bancontactLabel);
$this->submitOrder();
}

/**
* @param string $name Fixtures name
* @return void
*/
private function _submitBancontactPayment(string $name)
private function submitBancontactPayment(string $name)
{
$price = str_replace(',', '.', $this->_getPrice());
$price = str_replace(',', '.', $this->getPrice());
$fixtures = Fixtures::get($name);

$this->_getAcceptance()->waitForText($price);
$this->_getAcceptance()->waitForElement($this->cardNumberInput);
$this->_getAcceptance()->fillField($this->cardNumberInput, $fixtures['cardnumber']);
$this->_getAcceptance()->selectOption($this->monthExpiredSelect, 12);
$this->_getAcceptance()->selectOption($this->yearExpiredSelect, date('Y'));
$this->_getAcceptance()->fillField($this->cvvCodeInput, $fixtures['CVC']);
$this->_getAcceptance()->click($this->continueButton);

$this->_getAcceptance()->waitForPageLoad();
$this->_getAcceptance()->waitForText($price);
$this->_getAcceptance()->waitForElement($this->continueButton);
$this->_getAcceptance()->click($this->continueButton);
$this->getAcceptance()->waitForText($price);
$this->getAcceptance()->waitForElement($this->cardNumberInput);
$this->getAcceptance()->fillField($this->cardNumberInput, $fixtures['cardnumber']);
$this->getAcceptance()->selectOption($this->monthExpiredSelect, 12);
$this->getAcceptance()->selectOption($this->yearExpiredSelect, date('Y'));
$this->getAcceptance()->fillField($this->cvvCodeInput, $fixtures['CVC']);
$this->getAcceptance()->click($this->continueButton);

$this->getAcceptance()->waitForPageLoad();
$this->getAcceptance()->waitForText($price);
$this->getAcceptance()->waitForElement($this->continueButton);
$this->getAcceptance()->click($this->continueButton);
}

/**
* @return void
*/
private function _checkBancontactPayment()
private function checkBancontactPayment()
{
$this->_checkSuccessfulPayment();
$this->checkSuccessfulPayment();
}

/**
Expand All @@ -104,9 +104,9 @@ private function _checkBancontactPayment()
public function checkMastercardPaymentWorks(AcceptanceTester $I)
{
$I->wantToTest('Test Bancontact Mastercard payment works');
$this->_prepareBancontactTest($I);
$this->_submitBancontactPayment('mastercard_payment');
$this->_checkBancontactPayment();
$this->prepareBancontactTest($I);
$this->submitBancontactPayment('mastercard_payment');
$this->checkBancontactPayment();
}

/**
Expand All @@ -116,9 +116,9 @@ public function checkMastercardPaymentWorks(AcceptanceTester $I)
public function checkVisaPaymentWorks(AcceptanceTester $I)
{
$I->wantToTest('Test Bancontact Visa payment works');
$this->_prepareBancontactTest($I);
$this->_submitBancontactPayment('visa_payment');
$this->_checkBancontactPayment();
$this->prepareBancontactTest($I);
$this->submitBancontactPayment('visa_payment');
$this->checkBancontactPayment();
}

/**
Expand All @@ -128,8 +128,8 @@ public function checkVisaPaymentWorks(AcceptanceTester $I)
public function checkMaestroPaymentWorks(AcceptanceTester $I)
{
$I->wantToTest('Test Bancontact Maestro payment works');
$this->_prepareBancontactTest($I);
$this->_submitBancontactPayment('maestro_payment');
$this->_checkBancontactPayment();
$this->prepareBancontactTest($I);
$this->submitBancontactPayment('maestro_payment');
$this->checkBancontactPayment();
}
}
Loading

0 comments on commit 3426d34

Please sign in to comment.