woothemes/woocommerce — pull request #4054 by thenbrent (2013-11-04 01:03:23+00:00)
Title: New "Add Payment Method" Feature

First draft for #3396

#### Overview:

1. Adds a Add Payment Method page under checkout (endpoint: /checkout/add-payment-method): http://cl.ly/image/1J262h1E0x3s
1. Redirects to the My Account page after successfully adding a payment method: http://cl.ly/image/3H3I3L3l0m2m
1. Display Add Payment Method page if something went wrong (Stripe specific): http://cl.ly/image/2v363s1F0O02

#### Testing Notes:

1. Can test with Stripe from: [thenbrent/woocommerce-gateway-stripe/add_payment_method](https://github.com/thenbrent/woocommerce-gateway-stripe/tree/add_payment_method)
1. To start the process, visit: example.com/checkout/add-payment-method/ (no button for it yet)
1. Enter the new card's details & click "Add Payment Method"

#### Questions:

1. Where do we want to display the "Add Payment Method' button? The most logical place would be next to existing cards section, but there is no central/default saved cards section yet.
1. Do we want to use a `$gateway->supports( ‘add_payment_method’ )` flag or just check if the class has the required `add_payment_method()` function?
1. Should the page be added under the "Checkout" or under the "My Account"? In some ways, the My Account makes more sense, for example, the save duplicating the `is_user_logged_in()` check and as they are adding the card to their account, in other ways, the checkout parent makes sense as it's so similar to the Pay page.
1. Do we want to give a new ID to the "Add Payment Method" `

`? At the moment, it’s using `#order_review` to match the `form-pay.php`, which means most gateways won't require any changes their checkout JS.

#### Notes for Payment Gateway Integration:

These [two commits](https://github.com/thenbrent/woocommerce-gateway-stripe/compare/a2900cea128c57b9...2aa5b83297) show what was needed to add support in Stripe.

Just need to add a new `add_payment_method()` function & declare support for `'add_payment_method'`.

For Stripe, we also didn’t want to display existing cards on the "Add Payment Method" page, so for that, I used the `is_add_payment_method_page()` function, like this: https://github.com/thenbrent/woocommerce-gateway-stripe/commit/344d8038c33f84e14914ef50550de1c78da2dc24

#### Other notes:

It would be cool if we could use an "Info" notice (like the coupon/login box on the checkout page: http://cl.ly/image/3D220M2d1R3G) rather than the "confirmation" message used by default: http://cl.ly/image/1y3m0z3Z2P3U But that would require changes to `add_message()` function, beyond the scope of this patch.