Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit a credit card using Stripe checkout.js

Checkout from Stripe has a great way to add a credit card for a transaction, by simply invoking StripeCheckout.open().

Stripe checkout

Is it possible to use .open() to edit a card? (passing in the card token)

Also, where can I download a non-minified version of checkout.js to see the .open() method signature?

like image 437
Nelu Avatar asked Mar 04 '15 22:03

Nelu


People also ask

How do I change my credit card info on Stripe?

Add a Credit Card You can locate an existing customer by searching by email address or customer ID on your Stripe Dashboard. To add a new card, navigate to the Customer screen for the customer on your Stripe Dashboard: Under “Cards” click “Add Card” Enter the credit card information and click “Add Card”

Can you customize Stripe checkout?

You can customize the look and feel of Checkout in the Stripe Dashboard. Go to Branding Settings where you can: Upload a logo or icon. Customize the Checkout page's background color, button color, font, and shapes.

Can I process a credit card through Stripe?

Stripe's payments platform lets you accept credit cards, debit cards, and popular payment methods around the world—all with a single integration. Get access to advanced payments features like 3D Secure 2 authentication, card updates, automated retries, and more.


2 Answers

There is no way to edit a card that way. What you can do though is use Stripe Checkout to ask your customer for a new card without asking him to pay anything. The idea is to avoid setting the amount or data-amount parameter.

<form action="/charge" method="POST">
  <script
    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
    data-key="pk_test_XXX"
    data-name="Demo Site"
    data-description="Update Card Details"
    data-panel-label="Update Card Details"
    data-label="Update Card Details">
  </script>
</form>

You would get a new card token for that new card and you could then use the Update Customer API to save the new card on the customer.

As for your second question, there is unfortunately no unminified version of Checkout.js accessible at the moment.

like image 135
koopajah Avatar answered Oct 24 '22 01:10

koopajah


Try http://unminify.com/ to see an unminified version of checkout.

I saw this done for the first time today. If you have an app where users log in, you should be able to do it with a custom Checkout integration (the above is the simple integration) found here https://stripe.com/docs/checkout#integration-custom

On the server side you would retrieve the customer via Stripe's API. From the linked custom example, you can pass the retrieved ID through to Checkout via session data so it knows which customer to update here:

$('#customButton').on('click', function(e) {
// Open Checkout with further options
handler.open({
  name: 'Your Company Name',
  email: customer_email,
  id: customer_id,
  zipCode: false,      
  });

I have not yet tested this, if I get a chance I'll report back.

like image 33
cleetus Avatar answered Oct 24 '22 02:10

cleetus