Coder Social home page Coder Social logo

osiris-team / payhook Goto Github PK

View Code? Open in Web Editor NEW
25.0 3.0 2.0 466 KB

The simplest payment processing Java library in the world. Unifies PayPal and Stripe into one API. Supports both regular payments and subscriptions, with NO need of handling json, requests, storage into a database yourself.

License: MIT License

Java 100.00%
java-api paypal-java-sdk validating-paypals-webhooks webhooks paypal payment payment-processing payments stripe

payhook's Issues

cancel() com.stripe.exception.InvalidRequestException: No such subscription:

com.stripe.exception.InvalidRequestException: No such subscription: 'sub_1MOo5NIX00iKYn4iAq6PYg8N'; code: resource_missing; request-id: req_ywaU0OERhkLsSB
	at com.stripe.net.LiveStripeResponseGetter.handleApiError(LiveStripeResponseGetter.java:194)
	at com.stripe.net.LiveStripeResponseGetter.request(LiveStripeResponseGetter.java:65)
	at com.stripe.net.ApiResource.request(ApiResource.java:181)
	at com.stripe.model.Subscription.cancel(Subscription.java:644)
	at com.stripe.model.Subscription.cancel(Subscription.java:596)
	at com.osiris.payhook.PayHook.cancelPayment(PayHook.java:1184)
	at com.osiris.payhook.Subscription.cancel(Subscription.java:80)
	at com.osiris.payhook.MainTest.main(MainTest.java:161)

PAYPAL: Invalid HTTP method: PATCH / putProduct()

[08-01-2023 23:55:02][AP-Web][WARN] ================================
[08-01-2023 23:55:02][AP-Web][WARN] Message: null
[08-01-2023 23:55:02][AP-Web][WARN] Details: Invalid HTTP method: PATCH
[08-01-2023 23:55:02][AP-Web][WARN] Type: java.net.ProtocolException
[08-01-2023 23:55:02][AP-Web][WARN] Stacktrace: 
[08-01-2023 23:55:02][AP-Web][WARN] java.base/java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:489)
[08-01-2023 23:55:02][AP-Web][WARN] java.base/sun.net.www.protocol.http.HttpURLConnection.setRequestMethod(HttpURLConnection.java:598)
[08-01-2023 23:55:02][AP-Web][WARN] java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestMethod(HttpsURLConnectionImpl.java:344)
[08-01-2023 23:55:02][AP-Web][WARN] com.osiris.payhook.paypal.UtilsPayPalJson.jsonFromUrl(UtilsPayPalJson.java:33)
[08-01-2023 23:55:02][AP-Web][WARN] com.osiris.payhook.paypal.UtilsPayPalJson.patchJsonAndGetResponse(UtilsPayPalJson.java:84)
[08-01-2023 23:55:02][AP-Web][WARN] com.osiris.payhook.paypal.PayPalUtils.updateProduct(PayPalUtils.java:167)
[08-01-2023 23:55:02][AP-Web][WARN] com.osiris.payhook.PayHook.putProduct(PayHook.java:534)

updateProduct() patch com.osiris.jlib.json.exceptions.HttpErrorException:

Caused by: java.lang.RuntimeException: com.osiris.jlib.json.exceptions.HttpErrorException: 
url: https://api-m.paypal.com/v1/catalogs/products/PROD-1YH85584PA142631C 
message: 
json: 

	at com.osiris.autoplug.webserver.GD.<clinit>(GD.java:248)
	... 10 more
Caused by: com.osiris.jlib.json.exceptions.HttpErrorException: 
url: https://api-m.paypal.com/v1/catalogs/products/PROD-1YH85584PA142631C 
message: 
json: 

	at com.osiris.payhook.paypal.UtilsPayPalJson.jsonFromUrl(UtilsPayPalJson.java:50)
	at com.osiris.payhook.paypal.UtilsPayPalJson.patchJsonAndGetResponse(UtilsPayPalJson.java:64)
	at com.osiris.payhook.paypal.PayPalUtils.updateProduct(PayPalUtils.java:167)
	at com.osiris.payhook.PayHook.putProduct(PayHook.java:540)

WebHookValidationException - Received invalid webhook event (STRIPE, validation failed).

[09-01-2023 02:32:47][AP-Web][WARN] ================================
[09-01-2023 02:32:47][AP-Web][WARN] Message: null
[09-01-2023 02:32:47][AP-Web][WARN] Details: Received invalid webhook event (STRIPE, validation failed).
[09-01-2023 02:32:47][AP-Web][WARN] Type: com.osiris.payhook.exceptions.WebHookValidationException
[09-01-2023 02:32:47][AP-Web][WARN] Stacktrace: 
[09-01-2023 02:32:47][AP-Web][WARN] com.osiris.payhook.PayHook.receiveWebhookEvent(PayHook.java:1023)
...

Upgrade Instructions

Hi, I used this library in version 2.4 which does not seem to work with paypal anymore.
When I upgrade to version 4 everything seems to have changed. Are there any upgrade instructions? Does it now require its own database and other stuff?

Support REST-API calls too, instead of only webhook events

Currently, PayHook relies on webhook events/notifications and was designed around it.
However, it can also be done without webhooks.

Contributions are welcome for this one since I don't need support for it.

  • Find a way to capture payments after they have been created
  • Find a way to check if subscriptions have been paid

java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax;

Exception in thread "Thread-2" java.lang.RuntimeException: java.lang.RuntimeException: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 0 AND timestampCancelled = 0 AND timestampCreated < 1673038553098 AND times...' at line 1
	at com.osiris.payhook.PayHook.lambda$init$4(PayHook.java:276)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.RuntimeException: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 0 AND timestampCancelled = 0 AND timestampCreated < 1673038553098 AND times...' at line 1
	at com.osiris.jsqlgen.payhook.Payment.get(Payment.java:285)
	at com.osiris.jsqlgen.payhook.Payment.getPendingPayments(Payment.java:813)
	at com.osiris.jsqlgen.payhook.Payment.getPendingPayments(Payment.java:802)
	at com.osiris.payhook.PayHook.lambda$init$4(PayHook.java:251)
	... 1 more
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 0 AND timestampCancelled = 0 AND timestampCreated < 1673038553098 AND times...' at line 1
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1003)
	at com.osiris.jsqlgen.payhook.Payment.get(Payment.java:260)
	... 4 more

Network overload possible? Out of memory possible?

Since webhook events are verified by sending them completely to the payment processor and then waiting for the result, a malicious user could create fake webhook events that are very very large, thus decreasing overall network speed.

If the webhook event is large enough it could even cause the app to go out of memory, because the event is parsed fully.

It seems that payment processors also don't really have a maximum allowed size for the webhook event before they close the connection.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.