-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Add Stripe Webhook logic to retrieve payment intent events, and add to Payment entity valid status and description #57
Add Stripe Webhook logic to retrieve payment intent events, and add to Payment entity valid status and description #57
Conversation
…o Payment entity valid status and description
src/main/java/com/zufar/onlinestore/payment/processor/PaymentProcessor.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/config/StripeConfiguration.java
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/config/StripeConfiguration.java
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/processor/PaymentEventProcessor.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/processor/PaymentEventProcessor.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/impl/PaymentEventServiceImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/impl/PaymentEventServiceImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/impl/PaymentEventServiceImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/processor/PaymentEventProcessor.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/processor/PaymentProcessor.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/processor/PaymentProcessor.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/impl/PaymentEventServiceImpl.java
Outdated
Show resolved
Hide resolved
# Conflicts: # src/main/java/com/zufar/onlinestore/payment/PaymentApi.java # src/main/java/com/zufar/onlinestore/payment/config/StripeConfiguration.java # src/main/java/com/zufar/onlinestore/payment/dto/PaymentDetailsDto.java # src/main/java/com/zufar/onlinestore/payment/dto/PaymentWithTokenDetailsDto.java # src/main/java/com/zufar/onlinestore/payment/processor/PaymentProcessor.java
src/main/java/com/zufar/onlinestore/payment/service/PaymentGetter.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/PaymentCreator.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/PaymentEventParser.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/PaymentEventParser.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/controller/PaymentController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/controller/PaymentController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/controller/PaymentController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/controller/PaymentController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/dto/CreatePaymentMethodDto.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/PaymentIntentCreator.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/PaymentMethodGetter.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/PaymentMethodGetter.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/PaymentGetter.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/PaymentMethodGetter.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/api/PaymentApi.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/api/impl/PaymentApiImpl.java
Outdated
Show resolved
Hide resolved
@@ -25,15 +30,38 @@ public class Payment { | |||
@Column(name = "payment_id") | |||
private Long paymentId; | |||
|
|||
@Column(nullable = false, unique = true, name = "payment_intent_id") |
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.
fix it please
src/main/java/com/zufar/onlinestore/payment/repository/PaymentRepository.java
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/PaymentEventProcessor.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/PaymentFailedScenarioHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/PaymentIntentCreator.java
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/PaymentMethodCreator.java
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/PaymentRetriever.java
Show resolved
Hide resolved
src/main/java/com/zufar/onlinestore/payment/service/PaymentSuccessfulScenarioHandler.java
Outdated
Show resolved
Hide resolved
* @param stripeSignatureHeader this param it is a string describing of the stripe signature, which provide safe work with Stripe API webhooks mechanism | ||
* @throws SignatureVerificationException this exception throw then stripe signature verification problem was occurred | ||
* */ | ||
void paymentEventProcess(final String paymentIntentPayload, final String stripeSignatureHeader) throws SignatureVerificationException; |
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.
processPaymentEvent *
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.
Done
|
||
@PostConstruct | ||
private void init() { | ||
Stripe.apiKey = secretKey; | ||
} | ||
|
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.
probably remove extra space here
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.
done
public ResponseEntity<Void> paymentEventsProcess( | ||
@RequestBody @Valid @NotEmpty String paymentIntentPayload, | ||
@RequestHeader("Stripe-Signature") @Valid @NotEmpty String stripeSignatureHeader) throws SignatureVerificationException { | ||
if (Objects.isNull(paymentIntentPayload) || Objects.isNull(stripeSignatureHeader)) { |
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.
constrained with @notempty must be not null, and its size/length must be greater than zero.
I dont see so much sense to put additional if checks for it
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.
@@ -25,15 +30,38 @@ public class Payment { | |||
@Column(name = "payment_id") | |||
private Long paymentId; | |||
|
|||
@Column(nullable = false, unique = true, name = "payment_intent_id") |
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.
+
Payment updatedPayment = paymentRepository.updateStatusAndDescriptionInPayment( | ||
paymentIntent.getId(), status, status.getDescription()); | ||
log.info("Handle payment scenario method: finish of handling payment intent: {} by failed scenario.", paymentIntent); | ||
log.debug("Handle payment scenario method: payment data was updated: {}.", updatedPayment); |
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.
please remove
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.
done
paymentIntent.getId(), status, status.getDescription()); | ||
log.info("Handle payment scenario method: finish of handling payment intent: {} by successful scenario.", paymentIntent); | ||
log.debug("Handle payment scenario method: payment data was updated: {}.", updatedPayment); | ||
} |
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.
please remove
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.
done
…nt-handling-logic-was-added
Changes:
Test: At the moment, we don't have stripe logic on the frontend side yet. You have to generate events yourself, using Stripe SLI. And check how events are caught, and how, based on this, this or that logic works, which is intended to be executed in response to an event. The application rises, the endpoint has been tested. I will try to describe in detail how to test this logic in the Trello ticket.