Skip to content

Commit

Permalink
To reset
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisGarding committed Jun 26, 2023
1 parent 24ec54e commit 76b43da
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use SwagPaymentPayPalUnified\Components\Services\ThreeDSecureResultChecker\Exception\ThreeDSecureAuthorizationRejectedException;
use SwagPaymentPayPalUnified\Components\Services\ThreeDSecureResultChecker\Exception\ThreeDSecureCardHasNoAuthorization;
use SwagPaymentPayPalUnified\Components\Services\ThreeDSecureResultChecker\Exception\ThreeDSecureExceptionDescription;
use SwagPaymentPayPalUnified\PayPalBundle\Components\SettingsServiceInterface;
use SwagPaymentPayPalUnified\PayPalBundle\Components\SettingsTable;
use SwagPaymentPayPalUnified\PayPalBundle\V2\Api\Order;
use SwagPaymentPayPalUnified\PayPalBundle\V2\Api\Order\PaymentSource;
use SwagPaymentPayPalUnified\PayPalBundle\V2\Api\Order\PaymentSource\Card;
Expand All @@ -22,6 +24,13 @@

class ThreeDSecureResultChecker
{
private SettingsServiceInterface $settingsService;

public function __construct(SettingsServiceInterface $settingsService)
{
$this->settingsService = $settingsService;
}

/**
* List of responses: https://developer.paypal.com/docs/checkout/advanced/customize/3d-secure/response-parameters/
*
Expand Down Expand Up @@ -149,7 +158,20 @@ private function getStatus(Order $payPalOrder)
$threeDSecure = $this->get3DSecure($payPalOrder);

if (!$threeDSecure instanceof ThreeDSecure) {
throw new ThreeDSecureCardHasNoAuthorization(ThreeDSecureExceptionDescription::STATUS_CODE_NO_3DSECURE);
$withAuthenticationSystemOnly = $this->settingsService->get(
SettingsServiceInterface::SETTING_ACDC_WITH_AUTHENTICATION_SYSTEM_ONLY,
SettingsTable::ADVANCED_CREDIT_DEBIT_CARD
);

if ($withAuthenticationSystemOnly) {
throw new ThreeDSecureCardHasNoAuthorization(ThreeDSecureExceptionDescription::STATUS_CODE_NO_3DSECURE);
}

return new ThreeDSecureResultStatus(
ThreeDSecure::ENROLLMENT_STATUS_B,
'',
AuthenticationResult::LIABILITY_SHIFT_NO
);
}

return new ThreeDSecureResultStatus(
Expand Down
2 changes: 2 additions & 0 deletions PayPalBundle/Components/SettingsServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ interface SettingsServiceInterface
const SETTING_PUI_CUSTOMER_SERVICE_INSTRUCTIONS = 'customer_service_instructions';
const SETTING_PUI_SHOW_RATEPAY_HINT = 'show_rate_pay_hint_in_mail';

const SETTING_ACDC_WITH_AUTHENTICATION_SYSTEM_ONLY = 'with_authentication_system_only';

/**
* Returns the whole settings model
*
Expand Down
2 changes: 1 addition & 1 deletion Resources/services/components.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<service id="paypal_unified.three_d_secure_result_checker"
class="SwagPaymentPayPalUnified\Components\Services\ThreeDSecureResultChecker\ThreeDSecureResultChecker"
public="true">
<argument type="service" id="paypal_unified.logger_service"/>
<argument type="service" id="paypal_unified.settings_service"/>
</service>

<service id="paypal_unified.transaction_history_builder_service"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ fieldset/activation/activate = "Activate for this shop"
fieldset/activation/activate/help = "Enable this option to activate PayPal Advanced Credit Debit Card for this shop."
onboardingPendingMessage = "Your account is currently not eligible for accepting payments using Advanced Credit Debit Card."
button/capability/test = "Capability test"
fieldset/activation/withAuthenticationSystemOnly = "With authentication system only"
fieldset/activation/withAuthenticationSystemOnly/help = "With authentication system only"

[de_DE]
new/title = "Advanced Credit Debit Card Integration"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ Ext.define('Shopware.apps.PaypalUnifiedSettings.view.tabs.AdvancedCreditDebitCar
capabilityTestButtonText: '{s name="button/capability/test"}Capability test{/s}',
hasLimitsMessage: '{s name="capability/hasLimits/message/acdc"}Please go to your <a href="https://www.paypal.com/businessmanage/limits/liftlimits" target="_blank">PayPal Account</a> and clarify which company documents still need to be submitted in order to use credit/debit card payment permanent.{/s}',
},

createActivationFieldsetItems: function() {
var me = this,
items = this.callParent(arguments),
fieldConfig = {
name: 'with_authentication_system_only',
fieldLabel: me.snippets.activationFieldset.checkboxFieldLabel,
boxLabel: me.snippets.activationFieldset.checkboxLabel,
inputValue: true,
uncheckedValue: false
};

this.activationField = Ext.create('Ext.form.field.Checkbox', fieldConfig);

items.push();

return items;
},


});
// {/block}

Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@

this.opts.hostedFieldsError = this.validateForm(hostedFields);

// TODO: HERE
if (!Object.prototype.hasOwnProperty.call(this.opts.cardHolderData, 'contingencies')) {
this.opts.cardHolderData.cardholderName = $('#card-holder-name').val();
this.opts.cardHolderData.billingAddress.postalCode = $('#card-billing-address-zip').val();
Expand Down
11 changes: 6 additions & 5 deletions Setup/Assets/tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ CREATE TABLE IF NOT EXISTS swag_payment_paypal_unified_settings_pay_upon_invoice

CREATE TABLE IF NOT EXISTS swag_payment_paypal_unified_settings_advanced_credit_debit_card
(
`id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`shop_id` INT(11) NOT NULL,
`onboarding_completed` TINYINT(1) NOT NULL,
`sandbox_onboarding_completed` TINYINT(1) NOT NULL,
`active` TINYINT(1) NOT NULL,
`id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`shop_id` INT(11) NOT NULL,
`onboarding_completed` TINYINT(1) NOT NULL,
`sandbox_onboarding_completed` TINYINT(1) NOT NULL,
`active` TINYINT(1) NOT NULL,
`with_authentication_system_only` TINYINT(1) NOT NULL,
CONSTRAINT unique_shop_id UNIQUE (`shop_id`)
)
ENGINE = InnoDB
Expand Down
8 changes: 8 additions & 0 deletions Setup/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use SwagPaymentPayPalUnified\Setup\Versions\UpdateTo600;
use SwagPaymentPayPalUnified\Setup\Versions\UpdateTo602;
use SwagPaymentPayPalUnified\Setup\Versions\UpdateTo604;
use SwagPaymentPayPalUnified\Setup\Versions\UpdateTo609;

class Updater
{
Expand Down Expand Up @@ -234,6 +235,13 @@ public function update($oldVersion)
$this->translation
))->update();
}

if (\version_compare($oldVersion, '6.0.9', '<')) {
(new UpdateTo609(
$this->connection,
$this->columnService,
))->update();
}
}

/**
Expand Down
52 changes: 52 additions & 0 deletions Setup/Versions/UpdateTo609.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* (c) shopware AG <info@shopware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace SwagPaymentPayPalUnified\Setup\Versions;

use Doctrine\DBAL\Connection;
use SwagPaymentPayPalUnified\Setup\ColumnService;

class UpdateTo609
{
/**
* @var Connection
*/
private $connection;

/**
* @var ColumnService
*/
private $columnService;

public function __construct(Connection $connection, ColumnService $columnService)
{
$this->connection = $connection;
$this->columnService = $columnService;
}

/**
* @return void
*/
public function update()
{
$this->addAdvancedCreditDebitCardSettingWithAuthenticationSystemOnly();
}

/**
* @return void
*/
private function addAdvancedCreditDebitCardSettingWithAuthenticationSystemOnly()
{
if (!$this->columnService->checkIfColumnExist('swag_payment_paypal_unified_settings_advanced_credit_debit_card', 'with_authentication_system_only')) {
$this->connection->executeQuery(
'ALTER TABLE `swag_payment_paypal_unified_settings_advanced_credit_debit_card`
ADD `with_authentication_system_only` TINYINT(1) NOT NULL default 1;'
);
}
}
}
3 changes: 3 additions & 0 deletions Subscriber/AdvancedCreditDebitCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public function onCheckout(Enlight_Controller_ActionEventArgs $args)
'paypalUnifiedEcButtonStyleSize' => $generalSettings->getButtonStyleSize(),
];

// TODO: HERE
if (!isset($cardHolderData['contingencies'])) {
$viewData['extendedFields'] = true;
}
Expand Down Expand Up @@ -176,6 +177,8 @@ private function createCardHolderData($userData)
],
];

// TODO: Herausfinden ob contingencies gesetzt werden müssen. Auch für nicht EU länder
// TODO: $cardHolderData['contingencies'] = ['SCA_WHEN_REQUIRED'];
if (!$this->euStatesService->isEUCountry($additional['country']['countryiso'])) {
return $cardHolderData;
}
Expand Down

0 comments on commit 76b43da

Please sign in to comment.