From bccc4f49e03754b6eaf0a134e583c47795364fa2 Mon Sep 17 00:00:00 2001 From: Osiris Team Date: Thu, 23 Feb 2023 16:06:50 +0100 Subject: [PATCH] fix recurring payment missing details --- src/main/java/com/osiris/payhook/PayHook.java | 13 +++++++++---- .../java/com/osiris/payhook/stripe/UtilsStripe.java | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/osiris/payhook/PayHook.java b/src/main/java/com/osiris/payhook/PayHook.java index f3a8d9d..f2e9471 100644 --- a/src/main/java/com/osiris/payhook/PayHook.java +++ b/src/main/java/com/osiris/payhook/PayHook.java @@ -974,11 +974,16 @@ public static void receiveWebhookEvent(PaymentProcessor paymentProcessor, Map header, String body, String stripeWe Product product = Product.get(lastPayment.productId); if (product.charge != invoice.getAmountPaid()) throw new WebHookValidationException("Received invalid webhook event (" + PaymentProcessor.STRIPE + ", expected paid amount of '" + product.charge + "' but got '" + invoice.getAmountPaid() + "')."); - Payment newPayment = Payment.create(lastPayment.userId, invoice.getAmountPaid(), product.currency, product.paymentInterval); - newPayment.stripeSessionId = lastPayment.stripeSessionId; - newPayment.stripePaymentIntentId = invoice.getPaymentIntent(); - newPayment.stripeSubscriptionId = lastPayment.stripeSubscriptionId; + Payment newPayment = lastPayment.clone(); + newPayment.id = Payment.create(lastPayment.userId, invoice.getAmountPaid(), product.currency, product.paymentInterval) + .id; + newPayment.url = null; + newPayment.charge = invoice.getAmountPaid(); + newPayment.timestampCreated = now; newPayment.timestampAuthorized = now; + newPayment.timestampRefunded = 0; + newPayment.timestampExpires = now + 100000; + newPayment.timestampCancelled = 0; Payment.add(newPayment); PayHook.onPaymentAuthorized.execute(newPayment); } else if ("customer.subscription.deleted".equals(type)) {// Recurring payments