Skip to content

Commit bccc4f4

Browse files
committed
fix recurring payment missing details
1 parent b19119e commit bccc4f4

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/main/java/com/osiris/payhook/PayHook.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -974,11 +974,16 @@ public static void receiveWebhookEvent(PaymentProcessor paymentProcessor, Map<St
974974
Product product = Product.get(firstPayment.productId);
975975
if (product.charge != amountPaid)
976976
throw new WebHookValidationException("Received invalid webhook event (" + PaymentProcessor.PAYPAL + ", expected paid amount of '" + product.charge + "' but got '" + amountPaid + "').");
977-
Payment newPayment = Payment.create(firstPayment.userId, amountPaid, product.currency, product.paymentInterval);
978-
newPayment.paypalOrderId = firstPayment.paypalOrderId;
979-
newPayment.paypalCaptureId = firstPayment.paypalCaptureId;
980-
newPayment.paypalSubscriptionId = firstPayment.paypalSubscriptionId;
977+
Payment newPayment = firstPayment.clone();
978+
newPayment.id = Payment.create(firstPayment.userId, amountPaid, product.currency, product.paymentInterval)
979+
.id;
980+
newPayment.url = null;
981+
newPayment.charge = amountPaid;
982+
newPayment.timestampCreated = now;
981983
newPayment.timestampAuthorized = now;
984+
newPayment.timestampRefunded = 0;
985+
newPayment.timestampExpires = now + 100000;
986+
newPayment.timestampCancelled = 0;
982987
Payment.add(newPayment);
983988
onPaymentAuthorized.execute(newPayment);
984989
}

src/main/java/com/osiris/payhook/stripe/UtilsStripe.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,16 @@ public void handleEvent(Map<String, String> header, String body, String stripeWe
105105
Product product = Product.get(lastPayment.productId);
106106
if (product.charge != invoice.getAmountPaid())
107107
throw new WebHookValidationException("Received invalid webhook event (" + PaymentProcessor.STRIPE + ", expected paid amount of '" + product.charge + "' but got '" + invoice.getAmountPaid() + "').");
108-
Payment newPayment = Payment.create(lastPayment.userId, invoice.getAmountPaid(), product.currency, product.paymentInterval);
109-
newPayment.stripeSessionId = lastPayment.stripeSessionId;
110-
newPayment.stripePaymentIntentId = invoice.getPaymentIntent();
111-
newPayment.stripeSubscriptionId = lastPayment.stripeSubscriptionId;
108+
Payment newPayment = lastPayment.clone();
109+
newPayment.id = Payment.create(lastPayment.userId, invoice.getAmountPaid(), product.currency, product.paymentInterval)
110+
.id;
111+
newPayment.url = null;
112+
newPayment.charge = invoice.getAmountPaid();
113+
newPayment.timestampCreated = now;
112114
newPayment.timestampAuthorized = now;
115+
newPayment.timestampRefunded = 0;
116+
newPayment.timestampExpires = now + 100000;
117+
newPayment.timestampCancelled = 0;
113118
Payment.add(newPayment);
114119
PayHook.onPaymentAuthorized.execute(newPayment);
115120
} else if ("customer.subscription.deleted".equals(type)) {// Recurring payments

0 commit comments

Comments
 (0)