Skip to content

Commit

Permalink
PAA-238 Fix by Magento code standard
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-zhang-awx committed May 9, 2024
1 parent b5ffda8 commit 46d501a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Helper/AvailablePaymentMethodsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public function __construct(
*/
public function canInitialize(): bool
{
return !is_null($this->configuration->getApiKey()) &&
!is_null($this->configuration->getClientId());
return !$this->configuration->getApiKey() === null &&
!$this->configuration->getClientId() === null;
}

/**
Expand Down
11 changes: 6 additions & 5 deletions Model/Adminhtml/Notifications/ExpressDisabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ class ExpressDisabled implements MessageInterface
*
* @param Configuration $configuration
*/
public function __construct(
Configuration $configuration
){
public function __construct(Configuration $configuration)
{
$this->configuration = $configuration;
$this->expressDisabled();
}
Expand Down Expand Up @@ -64,9 +63,11 @@ public function getSeverity(): int
/**
* @return void
*/
private function expressDisabled(): void {
private function expressDisabled(): void
{
if (!$this->configuration->isCardActive()) {
$this->displayedText = __('Airwallex Express Checkout is also disabled. To use Express Checkout, you must first enable Credit Card payments.');
$this->displayedText = __('Airwallex Express Checkout is also disabled.'
. ' To use Express Checkout, you must first enable Credit Card payments.');
}
}
}
3 changes: 1 addition & 2 deletions Model/Methods/RedirectMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class RedirectMethod extends AbstractMethod
public const KAKAO_CODE = 'airwallex_payments_kakaopay';
public const TOUCH_N_GO_CODE = 'airwallex_payments_tng';
public const WECHAT_CODE = 'airwallex_payments_wechatpay';



/**
* @param InfoInterface $payment
* @param float $amount
Expand Down
3 changes: 1 addition & 2 deletions Model/PaymentIntents.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public function __construct(
CacheInterface $cache,
UrlInterface $urlInterface,
Logger $logger
)
{
) {
$this->paymentIntentsCancel = $paymentIntentsCancel;
$this->paymentIntentsCreate = $paymentIntentsCreate;
$this->checkoutSession = $checkoutSession;
Expand Down
18 changes: 10 additions & 8 deletions Model/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ public function addToCart(): string
}
}

private function error($message) {
private function error($message)
{
return json_encode([
'type' => 'error',
'message' => $message
Expand Down Expand Up @@ -569,13 +570,13 @@ public function postAddress(): string
public function validateMerchant()
{
$validationUrl = $this->request->getParam('validationUrl');
if ( empty( $validationUrl ) ) {
throw new Exception( 'Validation URL is empty.' );
if (empty($validationUrl)) {
return $this->error('Validation URL is empty.');
}

$initiativeContext = $this->request->getParam('origin');
if ( empty( $initiativeContext ) ) {
throw new Exception( 'Initiative Context is empty.' );
if (empty($initiativeContext)) {
return $this->error('Initiative Context is empty.');
}

return $this->validateMerchant->setInitiativeParams([
Expand All @@ -594,11 +595,11 @@ public function validateAddresses()
{
$quote = $this->checkoutHelper->getQuote();
$errors = $this->shippingAddressValidationRule->validate($quote);
if ($errors and $errors[0]->getErrors()) {
if ($errors && $errors[0]->getErrors()) {
return $this->error(__(implode(' ', $errors[0]->getErrors())));
}
$errors = $this->billingAddressValidationRule->validate($quote);
if ($errors and $errors[0]->getErrors()) {
if ($errors && $errors[0]->getErrors()) {
return $this->error(__(implode(' ', $errors[0]->getErrors())));
}
return '{"type": "success"}';
Expand Down Expand Up @@ -633,7 +634,8 @@ protected function checkIntent($id)
$respArr = json_decode($resp, true);
$okStatus = [$this->intentGet::INTENT_STATUS_SUCCESS, $this->intentGet::INTENT_STATUS_REQUIRES_CAPTURE];
if (!in_array($respArr['status'], $okStatus, true)) {
throw new Exception(__('Something went wrong while processing your request. Please try again later.'));
$msg = 'Something went wrong while processing your request. Please try again later.';
throw new GuzzleException(__($msg));
}
}
}
7 changes: 3 additions & 4 deletions view/frontend/templates/express.phtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<div data-bind="scope: 'airwallex-express'">
<?php
require __DIR__ . '/../web/template/payment/express-checkout.html';
?>
<!-- ko template: getTemplate() --><!-- /ko -->
</div>
<script type="text/x-magento-init">
{
Expand All @@ -10,7 +8,8 @@ require __DIR__ . '/../web/template/payment/express-checkout.html';
"components": {
"airwallex-express": {
"component": "Airwallex_Payments/js/view/payment/method-renderer/express-checkout",
"from": "<?=$block->getData('from')?>"
"from": "<?= $block->escapeHtml($block->getData('from')) ?>",
"template": "Airwallex_Payments/payment/express-checkout"
}
}
}
Expand Down

0 comments on commit 46d501a

Please sign in to comment.