WooCommerce Subscriptions: Changing payment method of existing subscription - wordpress

A client of mine wants to change payment service provider in his WooCommerce store. He has a few hundred existing subscriptions that need to be transferred to this new PSP. Basically, everything is done in order to do this, except for the configuration in WooCommerce. WooCommerce needs to know to use the new payment plugin's code to renew subscriptions. I know of the existence of this integration method but that's not the issue. That integration allows you to add the required metadata to orders (like credit card tokens) in the WooCommerce UI. That has already been done. I changed the _payment_method post meta of a test subscription to my payment method identifier and I set _requires_manual_renewal identifier to false however, for some reason in the UI it still says Manual Renewal under payment method.
What things do I have to change in the database in order to change the payment method?

Related

Recurring and non-recurring items in single PayPal checkout flow

I'm currently migrating a website from WooCommerce to Shopware 6, which needs to support recurring payments for a membership subscription.
WooCommerce is still using PayPal Standard, which allows you to mix non-recurring line items with a recurring subscription, in a single checkout flow.
Shopware 6 uses the REST API, which doesn't appear to support this ability and the only solution appears to be using the Javascript SDK:
User clicks Pay with PayPal.
Subscription is created via actions.subscription.create
Dialog is displayed requesting approval.
Customer approves.
Submit original checkout.
Redirect to PayPal.
Complete payment.
Redirect back to website with confirmation.
A potential solution I'm looking into now is changing the return URL of the initial order creation to redirect to a billing agreement approval URL and have the return URL's of that redirect back to the original return url.
Overly complicated and the worse UX I've ever seen.
Before I tear what's left of my hair out, does anyone have any suggestions?
UPDATE
Although it isn't the solution I was hoping for, I ended up removing the Shopware 6 PayPal plugin and implementing my own payment method using the NVP API.
From the user perspective, there is only one approval process. In the backend, once the user has approved the transaction (that has been marked as needing a billing agreement) the transaction is verified and then a recurring profile is created.
There's no way to combine Subscriptions and one-time payments in a single checkout. Such items even require different parameters on the PayPal SDK line, if using the PayPal buttons to show an in-context experience.
The in-context experience is best, since it involves no redirects away from your site to PayPal and back. Here is the flow for one-time payments:
Make two routes on your server, one for 'Create Order' and one for 'Capture Order', documented here. These routes should return only JSON data (no HTML or text). The latter one should (on success) store the payment details in your database before it does the return (particularly purchase_units[0].payments.captures[0].id, the PayPal transaction ID)
Pair those two routes with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server
A similar (separate) flow can be used for PayPal Subscriptions. Only one subscription can be approved at a time.

Custom PayPal Checkout for subscription plan

I want to build a custom PayPal checkout for a single product (subscription plan).
On successful purchase I need to save the current date +30 days to the user profile as well as upgrade the user role to "premium". This part is no problem but I'm having trouble finding how and what I need to use from PayPal.
Could someone point me in the right direction? Is the PayPal IPN service still a thing, or is it legacy?
I checked out some PayPal WordPress plugins but they offer too much esp. an own member solution or integration with WooCommerce, which I don't need. I only need a plugin that handles the checkout and gives me the chance to hook some custom actions on some events for example the successful purchase.
There's no reason to use something old like PayPal IPN. Use the current Subscriptions API, and webhooks for event notifications.
Subscriptions are documented here: https://developer.paypal.com/docs/subscriptions/integrate/
And to subscribe to webhooks for later event notification, see webhook event names for subscriptions.
The Webhook documentation mentions using REST SDKs. Those SDKs are deprecated, use HTTPS API calls.

Migrating customer stripe payment data from Squarespace to Woocommerce

I am migrating a website that offers subscription services from Square Space to Woo Commerce. Both platforms were configured using our Stripe account.
I am trying to figure out if we can migrate our existing customers into the new Woo Commerce app, so that it will use the same payment information that is already stored in Stripe. Basically we do not want existing customers to have to re-enter their payment information as we know we will lose some customers during this process.
On the Square Space side of things: whenever a new customer is created they create a customer in Stripe, then make a request to the Payment Intent API, associate the intent token to the customer, and then use this to charge the customer every time a payment is due.
On the Woo Commerce side of things: we are using the official Woo Commerce membership and subscription plugins. Whenever a new customer is created, a customer is created in Stripe, a payment method is attached to that user, and then that payment is used to charge the customer.
So my question for anyone who has a deep understanding of WooCommerce, is there a way to update how Woocommerce is integrating with Stripe to try and use the payment intent API tokens that we already have for these existing customers?
As long as these Customers were created under your account, you should be able to leverage them.
As a small correction, you would not be referring to existing Payment Intents, but rather existing Payment Methods attached to the Customer. You could, for example, retrieve these for any customer from the API and then use one of them to create a new Payment Intent.
Whether WooCommerce needs to do anything to be aware of these existing Customers or Payment Methods I can't say, but you should contact them for support about that.

How to notify .net api from WordPress WooCommerce when there is a new order

I have .net webapi that also integrated with WooCommerce .NET wrapper. Also I have a WordPress store runs on WooCommerce.
What I am trying to do is, as soon as there is a new order on the website, I want to notify my webapi with that order so I can save that order on other application.
I am able to use WooCommerce api to get orders, products etc.. but I want that the WooCommerce api post me the data when there is a sale. Or at least notify me with order id so I can go ahead and get that order with that order id from my .net application.
I have searched a lot but all I find is consuming the WooCommerce api. But I couldn't find anything that WooCommerce notifies my api.
I also checked the web hooks, but I didn't get it. There is a delivery url. From my understanding, for a created action, it hits that delivery url, but what it posts? Json object? I couldn't find any explanation for that. I am kind of new to WooCommerce.
Is this possible? Is there any example for this or any documentation about what I am trying to do.
You can use the following code in your WooCommerce store/setup (theme's functions.php preferable).
// add the action
add_action( 'woocommerce_new_order', 'action_woocommerce_new_order', 10, 3 );
function action_woocommerce_new_order($order_id){
// Do what ever with the order id, send mail or call your API
}

Add user on UrBackup server after order on Woocommerce site

I have wordpress site with woocommerce shop and I’m selling among others UrBackup client accounts on my server.
Do you have any idea how to automatically add UrBackup user after order in woocommerce?
Or maybe easier will be create shop based on different engine?
Any advice, tips? :)
After poking around a bit, it looks like UrBackup has an API you can use, that most likely has a 'create account' endpoint. I didn't see it immediately in their not-so-great documentation, but you'd think it'd HAVE to be there somewhere! There's also a PHP API kit you could integrate into your WordPress site here:
https://bitbucket.org/opensaucesystemsdevelopment/urbackup-api.git
So, you could load in this class, and after a WooCommerce order is placed, call the API endpoint to create a user. To do this with WooCommerce, you'd need to create a function on the "woocommerce_order_status_completed" hook.
http://hookr.io/actions/woocommerce_order_status_completed/
This would let you run any custom code you'd like after an order's payment has completed. Thus, you could check an order for if it contains the UrBackup product, and if so call the UrBackup API to create an account based on the current user's data.
Should work!

Resources