Giter VIP home page Giter VIP logo

cashfree-pg-sdk-java's People

Contributors

prasunparijat avatar prasunparijat-cashfree avatar suhas-cashfree avatar

Watchers

 avatar  avatar

cashfree-pg-sdk-java's Issues

The JSON string is invalid for CFPaymentsEntityMethod with oneOf schemas

I am trying to get payments for an order as follow:

    @SneakyThrows
    public List<CFPaymentsEntity> getPaymentDetails(String orderId) {

        ApiResponse<List<CFPaymentsEntity>> payments = cfPaymentGatewayService.getAllPayments(cfConfig, CFHeaders.builder().build(), orderId);
        if (payments.getStatusCode() != 200) {
            throw PaymentServiceException.create(ResponseCode.PAYMENT_GATEWAY_ERROR);
        }

        return payments.getData();
    }

But failing with following error

ERROR [2023-04-16 18:13:48,302] io.dropwizard.jersey.errors.LoggingExceptionMapper: Error handling a request: ef1d9d7910353068
! java.io.IOException: The JSON string is invalid for CFPaymentsEntityMethod with oneOf schemas: CFPaymentsEntityAppPayment, CFPaymentsEntityCardPayment, CFPaymentsEntityCardlessEMIPayment, CFPaymentsEntityNetbankingPayment, CFPaymentsEntityPaylaterPayment, CFPaymentsEntityUPIPayment. 0 class(es) match the result, expected 1. Detailed failure message for oneOf schemas: [Deserialization for CFPaymentsEntityAppPayment failed with `The field `others` in the JSON string is not defined in the `CFPaymentsEntityAppPayment` properties. JSON: {"others":{"card_number":"XXXXXXilure@gocash","card_country":"","card_network":null,"payment_mode":"UPI_CREDIT_CARD","bank_number":null,"upi_id":null,"bank_account":""}}`., Deserialization for CFPaymentsEntityCardPayment failed with `The field `others` in the JSON string is not defined in the `CFPaymentsEntityCardPayment` properties. JSON: {"others":{"card_number":"XXXXXXilure@gocash","card_country":"","card_network":null,"payment_mode":"UPI_CREDIT_CARD","bank_number":null,"upi_id":null,"bank_account":""}}`., Deserialization for CFPaymentsEntityCardlessEMIPayment failed with `The field `others` in the JSON string is not defined in the `CFPaymentsEntityCardlessEMIPayment` properties. JSON: {"others":{"card_number":"XXXXXXilure@gocash","card_country":"","card_network":null,"payment_mode":"UPI_CREDIT_CARD","bank_number":null,"upi_id":null,"bank_account":""}}`., Deserialization for CFPaymentsEntityNetbankingPayment failed with `The field `others` in the JSON string is not defined in the `CFPaymentsEntityNetbankingPayment` properties. JSON: {"others":{"card_number":"XXXXXXilure@gocash","card_country":"","card_network":null,"payment_mode":"UPI_CREDIT_CARD","bank_number":null,"upi_id":null,"bank_account":""}}`., Deserialization for CFPaymentsEntityPaylaterPayment failed with `The field `others` in the JSON string is not defined in the `CFPaymentsEntityPaylaterPayment` properties. JSON: {"others":{"card_number":"XXXXXXilure@gocash","card_country":"","card_network":null,"payment_mode":"UPI_CREDIT_CARD","bank_number":null,"upi_id":null,"bank_account":""}}`., Deserialization for CFPaymentsEntityUPIPayment failed with `The field `others` in the JSON string is not defined in the `CFPaymentsEntityUPIPayment` properties. JSON: {"others":{"card_number":"XXXXXXilure@gocash","card_country":"","card_network":null,"payment_mode":"UPI_CREDIT_CARD","bank_number":null,"upi_id":null,"bank_account":""}}`.]. JSON: {"others":{"card_number":"XXXXXXilure@gocash","card_country":"","card_network":null,"payment_mode":"UPI_CREDIT_CARD","bank_number":null,"upi_id":null,"bank_account":""}}
! at com.cashfree.pg.model.CFPaymentsEntityMethod.validateJsonObject(CFPaymentsEntityMethod.java:608)
! at com.cashfree.pg.model.CFPaymentsEntity.validateJsonObject(CFPaymentsEntity.java:817)
! at com.cashfree.pg.model.CFPaymentsEntity$CustomTypeAdapterFactory$1.read(CFPaymentsEntity.java:853)
! at com.cashfree.pg.model.CFPaymentsEntity$CustomTypeAdapterFactory$1.read(CFPaymentsEntity.java:842)
! at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:201)
! at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
! at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
! at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
! at com.google.gson.Gson.fromJson(Gson.java:1214)
! ... 80 common frames omitted
! Causing: com.google.gson.JsonSyntaxException: java.io.IOException: The JSON string is invalid for CFPaymentsEntityMethod with oneOf schemas: CFPaymentsEntityAppPayment, CFPaymentsEntityCardPayment, CFPaymentsEntityCardlessEMIPayment, CFPaymentsEntityNetbankingPayment, CFPaymentsEntityPaylaterPayment, CFPaymentsEntityUPIPayment. 0 class(es) match the result, expected 1. Detailed failure message for oneOf schemas: [Deserialization for CFPaymentsEntityAppPayment failed with `The field `others` in the JSON string is not defined in the `CFPaymentsEntityAppPayment` properties. JSON: {"others":{"card_number":"XXXXXXilure@gocash","card_country":"","card_network":null,"payment_mode":"UPI_CREDIT_CARD","bank_number":null,"upi_id":null,"bank_account":""}}`., Deserialization for CFPaymentsEntityCardPayment failed with `The field `others` in the JSON string is not defined in the `CFPaymentsEntityCardPayment` properties. JSON: {"others":{"card_number":"XXXXXXilure@gocash","card_country":"","card_network":null,"payment_mode":"UPI_CREDIT_CARD","bank_number":null,"upi_id":null,"bank_account":""}}`., Deserialization for CFPaymentsEntityCardlessEMIPayment failed with `The field `others` in the JSON string is not defined in the `CFPaymentsEntityCardlessEMIPayment` properties. JSON: {"others":{"card_number":"XXXXXXilure@gocash","card_country":"","card_network":null,"payment_mode":"UPI_CREDIT_CARD","bank_number":null,"upi_id":null,"bank_account":""}}`., Deserialization for CFPaymentsEntityNetbankingPayment failed with `The field `others` in the JSON string is not defined in the `CFPaymentsEntityNetbankingPayment` properties. JSON: {"others":{"card_number":"XXXXXXilure@gocash","card_country":"","card_network":null,"payment_mode":"UPI_CREDIT_CARD","bank_number":null,"upi_id":null,"bank_account":""}}`., Deserialization for CFPaymentsEntityPaylaterPayment failed with `The field `others` in the JSON string is not defined in the `CFPaymentsEntityPaylaterPayment` properties. JSON: {"others":{"card_number":"XXXXXXilure@gocash","card_country":"","card_network":null,"payment_mode":"UPI_CREDIT_CARD","bank_number":null,"upi_id":null,"bank_account":""}}`., Deserialization for CFPaymentsEntityUPIPayment failed with `The field `others` in the JSON string is not defined in the `CFPaymentsEntityUPIPayment` properties. JSON: {"others":{"card_number":"XXXXXXilure@gocash","card_country":"","card_network":null,"payment_mode":"UPI_CREDIT_CARD","bank_number":null,"upi_id":null,"bank_account":""}}`.]. JSON: {"others":{"card_number":"XXXXXXilure@gocash","card_country":"","card_network":null,"payment_mode":"UPI_CREDIT_CARD","bank_number":null,"upi_id":null,"bank_account":""}}
! at com.google.gson.Gson.fromJson(Gson.java:1229)
! at com.google.gson.Gson.fromJson(Gson.java:1124)
! at com.google.gson.Gson.fromJson(Gson.java:1034)
! at com.google.gson.Gson.fromJson(Gson.java:1001)
! at com.cashfree.pg.JSON.deserialize(JSON.java:277)
! at com.cashfree.pg.ApiClient.deserialize(ApiClient.java:887)
! at com.cashfree.pg.ApiClient.handleResponse(ApiClient.java:1102)
! at com.cashfree.pg.ApiClient.execute(ApiClient.java:1017)
! at com.cashfree.pg.api.PaymentsApi.getPaymentsfororderWithHttpInfo(PaymentsApi.java:619)
! at com.cashfree.pg.gatewayinterface.CFPaymentGatewayService.getAllPayments(CFPaymentGatewayService.java:137)
! at com.tarkshala.tavahot.ms.payments.clients.CashfreeClient.getPaymentDetails(CashfreeClient.java:129)
! at com.tarkshala.tavahot.ms.payments.services.CallbackService.updatePaymentState(CallbackService.java:31)
! at com.tarkshala.tavahot.ms.payments.services.CallbackService.handlePGPaymentNotification(CallbackService.java:26)
! at com.tarkshala.tavahot.ms.payments.resources.CallbackResource.handlePGPaymentNotification(CallbackResource.java:30)
! at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
! at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
! at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
! at java.base/java.lang.reflect.Method.invoke(Method.java:568)
! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:134)
! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:177)
! at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:159)
! at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:81)

SDK not updated with api response

The create order api is now returning an attribute called customer_uid, which is failing during deserialization in the java sdk as customer_uid is not a part of the CFCustomerDetails object.

{

2 | "cf_order_id": 2151987171,
3 | "created_at": "2023-10-13T22:46:10+05:30",
4 | "customer_details": {
5 | "customer_id": "409128494",
6 | "customer_name": null,
7 | "customer_email": null,
8 | "customer_phone": "9876543210",
9 | "customer_uid": null
10 | },
11 | "entity": "order",
12 | "order_amount": 636,
13 | "order_currency": "INR",
14 | "order_expiry_time": "2023-11-12T22:46:10+05:30",
15 | "order_id": "order_4105752WiZTisMERUFTJGDkoO8pEl3tuq",
16 | "order_meta": {
17 | "return_url": null,
18 | "notify_url": null,
19 | "payment_methods": null
20 | },
21 | "order_note": null,
22 | "order_splits": [],
23 | "order_status": "ACTIVE",
24 | "order_tags": null,
25 | "payment_session_id": "session_5awMLI1sM8qmbztBA-bKtBtrHttTzrkEifRFOiT3e8ZMcytARS7a5oj-5VfFbnt-nrauHwrX2x3YXtvR7tVvZgf0ngH8eNGLlFSSnJAXzi3_",
26 | "payments": {
27 | "url": "https://sandbox.cashfree.com/pg/orders/order_4105752WiZTisMERUFTJGDkoO8pEl3tuq/payments"
28 | },
29 | "refunds": {
30 | "url": "https://sandbox.cashfree.com/pg/orders/order_4105752WiZTisMERUFTJGDkoO8pEl3tuq/refunds"
31 | },
32 | "settlements": {
33 | "url": "https://sandbox.cashfree.com/pg/orders/order_4105752WiZTisMERUFTJGDkoO8pEl3tuq/settlements"
34 | },
35 | "terminal_data": null
36 | }

Fetching Payment Details

I am trying to Fetching Payment Details by Java previously below code works fine and i got the response:

` ApiResponse<List> response1 = cashfree.PGOrderFetchPayments("2023-08-01", orderid,null, null, null);
List paymentEntities = response1.getData();
String paymentstatus="";
String txnid="";
String orderid1="";
String paymentmode="";
String amount="";

        for (int i = 0; i < paymentEntities.size(); i++) {
            paymentstatus= String.valueOf(paymentEntities.get(i).getPaymentStatus());
            txnid=paymentEntities.get(i).getCfPaymentId();
            orderid1=paymentEntities.get(i).getOrderId();
            paymentmode= String.valueOf(paymentEntities.get(i).getPaymentMethod().getPaymentMethodAppInPaymentsEntity().getApp().getProvider());
            amount= String.valueOf(paymentEntities.get(i).getOrderAmount());
        }`

But today i got the error:

Message: class com.cashfree.model.PaymentMethodUPIInPaymentsEntity cannot be cast to class com.cashfree.model.PaymentMethodAppInPaymentsEntity (com.cashfree.model.PaymentMethodUPIInPaymentsEntity and com.cashfree.model.PaymentMethodAppInPaymentsEntity are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @47fe85d4)

java.lang.ClassCastException: class com.cashfree.model.PaymentMethodUPIInPaymentsEntity cannot be cast to class com.cashfree.model.PaymentMethodAppInPaymentsEntity (com.cashfree.model.PaymentMethodUPIInPaymentsEntity and com.cashfree.model.PaymentMethodAppInPaymentsEntity are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @47fe85d4)

Exception: com.cashfree.model.PaymentEntityPaymentMethod.getPaymentMethodAppInPaymentsEntity(PaymentEntityPaymentMethod.java:412)
com.example.regalbiriyani.CashFreeConfirm.doGet(CashFreeConfirm.java:50)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:683)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:792)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Please check the issue i want to take the gateway to production.

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.