#Ramya Chekuri-GooglePay

1 messages · Page 1 of 1 (latest)

rustic robin
#

Hi there, what SDK are you using?

humble pewter
#

com. stripe:stripe-java:19.45.0
com. stripe:stripe-android:14.4.0

rustic robin
#

I see. Can you paste the request id here? I can take a look. Also did you check your Stripe Dashboard logs for that request? What was the error?

#

I found that request req_EEvxOoHyjCpkdT, the error message is Missing required param: amount. You can re-check your server side code (in Java) around where you are creating PaymentIntent

humble pewter
#

Ok.. Will share here the parameters what we are sending

humble pewter
#

PaymentIntentCreateParams params =
PaymentIntentCreateParams.builder()
.setAmount(Long.parseLong(value))
.setCurrency("usd")
.build();
sending amount as long .. currency in lowercase

rustic robin
#

I see, can you put a debug to print out that value? Because in our log I don't see an amount passed in

humble pewter
#

ok Sure

#

is it correct way to send value as Long

#

PaymentIntentCreateParams params =
PaymentIntentCreateParams.builder()
.setAmount(1000L)
.setCurrency("usd")
.build();

#

PaymentIntent intent = PaymentIntent.create(params);
i have given values statically.. but still getting intent as null

rustic robin
#

Long should work. How about print out the whole PaymentIntentCreateParams after creation? Do you see the amount inside that object?

humble pewter
#

yes

#

it is returning same when i get from params

#

params.getAmount() and params.getCurrency()

#

it is working in debug mode getting this issue release mode

rustic robin
#

Hmm? So in test mode you do have the PaymentIntent with amount? Can you give an example requests in Test mode and Live mode?

humble pewter
#

not using any API calls we are using java code directly in thread and sending to PaymentIntent object.

#

class getSecretKey extends AsyncTask<String,String,String>{
String clientSecret;
@Override
protected String doInBackground(String... strings) {

        String units = preferenceUtils.getString(Constants.units,Constants.no_value);
        int amount = Integer.parseInt(MyApplication.getInstance().getDonation_charges_amount());
        String value = String.valueOf(amount*100);

        PaymentIntentCreateParams params =
                PaymentIntentCreateParams.builder()
                        .setAmount(1000L)
                        .setCurrency("usd")
                        .build();

        System.out.println("amount ::::" +params.getAmount()+"//"+params.getCurrency());


        try {
            Stripe.apiKey = stripe_sk;
            
            PaymentIntent intent = PaymentIntent.create(params);
            clientSecret = intent.getClientSecret();
            
        }catch (Exception e){
            System.out.println("in catch block");
            e.printStackTrace();


            new Thread()
            {
                public void run()
                {
                    PaymentIntegrationActivity.this.runOnUiThread(new Runnable()
                    {
                        public void run()
                        {
                            progressDialog.dismiss();
                            Constants.showAlert(PaymentIntegrationActivity.this,e.getMessage());
                        }
                    });
                }
            }.start();
        }

        return clientSecret;
    }
}
#

like this

rustic robin
#

Yes, but you can access to your Stripe Dashboard, right?

humble pewter
#

yes

rustic robin
#

wait, in the above code you are passing 1000L directly, right? The original code is

 .setAmount(Long.parseLong(value))
#

With this original code, is your code working in Test mode but not in Live mode?

humble pewter
#

right

#

in release mode both test and live keys are getting same issue

rustic robin
#

you have amount in Int already, why convert it to string and then to Long?

#

anw that's a different thing. In Release mode, can you reproduce and log the value of

 int amount = Integer.parseInt(MyApplication.getInstance().getDonation_charges_amount());

?

humble pewter
#

i understood you point.. but if i give value directly like 1000L

#

why i am getting same issue

rustic robin
#

Give it direct value of 1000L, build in Release mode = getting error?

#

hmm that's strange

humble pewter
#

yes

#

getting intent value null

rustic robin
humble pewter
#

not showing that popup message

rustic robin
#

Can you see the latest failed request here?

fringe scaffold
#

@humble pewter are you creating the payment_intent in your android App using secret key?

#

or you have a java server side doing that?

rustic robin
#

Ah yeah it's confusing. Let clarify that. Debug mode/Release mode is per client build, while this code is on Server

humble pewter
#

for secret key i am creating PaymentIntent

#

PaymentIntentCreateParams params =
PaymentIntentCreateParams.builder()
.setAmount(1000L)
.setCurrency("usd")
.build();

fringe scaffold
#

yeah, i mean are you doing that in yoru android app?

humble pewter
#

yes

fringe scaffold
#

you cannot do taht

#

Stripe-Java is used for server and secret key is like your bank account password which it should not be exposed in your android app

#

so that will not work

#

you will have to have a server like JSP, or Spring server calling Stripe API with Stripe-Java

#

then your android App call your server to get the payment_intent

humble pewter
#

i have a doubt we had so many released.. but we had this issue in recent

#

can you share working android code?

rustic robin
humble pewter
#

why we are getting this issue now

rustic robin
#

As wsw said, you should create the PaymentIntent on server and your Android call your server to get that PaymentIntent Secret. Please see the sample above

humble pewter
humble pewter
rustic robin
#

It should be the only correct way to go

rustic robin
humble pewter
#

They have mentioned only these 3
implementation 'com.stripe:stripe-android:15.1.0'
implementation 'com.squareup.okhttp3:okhttp:4.4.0'
implementation 'com.google.code.gson:gson:2.8.6'

#

followed the same

#

is there any suggestion

rustic robin
#

That should be enough for client. Aren't you using the same for your current setup?

humble pewter
#

using same

humble pewter
#

i am tring to create PaymentIntent object it is giving null

rustic robin
#

You will need to let server to create PaymentIntent

#

you won't pass anything from Android to server, just let your server create a fresh new PaymentIntent, and pass back the clientSecret to your Android

humble pewter
#

ok...

#

for that what i need to send to server

#

is there any specific data

#

like currency and amount like that

#

based on you i think server side they need only currency and amount right

rustic robin
#

That's another story 😄 Technically you wouldn't want to pass amount from Android to server. Server should decide the amount

#

The reason is your information on client can be hijacked (network spoof, Man In the Middle), you wouldn't want some of your customer to to able to change the amount to get a same service

#

So, just define a kind of product id on your server, and pass that id from your Android, and let Server decide what to do when creating a PaymentIntent

humble pewter
#

ok.. i will try with server and get back to you @rustic robin