#A-I-nstein-stripe-java
1 messages · Page 1 of 1 (latest)
Also can I directly pass the token returned by the google pay api to the 'source' parameter in the charge function or do I have to parse it ?
something like this ( token = paymentResult['paymentMethodData']['tokenizationData']['token'];) maybe ?
Does our installation guide help you on your setup questions? https://github.com/stripe/stripe-java#installation
By google pay API do you mean google's API or our something that our APi gives you for google pay?
google's API
https://pub.dev/packages/pay this flutter plugin I'm using which returns a token
You won't be able to use their API token with our API. You will want to use this guide to integrate with Google Pay with us https://stripe.com/docs/google-pay
Learn how to accept payments using Google Pay.
what about the Charge.create? what package am I supposed to import?
https://stackoverflow.com/questions/68659908/use-google-pay-response-token-in-stripe-api?rq=1
but in this discussion, the user seems to think that that we could directly send the api to the 'source parameter'?
Looking in to these...
You are right on the second one. With that setup you can use that token.
And can you use other stripe methods with java at all? Is it just Charge related things that you can't see?
When I call the Charge.create function, an error is thrown. I don't know how to import the Charge class.
So can I directly send the token or should I parse it?
What error is thrown?
Like this.
That the class Charge is not recognised
And you've already installed the Stripe-java library? A direct copy-paste of the exact error message you're seeing would be helpful!
Yes. One second
MainActivity.java:42: error: cannot find symbol
Charge charge = Charge.create(params);
^
symbol: class Charge
location: class MainActivity
import com.stripe.Stripe;
import java.util.HashMap;
import java.util.Map;
those are my imports
implementation "com.stripe:stripe-java:20.75.0"
the dependency in my build.gradle
and what happens if you also import the following:
import com.stripe.model.*;
import com.stripe.param.*;
error: unreported exception StripeException; must be caught or declared to be thrown
Charge charge = Charge.create(params);
^
1 error
So that tells you you need to catch the exception
So I simply need to work out the usual error handling? Oh Thank you.
Yes, it wasn't working earlier since you didn't have the correct imports.
@chrome thorn @versed timber thank you for helping me out.
Now that you have them, you just need to fix your error handling and make sure you keep the imports up to date
Really appreciate your time.
Anything on this?
Is there a specific reason you're trying to integrate directly with Google Pay? I only ask because this is a MUCH more complicated integration path
You haven't responded for a while so I'm going to archive this thread - if you come back later and need help please ask for someone to reopen your thread in the main channel and we can continue from there!!
I do. My specific use case requires me to use the Pay plugin in flutter (https://pub.dev/packages/pay) and the google pay payment token it returns. I'm thinking if I can now send the token returned by the plugin to Charge.create method's 'source' parameter
Hey @sleek gate karbi is offline so I will try to catch up. Please wait for a wile
Sure. No problem.
Okie I think I got it from here. Yes you now can use that token to Charge create method
Just to be sure, does your token start with "tok_"?
I'm still using the test environment with Google API and so it returns dummy values ('examplePaymentToken'). I'll let you know when in move forward.
Sure
Just one more question.
this.
I think the token is a string already? Then you should be good to directly use it. The ideal way to confirm if it is a correct token, is checking if it starts by "tok_"
Okay. Makes sense. I'll do that. Thank you so much for the support. Appreciate your time.
Oh but if it is something like ('examplePaymentToken'), then you may want to strip out that ( or '. Just make sure the check the value you got