-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix manual capture issues. #211
base: canary
Are you sure you want to change the base?
Changes from all commits
e6bf7ae
6a68d4c
f80ccae
5ad89ec
2bd2583
4e6ccf2
633c955
8f1e591
81be6ca
5bbe17d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -433,13 +433,12 @@ function stripePaymentIntentEventToPartialTransactionEventReportMutationVariable | |||
switch (stripeEvent.type) { | ||||
// handling these is required | ||||
case "payment_intent.succeeded": { | ||||
if (manualCapture) break; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
In Stripe docs: the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @witoszekdev :) If you would like to omit this line, I believe we should change the response action of TransactionChargeRequested event in salor, maybe allowing CHARGE_REQUEST as result response? Otherwise a transaction event with same pspReference and action is going to be fired, which would cause an error. As it is working right now, the following happens: As a race-condition the "payment_intent_succeded" event form stripe is fired, which then duplicates the "CHARGE_SUCCESS" transaction event. I believe the best approach, would be to change the logic in saleor to only allow CHARGE_FAILED or CHARGE_REQUESTED results types and then let the app handle everything through webhooks. This would streamline the process with automatic_capture. But I am not really a python dev, so I can't really change the logic inside saleor... :/ Let me know what you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not even sure that the CHARGE_REQUESTED would resolve the case, as the race condition still exists between wether the payment_intent.suceeded or saleor adds the transaction event first :) |
||||
const amount = getSaleorAmountFromStripeAmount({ | ||||
amount: manualCapture ? paymentIntent.amount_capturable : paymentIntent.amount_received, | ||||
currency: paymentIntent.currency, | ||||
}); | ||||
const type = manualCapture | ||||
? TransactionEventTypeEnum.AuthorizationSuccess | ||||
: TransactionEventTypeEnum.ChargeSuccess; | ||||
const type = TransactionEventTypeEnum.ChargeSuccess; | ||||
|
||||
return { amount, type, externalUrl, pspReference, message }; | ||||
} | ||||
|
@@ -503,7 +502,9 @@ function stripePaymentIntentEventToPartialTransactionEventReportMutationVariable | |||
amount: paymentIntent.amount, | ||||
currency: paymentIntent.currency, | ||||
}); | ||||
const type = TransactionEventTypeEnum.AuthorizationAdjustment; | ||||
const type = manualCapture | ||||
? TransactionEventTypeEnum.AuthorizationSuccess | ||||
: TransactionEventTypeEnum.AuthorizationAdjustment; | ||||
Comment on lines
+505
to
+507
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is a bit tricky - if this is the first Authorization, then
|
||||
return { amount, type, externalUrl, pspReference, message }; | ||||
} | ||||
|
||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not remove this file :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My fault :)