Skip to content

Commit

Permalink
fix recurring payment missing details
Browse files Browse the repository at this point in the history
  • Loading branch information
Osiris-Team committed Feb 23, 2023
1 parent b19119e commit bccc4f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions src/main/java/com/osiris/payhook/PayHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -974,11 +974,16 @@ public static void receiveWebhookEvent(PaymentProcessor paymentProcessor, Map<St
Product product = Product.get(firstPayment.productId);
if (product.charge != amountPaid)
throw new WebHookValidationException("Received invalid webhook event (" + PaymentProcessor.PAYPAL + ", expected paid amount of '" + product.charge + "' but got '" + amountPaid + "').");
Payment newPayment = Payment.create(firstPayment.userId, amountPaid, product.currency, product.paymentInterval);
newPayment.paypalOrderId = firstPayment.paypalOrderId;
newPayment.paypalCaptureId = firstPayment.paypalCaptureId;
newPayment.paypalSubscriptionId = firstPayment.paypalSubscriptionId;
Payment newPayment = firstPayment.clone();
newPayment.id = Payment.create(firstPayment.userId, amountPaid, product.currency, product.paymentInterval)
.id;
newPayment.url = null;
newPayment.charge = amountPaid;
newPayment.timestampCreated = now;
newPayment.timestampAuthorized = now;
newPayment.timestampRefunded = 0;
newPayment.timestampExpires = now + 100000;
newPayment.timestampCancelled = 0;
Payment.add(newPayment);
onPaymentAuthorized.execute(newPayment);
}
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/com/osiris/payhook/stripe/UtilsStripe.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,16 @@ public void handleEvent(Map<String, String> 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
Expand Down

0 comments on commit bccc4f4

Please sign in to comment.