Stripe.js: request for a data-stripe=exp attribute

1,057 views
Skip to first unread message

Ryan McGeary

unread,
Aug 21, 2014, 1:28:28 PM8/21/14
to api-d...@lists.stripe.com
Stripe.js has support for automatically reading input fields that adhere a set of `data-stripe` attributes.  

This is great, but when combined with Stripe's jquery.payment plugin for auto-parsing a combined MM/YY field, it looks like we lose an easy means of just pointing createToken at the form element itself, because createToken relies on exp-month and exp-year separately.

Instead, we must manually construct params for the createToken function.

Is it true that Stripe.js doesn't handle a combined MM/YY "exp" field? If not, please consider this a Stripe.js feature request.

Ryan

Jim Danz

unread,
Aug 21, 2014, 7:13:45 PM8/21/14
to api-d...@lists.stripe.com
Hi Ryan,

Thanks for the note on this. You are correct that Stripe.js doesn't
handle the combined field. Passing this along to the team!

Jim
> --
> You received this message because you are subscribed to the Google Groups
> "Stripe API Discussion" group.
> To post to this group, send email to api-d...@lists.stripe.com.
> Visit this group at
> http://groups.google.com/a/lists.stripe.com/group/api-discuss/.
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to api-discuss...@lists.stripe.com.

Brian Ross

unread,
Aug 22, 2014, 2:59:30 PM8/22/14
to api-d...@lists.stripe.com

jquery.payment does split the date. I found the code by accident since it's not documented.


Example code I use:


$('#payment-form').submit(function(e) {
    expiration = $('.cc-exp').payment('cardExpiryVal');
    Stripe.card.createToken({
        number: $('.cc-number').val(),
        cvc: $('.cc-cvc').val(),
        exp_month: (expiration.month || 0),
        exp_year: (expiration.year || 0)
    }, stripeResponseHandler);
    return false;
});


From: api-d...@lists.stripe.com <api-d...@lists.stripe.com> on behalf of Ryan McGeary <ryan.m...@gmail.com>
Sent: Thursday, August 21, 2014 10:28 AM
To: api-d...@lists.stripe.com
Subject: [stripe-api-discuss] Stripe.js: request for a data-stripe=exp attribute
 

Ryan McGeary

unread,
Aug 23, 2014, 9:37:46 AM8/23/14
to api-d...@lists.stripe.com
Brian,

That's pretty much my point. jquery.payment (authored by Stripe) supports a combined expiration date, but Stripe.js does not. Your code looks almost identical to what we have in our application. My point is that this code shouldn't be necessary. It would be nice if we could use Stripe.js's form handler (using data-stripe attributes) instead. For example:

$('#payment-form').submit(function(e) {
  Stripe.card.createToken($(this), stripeResponseHandler);
  return false;
});

-Ryan

Stephen Nancekivell

unread,
Oct 16, 2014, 8:00:04 PM10/16/14
to api-d...@lists.stripe.com
+1,

This is weird.

Stacey Irvin

unread,
May 12, 2015, 3:45:46 PM5/12/15
to api-d...@lists.stripe.com
+1

Craig McKeachie

unread,
Jun 5, 2015, 3:02:34 PM6/5/15
to api-d...@lists.stripe.com
+1 for me as well, please fix this.

Zachary Klein

unread,
Aug 5, 2015, 2:06:04 PM8/5/15
to Stripe API Discussion
+1 - this is a real snag. At the very least the workaround needs to be documented somewhere.


On Thursday, August 21, 2014 at 12:28:28 PM UTC-5, Ryan McGeary wrote:

Craig McKeachie

unread,
Aug 6, 2015, 1:21:48 AM8/6/15
to api-d...@lists.stripe.com
I just noticed the other day the way it is handled in the embedded form that Stripe generates for you.  They have two select lists on the page that are absolutely positioned off screen.  So these include the needed inputs on the form.
element.style {
  1. positionabsolute;
  2. left-10000px;
}



--
You received this message because you are subscribed to a topic in the Google Groups "Stripe API Discussion" group.
Reply all
Reply to author
Forward
0 new messages