Custom PayPal Checkout for subscription plan - wordpress

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.

Related

Send API after payment completed WooCommerce

I have an e-commerce on Wordpress where I put my products for sale through WooCommerce and a demand arose for an advantage club where, after payment was made, it would send data to an API to create an account on a platform and when is no longer paid to be deactivated by the same API. How can I do this? Is there any way?
I looked for documentation on the internet but I couldn't find much.
You can use, a hook that runs when an ordered is marked as completed:
woocommerce_order_status_completed
if that doesnt work for you, you need to check the payment gateway provider, to see what hooks they offer

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.

Send email to customer when Subscription is Cancelled, Expired or Suspended

Using latest WooCommerce and WooCommerce Subscriptions and WooCommerce Membership plugins!
By default WooCommerce Subscription plugin sends emails about subscription cancellation, expiration and suspention just to admin, what is really strange. I think that customer should be informed about these actions. Therefore question - has anybody hooked it that such emails are also sent to customers?
Had not find any usefull solution so far for this issue...
to achieve what I want - decided to use this plugin: https://automatewoo.com/.

WooCommerce Subscriptions: Changing payment method of existing subscription

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?

Woocommerce orders not being received by PayPal, but email suggests otherwise

Having a nightmare with this and cannot find a solution anywhere - the only similar issues I find are the exact opposite problem!
Placing an order using PayPal (standard) at checkout puts the order 'On hold' in wp, but completes on the front end and the user even receives the PayPal receipt so are none the wiser. In the PayPal business account there is nothing.
Interestingly, PayPal express checkout works fine! So the account is definitely setup correctly. Something I have noticed is that the receipt from the express checkout transaction and from the standard have different Merchant names - the standard one (the one not working)has the name#emailaddress.com rather than the merchant name. This would suggest that this is the issue, but I've been into the business settings and checked this as well as the Woocommerce settings and everything is in order.
Any ideas? Thanks in advance!
For Woocommerce PayPal standard you have to enable Auto return url and Notification url(Instant payment notification) which will update the order status on your woocommerce. Refer the following URL link: https://docs.woocommerce.com/document/paypal-standard/ and enable both Auto return & Instant payment notification settings on the Merchant/Business PayPal account. Please note that Merchant PayPal account is not linked with any other website.
PayPal Express checkout is recommended: https://woocommerce.com/products/woocommerce-gateway-paypal-express-checkout/
I would recommend you just stick with Express Checkout. It has many more features and options than PayPal Standard. I would recommend the PayPal for WooCommerce, though, which is the one PayPal reps would recommend as well if you talk to them.

Resources