Thank you for the 2.x branch of this module. It's a really clever approach, and I'm already using it and find it quite useful.
While the initial integration with the Stripe.js works, there are some edge cases that the Stripe integration breaks.
In js/uc_stripe.js, there are some workarounds to remove the name attribute of the credit card number and security code. This uses HTML IDs, but since the payment pane is Ajax-dependent, its HTML ID tend to get updated for every Ajax call. Also, the form element itself has an ID, that can be changed with Ajax calls.
For example cases, please consider these two:
- Complete the checkout page as usual, and then, click "Back" button from the Review page (/cart/checkout/review)
- In the checkout page, change the "Country" field to a different one. There will be an Ajax call to change the address form, which also changes the payment page.
- Also removes the "Last 4" text, which Stripe.js sometimes replaces the credit card number field value with. Since the token is created every time, user must re-enter the card details.
Stripe.js adds some Stripe-specific elements, which are fine to be used. However, without using HTML classes/name attributes, it is not really possible to get uc_stripe to working with the Ajax edge cases.
Attached patch works around this.
- Now uses the form class instead of the form tag's ID (fixes the submit button event attachments).
- CC and CVV numbers are saved to a JS variable, so it can be detected later.
- Uses wildcard ID selector, to allow Drupal to change the ID (element, element--1, element--2, etc all get selected).
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | uc_stripe_http.png | 40.28 KB | ayesh |
| #2 | ajax_calls_break_the-2565303-2.patch | 3.03 KB | ayesh |
Comments
Comment #2
ayesh commentedComment #3
ayesh commentedthe patch above is not letting Drupal see the CC number or CVV, just the way it was working before.
Comment #5
rfayAwesome, and thanks so much for the excellent patch. I reviewed and tested the code and I like it, thanks very much. It fixes problems that result from Drupal validation errors as well, and getting rid of the "Last 4" was a good thing.
Thanks so much for your collaboration on this!