#disha_code

1 messages · Page 1 of 1 (latest)

warped notchBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1219600960737775717

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

simple latchBOT
wheat dock
#

👋 happy to help

warped stream
#

Hello

wheat dock
#

would you mind sharing the request ID that failed please?

warped stream
#

sure

#

actually it seems the code itself is failing

#

19-03-2024 16:11:17.148 [http-nio-8081-exec-2] INFO com.pti.eic.StripePaymentService.createPaymentIntent - Creating Payment Intent for:cus_PivlUB7G3WcvUe, pm_1Ovdb1PW5uzzYOGMTXS8rEYy
19-03-2024 16:11:17.183 [http-nio-8081-exec-2] ERROR c.p.eic.controller.PaymentController.logAfterThrowing - Exception in authAndCapture() with cause = 'java.lang.ClassNotFoundException: com.google.gson.ReflectionAccessFilter' and exception = 'com/google/gson/ReflectionAccessFilter'
java.lang.NoClassDefFoundError: com/google/gson/ReflectionAccessFilter

wheat dock
#

would you mind sharing the whole code?

warped stream
#

sure

#

public void createPaymentIntent(String clonedCustomerId, String clonedPaymentMethod,
RequestOptions requestOptions) {

    LOGGER.info("Creating Payment Intent for:{}, {}", clonedCustomerId, clonedPaymentMethod);
    
    try {
        PaymentIntentCreateParams params =
              PaymentIntentCreateParams.builder()
                .setAmount(60L)
                .setCurrency("usd")
                .addPaymentMethodType("card")
                .setCaptureMethod(PaymentIntentCreateParams.CaptureMethod.MANUAL)
                .setCustomer(clonedCustomerId)
                .setPaymentMethod(clonedPaymentMethod)
                .addExpand("latest_charge")

                .setConfirm(true)
                .build();

            PaymentIntent paymentIntent = PaymentIntent.create(params, requestOptions);
            
            LOGGER.info("Payment Intent ID:{}", paymentIntent.getId());
            
            collectPayment(paymentIntent.getId(), requestOptions);
    }
    catch(StripeException ex) {
        LOGGER.error("Error creating a PaymentIntent:{}",ex);
    }
}
#

this code was running fine with Stripe API v21.0.0

#

but with 24.20.0, it is faiing

wheat dock
#

would you mind sharing the request ID that succeeded?

#

req_xxx

warped stream
#

let me

#

I could find the payment intent id:pi_3OvyVXPW5uzzYOGM1Xv7OeJt

#

I did see req id in the application logs, but they are gone

#

hope you can work with this id

wheat dock
#

I was able to find the request ID for this one

#

I was hoping to be able to find a request ID for the failing one with the 24.20.0 version

#

but I wasn't able to

warped stream
#

that's right, because the code itself fails

#

so the request doesn't reach Stripe

#

it appears as if the gson library class that it is looking for is not found

#

19-03-2024 16:11:17.183 [http-nio-8081-exec-2] ERROR c.p.eic.controller.PaymentController.logAfterThrowing - Exception in authAndCapture() with cause = 'java.lang.ClassNotFoundException: com.google.gson.ReflectionAccessFilter' and exception = 'com/google/gson/ReflectionAccessFilter'
java.lang.NoClassDefFoundError: com/google/gson/ReflectionAccessFilter

#

for what it matters, I'm using Java 8 version

wheat dock
#

what version of "com.google.code.gson" do you have in your grade file?

warped stream
#

I tried latest one - 2.10.1

carmine breach
#

Could you please try dropping and re-installing all the libraries?

warped stream
#

tried a couple of times

carmine breach
#

This just looks like a very straightforward example that should just work. And if you start a fresh project?

warped stream
#

let me try that out

#

tried that, getting same error

#

Exception in thread "main" java.lang.NoSuchMethodError: com.google.gson.GsonBuilder.addReflectionAccessFilter(Lcom/google/gson/ReflectionAccessFilter;)Lcom/google/gson/GsonBuilder;
at com.stripe.net.ApiResource.createGson(ApiResource.java:41)
at com.stripe.net.ApiResource.<clinit>(ApiResource.java:26)
at Test.Test1.StripeTest.main(StripeTest.java:26)

spark orbit
#

Hey! Taking over for my colleague. Let me catch up.

warped stream
#

sure

spark orbit
#

Could you please share the pom.xml?

#

or your build.gradle ?

warped stream
#

sure

spark orbit
#

thanks, checking..

warped stream
#

sure

spark orbit
#

What do you have in these dependencies?

        <dependency>
            <groupId>eu.chargetime.ocpp</groupId>
            <artifactId>common</artifactId>
            <version>0.5-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>eu.chargetime.ocpp</groupId>
            <artifactId>OCPP-J</artifactId>
            <version>0.1-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>eu.chargetime.ocpp</groupId>
            <artifactId>v1_6</artifactId>
            <version>0.5-SNAPSHOT</version>
        </dependency>
warped stream
#

they are for a feature we are implementing

#

do you want me to try without these?

spark orbit
#

Are you using GSON in these libs ?

warped stream
#

they are 3rd party libraries, I'm not sure

spark orbit
#

Can you run mvn dependency:tree and see what are the GSON version used ?

warped stream
#

ok

#

Test:Test1🫙0.0.1-SNAPSHOT
[INFO] +- com.stripe:stripe-java🫙24.20.0:compile
[INFO] | - com.google.code.gson:gson🫙2.10.1:runtime
[INFO] +- junit:junit🫙4.11:test
[INFO] | - org.hamcrest:hamcrest-core🫙1.3:test
[INFO] - commons-net:commons-net🫙3.6:compile

spark orbit
#

Can you share a complete code snippets that I can run using your pom.xml ?

warped stream
#

sure

#

package Test.Test1;

import com.stripe.exception.StripeException;
import com.stripe.model.PaymentIntent;
import com.stripe.net.RequestOptions;
import com.stripe.param.PaymentIntentCreateParams;

public class StripeTest {

public static void main(String[] args) throws StripeException {
    
    RequestOptions requestOptions = RequestOptions.builder().setStripeAccount("acct_1OeaYJPW5uzzYOGM")
    .setApiKey("sk_test_51LamFuBZfmvI9JsLziMprNBpwKsTTOqKuytFowqJkbmvtrpSzxz6Myt60NEdoG8ERU3gGyog94SVIMeIaonWxaWy00Ta4RYvjK").build();
    
    PaymentIntentCreateParams params =
            PaymentIntentCreateParams.builder()
              .setAmount(60L)
              .setCurrency("usd")
              .addPaymentMethodType("card")
              .setCaptureMethod(PaymentIntentCreateParams.CaptureMethod.MANUAL)
              .setCustomer("cus_PivlUB7G3WcvUe")
              .setPaymentMethod("pm_1Ovdb1PW5uzzYOGMTXS8rEYy")
              .addExpand("latest_charge")
              .setConfirm(true)
              .build();

          PaymentIntent paymentIntent = PaymentIntent.create(params, requestOptions);
          
          System.out.println("Payment Intent ID:"+paymentIntent.getId());

}

}

spark orbit
#

I just run your code and it's working fine

warped stream
#

ohh

spark orbit
#

Can y ou remove the ocpp dependencies and double check ?

warped stream
#

doing

#

works without all that

#

thanks for help

#

I will drill down what was going wrong with those jars