Skip to content

Commit

Permalink
Merge branch 'main' into ECP-9352
Browse files Browse the repository at this point in the history
  • Loading branch information
candemiralp authored Oct 8, 2024
2 parents 8b16ac0 + e3af5ed commit c4f4e00
Show file tree
Hide file tree
Showing 18 changed files with 223 additions and 7 deletions.
5 changes: 5 additions & 0 deletions Gateway/Http/Client/TransactionPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ public function placeRequest(TransferInterface $transferObject): array
$this->adyenHelper->logResponse($responseData);
} catch (AdyenException $e) {
$this->adyenHelper->logAdyenException($e);

$responseObj['error'] = $e->getMessage();
$responseObj['errorCode'] = $e->getAdyenErrorCode();

$responseCollection[] = $responseObj;
}

return $responseCollection;
Expand Down
9 changes: 6 additions & 3 deletions Gateway/Validator/CheckoutResponseValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,17 @@ public function validate(array $validationSubject): ResultInterface
// Extract all the payment responses
$responseCollection = $validationSubject['response'];
unset($validationSubject['response']);

// hasOnlyGiftCards is needed later but cannot be processed as a response
unset($responseCollection['hasOnlyGiftCards']);

// Assign the remaining items to $commandSubject
$commandSubject = $validationSubject;

if (empty($responseCollection)) {
throw new ValidatorException(__("No responses were provided"));
}

// hasOnlyGiftCards is needed later but cannot be processed as a response
unset($responseCollection['hasOnlyGiftCards']);
foreach ($responseCollection as $thisResponse) {
$responseSubject = array_merge($commandSubject, ['response' => $thisResponse]);
$this->validateResponse($responseSubject);
Expand All @@ -90,11 +92,12 @@ private function validateResponse($responseSubject): void

$payment->setAdditionalInformation('3dActive', false);

// validate result
// Handle empty result for unexpected cases
if (empty($response['resultCode'])) {
$this->handleEmptyResultCode($response);
}

// Handle the `/payments` response
$this->validateResult($response, $payment);
}

Expand Down
18 changes: 18 additions & 0 deletions Test/Unit/Gateway/Http/Client/TransactionPaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Adyen\Payment\Test\Unit\Gateway\Http\Client;

use Adyen\AdyenException;
use Adyen\Model\Checkout\ApplicationInfo;
use Adyen\Model\Checkout\PaymentRequest;
use Adyen\Model\Checkout\PaymentResponse as CheckoutPaymentResponse;
Expand Down Expand Up @@ -87,6 +88,23 @@ public function testPlaceRequestWithResultCode()
$this->assertEquals($requestBody, $result);
}

public function testPlaceRequestWithoutResultCode()
{
$transferObjectMock = $this->createMock(TransferInterface::class);

$requestBody = ['amount' => ['value' => 1000]];
$transferObjectMock->method('getBody')->willReturn($requestBody);
$transferObjectMock->method('getClientConfig')->willReturn(['storeId' => 1]);

$clientMock = $this->createMock(PaymentsApi::class);
$clientMock->method('payments')->willThrowException(new AdyenException());

$this->adyenHelperMock->method('initializePaymentsApi')->willReturn($clientMock);

$response = $this->transactionPayment->placeRequest($transferObjectMock);
$this->assertArrayHasKey('errorCode', $response[0]);
}

public function testPlaceRequestGeneratesIdempotencyKey()
{
$requestBody = ['reference' => 'ABC12345', 'amount' => ['value' => 100], 'applicationInfo' => $this->applicationInfoMock];
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.8.1
9.9.1
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module",
"version": "9.8.1",
"version": "9.9.1",
"license": "MIT",
"repositories": [
{
Expand Down
66 changes: 66 additions & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2207,6 +2207,72 @@
<title>Stored DANA</title>
<model>AdyenPaymentDanaVaultFacade</model>
</adyen_dana_vault>
<adyen_kcp_naverpay>
<active>0</active>
<model>AdyenPaymentKcpNaverpayFacade</model>
<title>NaverPay</title>
<allowspecific>0</allowspecific>
<sort_order>0</sort_order>
<payment_action>authorize</payment_action>
<can_initialize>1</can_initialize>
<can_use_checkout>1</can_use_checkout>
<can_capture>1</can_capture>
<can_capture_partial>0</can_capture_partial>
<can_use_internal>0</can_use_internal>
<can_refund_partial_per_invoice>1</can_refund_partial_per_invoice>
<can_refund>1</can_refund>
<can_void>1</can_void>
<can_cancel>1</can_cancel>
<supports_recurring>0</supports_recurring>
<supports_manual_capture>0</supports_manual_capture>
<supports_auto_capture>1</supports_auto_capture>
<is_wallet>1</is_wallet>
<group>adyen-alternative-payment-method</group>
</adyen_kcp_naverpay>
<adyen_kcp_payco>
<active>0</active>
<model>AdyenPaymentKcpPaycoFacade</model>
<title>PayCo</title>
<allowspecific>0</allowspecific>
<sort_order>0</sort_order>
<payment_action>authorize</payment_action>
<can_initialize>1</can_initialize>
<can_use_checkout>1</can_use_checkout>
<can_capture>1</can_capture>
<can_capture_partial>0</can_capture_partial>
<can_use_internal>0</can_use_internal>
<can_refund_partial_per_invoice>1</can_refund_partial_per_invoice>
<can_refund>1</can_refund>
<can_void>1</can_void>
<can_cancel>1</can_cancel>
<supports_recurring>0</supports_recurring>
<supports_manual_capture>0</supports_manual_capture>
<supports_auto_capture>1</supports_auto_capture>
<is_wallet>1</is_wallet>
<group>adyen-alternative-payment-method</group>
</adyen_kcp_payco>
<adyen_kcp_creditcard>
<active>0</active>
<model>AdyenPaymentKcpCreditcardFacade</model>
<title>Credit Card via KCP</title>
<allowspecific>0</allowspecific>
<sort_order>0</sort_order>
<payment_action>authorize</payment_action>
<can_initialize>1</can_initialize>
<can_use_checkout>1</can_use_checkout>
<can_capture>1</can_capture>
<can_capture_partial>0</can_capture_partial>
<can_use_internal>0</can_use_internal>
<can_refund_partial_per_invoice>1</can_refund_partial_per_invoice>
<can_refund>1</can_refund>
<can_void>1</can_void>
<can_cancel>1</can_cancel>
<supports_recurring>0</supports_recurring>
<supports_manual_capture>0</supports_manual_capture>
<supports_auto_capture>1</supports_auto_capture>
<is_wallet>0</is_wallet>
<group>adyen-alternative-payment-method</group>
</adyen_kcp_creditcard>
</payment>
</default>
</config>
3 changes: 3 additions & 0 deletions etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
<column name="merchant_reference"/>
<column name="event_code"/>
</index>
<index referenceId="ADYEN_NOTIFICATION_CREATED_AT" indexType="btree">
<column name="created_at"/>
</index>
</table>
<table name="adyen_invoice" resource="default" engine="innodb" comment="Adyen Invoice">
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true" comment="Adyen Invoice Entity ID"/>
Expand Down
5 changes: 3 additions & 2 deletions etc/db_schema_whitelist.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"ADYEN_NOTIFICATION_PSPREFERENCE": true,
"ADYEN_NOTIFICATION_EVENT_CODE": true,
"ADYEN_NOTIFICATION_PSPREFERENCE_EVENT_CODE": true,
"ADYEN_NOTIFICATION_MERCHANT_REFERENCE_EVENT_CODE": true
"ADYEN_NOTIFICATION_MERCHANT_REFERENCE_EVENT_CODE": true,
"ADYEN_NOTIFICATION_CREATED_AT": true
},
"constraint": {
"PRIMARY": true
Expand Down Expand Up @@ -110,4 +111,4 @@
"PRIMARY": true
}
}
}
}
81 changes: 81 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4236,4 +4236,85 @@
<argument name="methodCode" xsi:type="string">adyen_dana_vault</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentKcpNaverpayFacade" type="Adyen\Payment\Model\Method\Adapter">
<arguments>
<argument name="code" xsi:type="string">adyen_kcp_naverpay</argument>
<argument name="formBlockType" xsi:type="string">Magento\Payment\Block\Form</argument>
<argument name="infoBlockType" xsi:type="string">Adyen\Payment\Block\Info\PaymentMethodInfo</argument>
<argument name="valueHandlerPool" xsi:type="object">AdyenPaymentKcpNaverpayValueHandlerPool</argument>
<argument name="validatorPool" xsi:type="object">AdyenPaymentValidatorPool</argument>
<argument name="commandPool" xsi:type="object">AdyenPaymentCommandPool</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentKcpNaverpayValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">
<arguments>
<argument name="handlers" xsi:type="array">
<item name="default" xsi:type="string">AdyenPaymentKcpNaverpayConfigValueHandler</item>
</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentKcpNaverpayConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler">
<arguments>
<argument name="configInterface" xsi:type="object">AdyenPaymentKcpNaverpayConfig</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentKcpNaverpayConfig" type="Magento\Payment\Gateway\Config\Config">
<arguments>
<argument name="methodCode" xsi:type="string">adyen_kcp_naverpay</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentKcpPaycoFacade" type="Adyen\Payment\Model\Method\Adapter">
<arguments>
<argument name="code" xsi:type="string">adyen_kcp_payco</argument>
<argument name="formBlockType" xsi:type="string">Magento\Payment\Block\Form</argument>
<argument name="infoBlockType" xsi:type="string">Adyen\Payment\Block\Info\PaymentMethodInfo</argument>
<argument name="valueHandlerPool" xsi:type="object">AdyenPaymentKcpPaycoValueHandlerPool</argument>
<argument name="validatorPool" xsi:type="object">AdyenPaymentValidatorPool</argument>
<argument name="commandPool" xsi:type="object">AdyenPaymentCommandPool</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentKcpPaycoValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">
<arguments>
<argument name="handlers" xsi:type="array">
<item name="default" xsi:type="string">AdyenPaymentKcpPaycoConfigValueHandler</item>
</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentKcpPaycoConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler">
<arguments>
<argument name="configInterface" xsi:type="object">AdyenPaymentKcpPaycoConfig</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentKcpPaycoConfig" type="Magento\Payment\Gateway\Config\Config">
<arguments>
<argument name="methodCode" xsi:type="string">adyen_kcp_payco</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentKcpCreditcardFacade" type="Adyen\Payment\Model\Method\Adapter">
<arguments>
<argument name="code" xsi:type="string">adyen_kcp_creditcard</argument>
<argument name="formBlockType" xsi:type="string">Magento\Payment\Block\Form</argument>
<argument name="infoBlockType" xsi:type="string">Adyen\Payment\Block\Info\PaymentMethodInfo</argument>
<argument name="valueHandlerPool" xsi:type="object">AdyenPaymentKcpCreditcardValueHandlerPool</argument>
<argument name="validatorPool" xsi:type="object">AdyenPaymentValidatorPool</argument>
<argument name="commandPool" xsi:type="object">AdyenPaymentCommandPool</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentKcpCreditcardValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">
<arguments>
<argument name="handlers" xsi:type="array">
<item name="default" xsi:type="string">AdyenPaymentKcpCreditcardConfigValueHandler</item>
</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentKcpCreditcardConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler">
<arguments>
<argument name="configInterface" xsi:type="object">AdyenPaymentKcpCreditcardConfig</argument>
</arguments>
</virtualType>
<virtualType name="AdyenPaymentKcpCreditcardConfig" type="Magento\Payment\Gateway\Config\Config">
<arguments>
<argument name="methodCode" xsi:type="string">adyen_kcp_creditcard</argument>
</arguments>
</virtualType>
</config>
9 changes: 9 additions & 0 deletions etc/events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,13 @@
<event name="payment_method_assign_data_adyen_dana">
<observer name="adyen_dana_gateway_data_assign" instance="Adyen\Payment\Observer\AdyenPaymentMethodDataAssignObserver" />
</event>
<event name="payment_method_assign_data_adyen_kcp_naverpay">
<observer name="adyen_kcp_naverpay_gateway_data_assign" instance="Adyen\Payment\Observer\AdyenPaymentMethodDataAssignObserver" />
</event>
<event name="payment_method_assign_data_adyen_kcp_payco">
<observer name="adyen_kcp_payco_gateway_data_assign" instance="Adyen\Payment\Observer\AdyenPaymentMethodDataAssignObserver" />
</event>
<event name="payment_method_assign_data_adyen_kcp_creditcard">
<observer name="adyen_kcp_creditcard_gateway_data_assign" instance="Adyen\Payment\Observer\AdyenPaymentMethodDataAssignObserver" />
</event>
</config>
3 changes: 3 additions & 0 deletions etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@
<item name="adyen_paypo" xsi:type="string">paypo</item>
<item name="adyen_upi" xsi:type="string">upi</item>
<item name="adyen_dana" xsi:type="string">dana</item>
<item name="adyen_kcp_naverpay" xsi:type="string">kcp_naverpay</item>
<item name="adyen_kcp_payco" xsi:type="string">kcp_payco</item>
<item name="adyen_kcp_creditcard" xsi:type="string">kcp_creditcard</item>
</argument>
<argument name="customMethodRenderers" xsi:type="array">
<item name="adyen_cc" xsi:type="string">Adyen_Payment/js/view/payment/method-renderer/adyen-cc-method</item>
Expand Down
3 changes: 3 additions & 0 deletions etc/graphql/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
<item name="adyen_paypo" xsi:type="object">Adyen\Payment\Model\Cart\Payment\AdditionalDataProvider\AdyenPm</item>
<item name="adyen_upi" xsi:type="object">Adyen\Payment\Model\Cart\Payment\AdditionalDataProvider\AdyenPm</item>
<item name="adyen_dana" xsi:type="object">Adyen\Payment\Model\Cart\Payment\AdditionalDataProvider\AdyenPm</item>
<item name="adyen_kcp_naverpay" xsi:type="object">Adyen\Payment\Model\Cart\Payment\AdditionalDataProvider\AdyenPm</item>
<item name="adyen_kcp_payco" xsi:type="object">Adyen\Payment\Model\Cart\Payment\AdditionalDataProvider\AdyenPm</item>
<item name="adyen_kcp_creditcard" xsi:type="object">Adyen\Payment\Model\Cart\Payment\AdditionalDataProvider\AdyenPm</item>
</argument>
</arguments>
</type>
Expand Down
9 changes: 9 additions & 0 deletions etc/payment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,14 @@
<method name="adyen_dana">
<allow_multiple_address>1</allow_multiple_address>
</method>
<method name="adyen_kcp_naverpay">
<allow_multiple_address>1</allow_multiple_address>
</method>
<method name="adyen_kcp_payco">
<allow_multiple_address>1</allow_multiple_address>
</method>
<method name="adyen_kcp_creditcard">
<allow_multiple_address>1</allow_multiple_address>
</method>
</methods>
</payment>
1 change: 1 addition & 0 deletions view/base/web/images/logos/kcp_creditcard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c4f4e00

Please sign in to comment.