stripe / stripe-android Goto Github PK
View Code? Open in Web Editor NEWStripe Android SDK
Home Page: https://stripe.com/docs/mobile/android
License: MIT License
Stripe Android SDK
Home Page: https://stripe.com/docs/mobile/android
License: MIT License
validateNumber is not working correctly for American express and Diners club card.
The check is being made on "type" which is null, where as getType is returning the right card type.
https://github.com/stripe/stripe-android/blob/master/stripe/src/main/java/com/stripe/android/model/Card.java#L207
for expiration year of 99
I get a client side success and a server side failure.
here is a snip of code....
Card card = new Card(getCardNumber(), getExpMonth(), getExpYear(), getCvc());
if (!card.validateNumber()) {
} else if (!card.validateExpiryDate()) {
} else if (!card.validateCVC()) {
} else if (!card.validateCard()) {
} else {
new Stripe().createToken(card, stripeKey, this);
}
all of those error checks are negative... then I get the server side failure in the callback:
com.stripe.exception.CardException: Your card's expiration year is invalid.
at com.stripe.net.APIResource.handleAPIError(APIResource.java:500)
at com.stripe.net.APIResource._request(APIResource.java:482)
at com.stripe.net.APIResource.request(APIResource.java:420)
at com.stripe.model.Token.create(Token.java:92)
at com.stripe.android.Stripe$1$1.doInBackground(Stripe.java:25)
at com.stripe.android.Stripe$1$1.doInBackground(Stripe.java:22)
at com.stripe.android.compat.AsyncTask$2.call(AsyncTask.java:236)
If I use an invalid month, I get a client side failure as I would expect... So it just seems like the client and the server do not validate years in the same way.
Related to issue #33 and Pull request #34
Unless the card is re-created from scratch any time the number changes, it's not possible to get the number validation to work properly, particularly if using AMEX cards, as type is only set once. (Ie: populating a blank card is not guaranteed to work even with correct data.)
A quick solution for this is to change validateNumber() to reference type indirectly through it's getter.
if (AMERICAN_EXPRESS.equals(getType())) {
instead of
if (AMERICAN_EXPRESS.equals(type)) {
your example is not working,
my data below:
number: 4242424242424242
expYear:2014
expMonth:12
cvc:123
PUBLISHABLE_KEY:pk_test_6pRNASCoBOKtIshFeQd4XMUh
then, i accept a error: illegalStateException! help me , thanks~~
A card with the number 4242 4242 4242 4242
is shown as 4242424242424242
.
Hi,
I have Eclipse Luna Service Release 1a (4.4.1), Android SDK including API level 17 and Android Support Library 21.0.3. I've cloned the stripe-android/ and tried to import stripe-android/stripe/ to Eclipse as "Existing project into workspace", as outlined in https://github.com/stripe/stripe-android#eclipse, but have been unable to do it. The stripe item in "Projects" list of the "Import Projects" dialog is grayed out, it's not possible to select the project. How to use the stripe-android in my environment?
Thanks for help.
Currently using v1.15.1, when newest stripe-java
is 1.16.0. (https://github.com/stripe/stripe-java)
StripeTextUtils
recently started depending on Android Framework through call to android.text.TextUtils
which breaks our Unit Tests…
Can you please roll back to your own code which does not invoke Android Framework?
I have got this link and code from support docs
https://support.stripe.com/questions/can-i-save-a-card-and-charge-it-later
but code is not in android, is it possible in android also to store card and later on charge it?
It skips to the CVC, even though the expiry fields are visually next in line.
The method hashMapFromCard in Stripe.java should have the following lines:
cardParams.put("address_line_1", card.getAddressLine1());
cardParams.put("address_line_2", card.getAddressLine2());
cardParams.put("address_line_city", card.getAddressCity());
cardParams.put("address_line_zip", card.getAddressZip());
cardParams.put("address_line_state", card.getAddressState());
cardParams.put("address_line_country", card.getAddressCountry());
Changed to:
cardParams.put("address_line1", card.getAddressLine1());
cardParams.put("address_line2", card.getAddressLine2());
cardParams.put("address_city", card.getAddressCity());
cardParams.put("address_zip", card.getAddressZip());
cardParams.put("address_state", card.getAddressState());
cardParams.put("address_country", card.getAddressCountry());
This will bring the android library in line with the ios library, and will fix the issue.
In an app using AndroidAnnotations where Stripe().createToken(...) is invoked inside a method annotated with @background, the use of com.stripe.android.compat.AsyncTask causes a crash which is solved by just using android.os.AsyncTask. Do you really anticipate people using stripe-android in an environment that doesn't have android.os.AsyncTask?
W/dalvikvm( 5086): Exception Ljava/lang/RuntimeException; thrown while initializing Lcom/stripe/android/compat/AsyncTask;
E/AndroidRuntime( 5086): FATAL EXCEPTION: pool-1-thread-1
E/AndroidRuntime( 5086): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 5086): at com.stripe.android.Stripe$1.create(Stripe.java:20)
E/AndroidRuntime( 5086): at com.stripe.android.Stripe.createToken(Stripe.java:142)
E/AndroidRuntime( 5086): at com.stripe.android.Stripe.createToken(Stripe.java:125)
E/AndroidRuntime( 5086): at redacted.MainActivity.startCreditPurchase(MainActivity.java:144)
E/AndroidRuntime( 5086): at redacted.MainActivity_.access$2(MainActivity_.java:1)
E/AndroidRuntime( 5086): at redacted.MainActivity_$2.run(MainActivity_.java:111)
E/AndroidRuntime( 5086): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
E/AndroidRuntime( 5086): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
E/AndroidRuntime( 5086): at java.lang.Thread.run(Thread.java:856)
E/AndroidRuntime( 5086): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
E/AndroidRuntime( 5086): at android.os.Handler.<init>(Handler.java:197)
E/AndroidRuntime( 5086): at android.os.Handler.<init>(Handler.java:111)
E/AndroidRuntime( 5086): at com.stripe.android.compat.AsyncTask$InternalHandler.<init>(AsyncTask.java:579)
E/AndroidRuntime( 5086): at com.stripe.android.compat.AsyncTask$InternalHandler.<init>(AsyncTask.java:579)
E/AndroidRuntime( 5086): at com.stripe.android.compat.AsyncTask.<clinit>(AsyncTask.java:189)
E/AndroidRuntime( 5086): ... 9 more
It doesn't appear anywhere. I don't know how it's supposed to work.
Is this lib dead ?
You can see here https://github.com/stripe/stripe-android/releases a 1.0.1 version but in public repo is only available 1.0.0, why? is there a changelog?
Can you please provide a text formatter for the credit card numbers? It seems like cards do not always follow XXXX-XXXX-XXXX-XXXX pattern, would be really nice to have a TextWatcher or something of that nature.
Without it, CC input is a bit tedious!
I'll admit I haven't actually tested this, but I'm pretty sure requestToken()
doesn't work, as it issues a call to the retrieve token API endpoint with a publishable key (see here).
My best guess is that it was an undocumented behavior that was removed at some point? Anyway, the API will reject this call with "This API call cannot be made with a publishable API key."
The README seems to suggest Stripe can be instantiated as a class with the publishable key and that createToken exists accepting a card and callback. I have found none of this in the Stripe Android library I installed in the manner described (i.e. compile 'com.stripe:stripe-android:+')
Stripe is an abstract class:
public abstract class Stripe
I have to set the apiKey thus:
Stripe.apiKey = "sk_test_FOO;
And creating a token offers no async callback:
Token token = Token.create(tokenParams);
I am wondering if it is me who has an older library (and thus the question is how would I get the latest) or whether the README is old.
Specifically I am not getting a CardException raised when using a Stripe payment expired card number from the test page when creating a token despite try/catching the Token.create - it goes ahead and creates a token.
i got error that Customer cus_id does not have a linked card with ID
**com.stripe.Stripe.apiKey = SECRET_KEY;
Map<String, Object> customerParams = new HashMap<String, Object>();
customerParams.put("description", "Customer111 for [email protected]");
customerParams.put("card", token.getId()); // Obtained in onSuccess() method of TokenCallback
// while creating token above
//Create a Customer
Customer cust = Customer.create(customerParams);
final Map<String, Object> chargeParams = new HashMap<String, Object>();
chargeParams.put("amount", 12000);
chargeParams.put("currency", "usd");
chargeParams.put("card", token.getId());
chargeParams.put("customer", cust.getId());
charge = Charge.create(chargeParams);**
Is the validation of Expiry Date only seek to look if it is a future date or it is actual comapre the values entered with the card real values ?
check the boolean validateCVC(); method. But in iOS SDK 3 digit CVV for AMEX cards are accepted.
refer: stripe/stripe-ios#299
Also, adding comments and a handful of formatting changes, setting public methods that don't need to be public to be package-private, and reordering methods for formatting (keeping the order public, package, private).
Just wondering if there was a mistake on this line
https://github.com/stripe/stripe-android/blob/master/stripe/src/main/java/com/stripe/android/model/Card.java#L19
or why is it that you are including 37
as a Diners Club
prefix if according to your source page https://en.wikipedia.org/wiki/Bank_card_number#Issuer_identification_number_.28IIN.29 it clearly exclude 37
For example, entering an incorrect CVC returns You did not enter a valid card.
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
When I downgrade to compile 'com.stripe:stripe-android:1.0.0', everything works ok. Any ideas? I have more details on this SO post: http://stackoverflow.com/questions/34844903/stripe-android-lib-1-0-3-upgrade-causes-execution-error
Can this be added as an Maven dependency? Or at least gradleise it, Eclipse is dead and importing as a library option is long dead for Intellij/AndroidStudio.
When using Stripe with Android Pay, MaskedWalletRequest needs stripe:version which is set to com.stripe.android.Stripe.VERSION. But this field is not available on version 2.0.0. Any help?
There is nothing more evil than public api with no documentation.
Can you start stubbing out what your Public API actually does?
requested by a user in IRC
in iOS version. we can use beautiful input view for typing credit card.
https://github.com/stripe/stripe-ios/tree/master/Stripe
but Android version is not.
Hi all,
I would like to use stripe.createToken in an Asynctask as I am creating the Stripe Token at the same time than other network requests.
I did look for a synchronous way to createToken but only the async mode seems to be available.
The issue is that when I try to use stripe.createToken in a custom Asynctask, it crashes. If I understood correctly the TokenCallBack expects to be in the UI Thread.
How could I do that?
Kin regards.
When requesting all orders, it's possible to add a data flag to get more information about the parent, using, for example
HashMap<String,String> data = new HashMap<>();
data.put("expand[]", "data.items.parent.product");
Usually the OrderItem object will have a member "parent" which is a String, which is the parent ID. However with the above flag we get back a more complex parent object.
There is no such complex parent object supplied in the models with this SDK, can you add this?
All in the title, you can no longer import this project into Android Studio.
I want to put my credit card creation inside an observable for testing purposes: and I get:
java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:62)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5694)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ExceptionInInitializerError
at com.stripe.android.Stripe$1.create(Stripe.java:22)
at com.stripe.android.Stripe.createToken(Stripe.java:144)
at com.stripe.android.Stripe.createToken(Stripe.java:127)
at com.stripe.android.Stripe.createToken(Stripe.java:131)
at com.pickupnow.customer.model.payment.PaymentService.lambda$createToken$59(PaymentService.java:30)
at com.pickupnow.customer.model.payment.PaymentService.access$lambda$0(PaymentService.java)
at com.pickupnow.customer.model.payment.PaymentService$$Lambda$1.call(Unknown Source)
at rx.Observable$1.call(Observable.java:144)
at rx.Observable$1.call(Observable.java:136)
at rx.Observable$1.call(Observable.java:144)
at rx.Observable$1.call(Observable.java:136)
at rx.Observable$1.call(Observable.java:144)
at rx.Observable$1.call(Observable.java:136)
at rx.Observable.unsafeSubscribe(Observable.java:7531)
at rx.internal.operators.OperatorSubscribeOn$1$1.call(OperatorSubscribeOn.java:62)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:200)
at android.os.Handler.<init>(Handler.java:114)
at com.stripe.android.compat.AsyncTask$InternalHandler.<init>(AsyncTask.java:579)
at com.stripe.android.compat.AsyncTask$InternalHandler.<init>(AsyncTask.java:579)
at com.stripe.android.compat.AsyncTask.<clinit>(AsyncTask.java:189)
at com.stripe.android.Stripe$1.create(Stripe.java:22)
at com.stripe.android.Stripe.createToken(Stripe.java:144)
at com.stripe.android.Stripe.createToken(Stripe.java:127)
at com.stripe.android.Stripe.createToken(Stripe.java:131)
at com.pickupnow.customer.model.payment.PaymentService.lambda$createToken$59(PaymentService.java:30)
at com.pickupnow.customer.model.payment.PaymentService.access$lambda$0(PaymentService.java)
at com.pickupnow.customer.model.payment.PaymentService$$Lambda$1.call(Unknown Source)
at rx.Observable$1.call(Observable.java:144)
at rx.Observable$1.call(Observable.java:136)
at rx.Observable$1.call(Observable.java:144)
at rx.Observable$1.call(Observable.java:136)
at rx.Observable$1.call(Observable.java:144)
at rx.Observable$1.call(Observable.java:136)
at rx.Observable.unsafeSubscribe(Observable.java:7531)
at rx.internal.operators.OperatorSubscribeOn$1$1.call(OperatorSubscribeOn.java:62)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
When I execute:
public Observable<String> createToken(String number, int month, int year, String cvc, String zip) {
return Observable.create(subscriber -> {
Card card = new Card(number, month, year, cvc);
card.setAddressZip(zip);
if (card.validateCard()) {
try {
Stripe stripe = new Stripe(BuildConfig.STRIPE_TOKEN);
stripe.createToken(card, new TokenCallback() {
@Override
public void onSuccess(final Token token) {
subscriber.onNext(token.getId());
subscriber.onCompleted();
}
@Override
public void onError(Exception e) {
subscriber.onError(e);
}
});
} catch (AuthenticationException e) {
subscriber.onError(e);
}
} else {
subscriber.onError(new InvalidCardException("Invalid card values"));
}
});
}
If a card is initialised with an invalid card number and updated with a valid card the type of the card will never get set e.g. Card card = new Card("1234", null, null, "");
and then updated using card.setNumber("3782 822463 10005");
Hi,Berg.
Why need Android API 17 ?
Are you using "addJavascriptInterface" in stripe-android?
i created a card token, but when i check the response i can't find the funding property. the funding property let me know if the card is debit, credit or prepaid.
The card.getType() is always returning null on android
Stripe stripe = new Stripe(getResources().getString(R.string.stripe_app_id));
stripe.createToken(
card,
new TokenCallback() {
public void onSuccess(Token token) {
// Send token to your server
activity.cardBrand = token.getCard().getType();
activity.userStripeId = token.getId();
}
public void onError(Exception error) {
// Show localized error message
}
}
);
Hi!
Could you please upload the latest release (1.0.1) to the maven repo such that it's available from the gradle build? Currently only 1.0.0 version is there:
http://search.maven.org/#browse%7C1181361068
Thanks in advance!
Proguard will mangle the class names in the stripe-java
API resource classes, yielding 404s upon token creation (among other things).
The docs should inform users to add the following line to their proguard.cfg:
-keep class com.stripe.** { *; }
hi @bct
i am using your code in eclipse and unfortunately i can not get class com.google.android.gms.wallet.fragment is there i missing something,then please guide me..
Thanks.
Everything is working fine. But I am not getting from where should i add price in source code?
Is there a full example of executing a charge on android? It seems that there are multiple models at play here and they don't play nice with each other.
I have added this line in my build. project as described in your doc.
compile 'com.stripe:stripe-android:+'
I am getting this kind of error. why I got this? which version of your library for android working now?
Error:(14, 13) Failed to resolve: com.stripe:stripe-android:+
I've added compile 'com.stripe:stripe-android:+'
into my gradle dependencies and sync the gradle. After that I tried the codes from the doc. Unfortunately, the class Card
had no contructors(only default contructor is available). I am stuck there and not sure about how to proceed with the integration. Am I missing something in the steps or doc is no more valid.
Hello!
I have been looking and can't find anything on it. Are there any code snippets/models to implement withdrawal for users in Android?
Much oblidged.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.