Comments (5)
Hello @dimitriBouteille,
Thank you for creating this issue. Plugin does not store the state data on the DB by default, we changed that approach in the earlier versions of V8. It stores the state data temporarily via setting it by observes and consumes it on the request builders.
The reason of this removal is for supporting giftcard payments through graphql. If the payment contains two payment methods (giftcard + credit card), first giftcard is redeemed and then placeOrder
mutation is executed with credit card state data. However, if you call setPaymentMethodOnCart
and placeOrder
in a combined mutation, AdyenCcDataAssignObserver is hit twice (for each of the mutations). Since, placeOrder
mutation doesn't accept additional data, state data is empty on the second observer hit. Therefore, it tries to access to DB. DB holds giftcard state data at that moment and due to this fact observer passes the wrong state data to the request builder CheckoutDataBuilder for credit card payment.
By default, setPaymentMethodOnCart doesn't save the state data to the DB. Do you have a custom logic to save the state data? Could you please give more details about your implementation? So that we can try to investigate the potential solutions?
Best Regards,
Can
from adyen-magento2.
Hi @candemiralp
Thank you for this information, I better understand the problem.
Concerning myself, in my application I use for technical reasons a proxy that will automatically separate the mutations, so if this request:
mutation setPaymentMethodAndPlaceOrder(
$cartId: String!
$paymentMethod: PaymentMethodInput!
) {
setPaymentMethodOnCart(
input: { cart_id: $cartId, payment_method: $paymentMethod }
) {
cart {
selected_payment_method {
...CartSelectedPaymentMethodFragment
}
}
}
placeOrder(input: { cart_id: $cartId }) {
order {
order_number
}
}
}
will be executed in two queries:
mutation setPaymentMethodAndPlaceOrder(
$cartId: String!
$paymentMethod: PaymentMethodInput!
) {
setPaymentMethodOnCart(
input: { cart_id: $cartId, payment_method: $paymentMethod }
) {
cart {
selected_payment_method {
...CartSelectedPaymentMethodFragment
}
}
}
}
mutation setPaymentMethodAndPlaceOrder(
$cartId: String!
) {
placeOrder(input: { cart_id: $cartId }) {
order {
order_number
}
}
}
Unfortunately I can not do otherwise:( I see that you added the adyenSaveStateData
mutation, do you know if it can fix the problem? and thus execute the queries in this order?
- setPaymentMethodOnCart
- adyenSaveStateData
- placeOrder
from adyen-magento2.
Hello @dimitriBouteille,
Thank you for explaining the details of your use case. I don't think adyenSaveStateData
will solve your issue with its current state.
Do you insert the state data to the database via that proxy?
Best Regards,
Can
from adyen-magento2.
Hu @candemiralp
I made a plugin to save the state because in <= 9.3 the adyenSaveStateData
mutation does not exist.
/**
* @param \Adyen\Payment\Helper\StateData $subject
* @param array $stateData
* @param int $quoteId
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSetStateData(
\Adyen\Payment\Helper\StateData $subject,
array $stateData,
int $quoteId
): array {
/**
* Fix bug with graphQl
* @see https://github.com/Adyen/adyen-magento2/pull/1924
*/
try {
$stateDataObject = $this->stateDataFactory->create();
$stateDataObject->setData('state_data', json_encode($stateData));
$stateDataObject->setData('quote_id', $quoteId);
$this->stateDataResource->save($stateDataObject);
} catch (\Exception $exception) {
$this->adyenLogger->critical(
sprintf(
'Something when wrong durant save State Data: %s',
$exception->getMessage()
),
[
'cart_id' => $quoteId,
'exception' => $exception,
]
);
}
return [$stateData, $quoteId];
}
<type name="Adyen\Payment\Helper\StateData">
<plugin name="Reflet_Adyen::save_stateDate_in_db"
type="Reflet\Adyen\Plugin\Helper\StateData"/>
</type>
I see that you are already working on 9.5.0, would it be possible to prioritize this ticket ? so that I can make the updates ❤️
from adyen-magento2.
Hello @dimitriBouteille,
Thank you for explaining the details of your implementation. Now, the whole picture is clear for us.
As I mentioned earlier, we've decided not to store the stated data on the database since it contains card information (even though it's encrypted). But, while implementing new gift card flow, that became a blocker for us since one quote might have multiple state data (credit card + gift card). The main purpose of implementing adyenSaveStateData
mutation is inserting the gift card state data to the DB. While designing headless gift card flow, we assumed gift card state data could be inserted via adyenSaveStateData
mutation and credit card state data could be inserted as a part of setPaymentMethodOnCart
mutation withouth persisting it to the database.
Your implementation shows a valid use case of storing the state data for all of the payment methods besides gift cards. So, I will create an internal case to discuss and fix this implementation. Unfortunately, it's not possible to make it part of 9.5.0 due to time concern. But, we are prioritising this task.
Best Regards,
Can
from adyen-magento2.
Related Issues (20)
- [ECP-9194] Adyen 9.2.0 conflicting with Avalara Avatax - Payment methods not loaded - adyen_payment_methods_response empty HOT 2
- List incompatible changes when upgrading to 9.x HOT 1
- [ECP-9196] Allow shopperReference to be linked to GuestCustomer HOT 6
- Improvement Suggestion: Add index to merchant_reference column in adyen_payment_response HOT 1
- UNIONPAY, WECHAT, ALIPAY After click "Back To Merchant" without complete payment land in thankyou page HOT 1
- [ECP-9098] PayPal not working when T&C's are not checked HOT 2
- [ECP-9223] Apple Pay Certificate can't be downloaded HOT 1
- Swish orders wrongly updated to the Pending status from Canceled or Processing HOT 2
- Parse error: syntax error, unexpected ')', expecting variable (T_VARIABLE) in /var/www/html/magento2422/app/code/Adyen/Payment/Helper/Webhook/WebhookHandlerFactory.php on line 62 HOT 3
- [ECP-9229] Undefined array key "order" in Plugin/GraphQlPlaceOrderAddCartId.php on line 63 HOT 2
- [ECP-9228] js errors on luma checkout when no payment methods are returned for adyen_payment_methods_response HOT 1
- [ECP-9246] Unable to create Credit Memos for orders containing deleted products. HOT 5
- Implement captureDelayHours in SFCC cartridge HOT 1
- Could not create admin order using credit card payment method. HOT 2
- Unable to get payment creation date HOT 2
- Firecheckout: Paymethods not rendering when using one step checkout HOT 5
- [ECP-9281] Multiple Shipment failed through API incase of the partial fulfillment with multi captures enabled HOT 2
- [ECP-9289] Gerar Link pay-by-link com opção parcelar o pagamento HOT 1
- [ECP-9290] Undocumented breaking change in 9.6.0 HOT 2
- [ECP-9339]Loader freezes and payment methods are not loading HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adyen-magento2.