• Resolved crackajax

    (@crackajax)


    Greetings,

    I am using the filter, add_filter( ‘wc_stripe_force_save_source’, ‘__return_true’ );, because I need to have the checkbox for “SAVE PAYMENT INFORMATION TO MY ACCOUNT FOR FUTURE PURCHASES.” on the checkout page to be checked by default. The customer is buying into a monthly order system that automatically creates the order and charges the customer each month.

    However, this filter does not default the save payment checkbox to checked and we are having to login as customer and charge their card manually.

    Is this still the preferred way to set the Save Payment checkbox to checked? If not, what would be the best way to accomplish this programmatically? If so, what might cause it to not be working?

    Thanks in advance for your help.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Doug – a11n

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @crackajax

    The customer is buying into a monthly order system that automatically creates the order and charges the customer each month.

    Can I asking what you are using for this process?

    Thanks,

    Internal ref p7bbVw-3cQ-p2

    Thread Starter crackajax

    (@crackajax)

    @dougaitken I am using a cron job the 1st of each month to create a preselected assortment of products to build an order and using Stripe API to charge payment. It has been running for a year without problems other than the forced save card issue. Does that answer your question?

    Plugin Support Doug – a11n

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @crackajax

    Thanks for confirming.

    It looks like something may not be working with your custom code.

    I have confirmed this custom code is working when the Customer is either logged into a registered account or an account is being created at checkout.

    You can see this in action here – https://dev.doug.press/

    * Place an order and check the box to create an account at checkout
    * Don’t select the same payment method button
    * Use 4242 test card or another Stripe test card and remember the expiry and last four – https://stripe.com/docs/testing#cards
    * When order is placed, navigate to https://dev.doug.press/my-account/payment-methods/ and you’ll see the card is saved

    If the customer is a guest this won’t work since there is no account to save the card details to.

    Thanks,

    Thread Starter crackajax

    (@crackajax)

    @dougaitken I have deactivated all plugins except Woocommerce and the Woocommerce Stripe addon. I activated the Twenty Twenty theme and added the filter to the functions.php. With this very simple setup I am still not getting this to work. So, perhaps I am testing it incorrectly. Here are my steps:

    1) Add product to the cart.
    2) Go to checkout.
    3) Login with my test user.
    4) Check the Save payment information to my account for future purchases. checkbox to be checked, but it is not.

    I do have Stripe in test mode. I have verified that the Enable Payment via Saved Cards under the Stripe Payment settings (Woocommerce >> Payments >> Stripe >> Manage) is checked. There is no custom code in this scenario, just WordPress core, Twenty Twenty them (with the inserted filter below), Woocomerce & Stripe plugins.

    So, should the checkbox be checked automatically when using the add_filter( ‘wc_stripe_force_save_source’, ‘__return_true’ ); filter? Or, does this not work if Stripe is in test mode?

    Any ideas or leads for further investigation are appreciated.

    Thanks,

    Plugin Support Doug – a11n

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @crackajax

    I have done all my testing with my Stripe payment gateway in test mode so it does work.

    So, should the checkbox be checked automatically when using the add_filter( ‘wc_stripe_force_save_source’, ‘__return_true’ ); filter? Or, does this not work if Stripe is in test mode?

    To confirm – the checkbox WON’T be checked at all. The card being saved to the customer account is done without this intervention.

    Yes, the “Enable Payment via Saved Cards” should be checked, the custom snippet added, and the card will be saved for a registered user.

    Have you gone through the full checkout flow as a customer to see if the card is added?

    If you’d like to try this on my test site, follow the details I gave previously.

    I can confirm that the filter is working as expected so if this isn’t working on your implementation, this would be related to something specific to your site.

    Thanks,

    Thread Starter crackajax

    (@crackajax)

    @dougaitken thanks so much! I have been testing to there expecting the checkbox. It is the client’s Stripe account, and I don’t have access there to verify the customer creation. I will setup my own Stripe account on the dev site and verify that way. Thanks again!

    Plugin Support Doug – a11n

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @crackajax

    As a note – you can create a test customer on the site, no need to access the Stripe.com account, the card details would be save to the my-account/payment-methods page when viewing as that test Customer.

    I’ll mark this thread as Resolved for now – please do create a new one or reach out via WooCommerce.com for anything else.

    Thanks,

    Thread Starter crackajax

    (@crackajax)

    @dougaitken I have had the client check her Stripe for the actual customer account creation and if they see the credit card on the account. As it turns out the customer account was created and a credit card is present for the two customers whose accounts failed on the automated order. Their accounts were created on the day they setup their Woocommerce accounts on the site. The automated orders take place on the 1st of each month thereafter.

    For the existing customer in the program prior to these two new ones, their card gets charged and the order created. But the new customers who are buying in (simply by buying a tagged product in the Woocommerce shop – nothing custom going other than setting a user capability when purchasing a certain item), even though their customer account is created in Stripe, and the credit card associated, the _stripe_customer_id is not being set in the WordPress user_meta table.

    I am checking in my custom code for the Stripe token before hitting the API and if not found for the customer ID, it logs the error, User has no credit card on file, and returns. So, does the filter, add_filter( ‘wc_stripe_force_save_source’, ‘__return_true’ );, trigger the creation of the Stripe token? Should it be stored by the plugin as part of the transaction?

    Thanks.
    Crack-Ajax

    • This reply was modified 3 years, 10 months ago by crackajax.
    • This reply was modified 3 years, 10 months ago by crackajax.
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Forced Save Card (Customer Creation) Not Working’ is closed to new replies.