use of alfio.model.transaction.webhook.StripeChargeTransactionWebhookPayload in project alf.io by alfio-event.
the class StripeWebhookPaymentManager method parseTransactionPayload.
@Override
public Optional<TransactionWebhookPayload> parseTransactionPayload(String body, String signature, Map<String, String> additionalInfo, PaymentContext paymentContext) {
try {
var stripeEvent = Webhook.constructEvent(body, signature, getWebhookSignatureKey(paymentContext.getConfigurationLevel()));
String eventType = stripeEvent.getType();
if (eventType.startsWith("charge.")) {
return deserializeObject(stripeEvent).map(obj -> new StripeChargeTransactionWebhookPayload(eventType, (Charge) obj));
} else if (eventType.startsWith("payment_intent.")) {
return deserializeObject(stripeEvent).map(obj -> new StripePaymentIntentWebhookPayload(eventType, (PaymentIntent) obj));
}
return Optional.empty();
} catch (Exception e) {
log.error("got exception while handling stripe webhook", e);
return Optional.empty();
}
}
Aggregations