Recurring and non-recurring items in single PayPal checkout flow - woocommerce

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.

Related

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.

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?

Paypal website payment standard not returning to return url from Sandbox test account

I am using Paypal Website Standard integration with Asp.Net and my problem is even after payment is successful, paypal is not returning me to my thank-you.aspx page. I have already set return-url in code as
sbForm.Append("<input type=\"hidden\" name=\"return\" value=\"" + successUrl + "\">");
means, I have created form mark-up using Code-Behind. Success url is absolute reachable (I can copy url and paste in browser, it works). I have my sand-box settings as below:
Profile -> Selling Tools
Under Selling Online -> Website Payment Preferences
Auto Return: On
Return URL: http://mywebsite/thank-you.aspx
Payment Data Transfer: Off
PayPal Account Optional:On
Contact Telephone:Off (PayPal recommends this option)
Support giropay and bank transfer payments:No
However it return to cancel page without fail if I cancel payment.
Edit
Taking reference if this, I set PayPal Account Optional:Off but no luck.
Edit
When I click the link after payment success message on Paypal's success page, I can go back and debug but it not returning any QueryString with the key name tx which results always Fail\n response.
With Payments Standard, enabling auto-return with a return URL should redirect, but it can sometimes take up to 10 seconds or so for the redirection to happen. That's why there is no guarantee users will make it to your thank you page even when it's all configured and working well.
If you need to ensure users end up at your site and there's no chance they wouldn't reach your thank you page then you'll want to use the Express Checkout API instead of Payments Standard.
The Express Checkout flow doesn't get completed until the user is back at your site (where you make the final API call) so you can rest assured you'll always end up on your thank you page.
Even still, if you're trying to automate procedures like updating your database, sending email notifications, etc. you'll want to use Instant Payment Notification (IPN).
IPN's are triggered instantly, so you can automate procedures in real-time. It also allows you to handle things like pending payments that have cleared (which you wouldn't want to deliver or ship right away), disputes, refunds, etc.
Turned Payment Data Transfer On and get it worked

Pass dynamic querystring to paypal continue page

My website is in Asp.Net C#.
I am using paypal for my website. i have multiple products like logo design, brochure design etc. I am using different BuyNow button for each service.
After successful payment i am sending user back to my continue.aspx page.
But I am just confused about 1 thing that are we able to receive OrderId to my continue.aspx page anyhow? I have to fetch details of that particular order on the continue.aspx page to add more design descriptions like company name, requirements etc.
Is there any way to receive my orderId as a query string on my continue.aspx after successful payment?
Are you using Website Payments Standard or Express Checkout? It sounds like you are using Express Checkout, but if your using standard you may want to switch over to Express Checkout as you will have more control over the checkout flow. With Express Checkout when the buyer is sent back to your site after they have agreed to the payment your site will perform a GetExpressCheckoutDetails API call. You will get the buyers information with this API call. From there you can then present the buyer with the additional options and etc before performing the DoExpressCheckoutPayment API call which is the API call that actually charges the buyer.

paypal buy it now button process flow

Im adding paypal payments to my site via a buy it now button, which as i understand it posts a form to paypal then the user completes payment on paypal's site.
To process the order after payment is confirmed im using an IPN listener, but id like to do some processing on our server at the time of ordering too. Is it possible to have the buy it now button submit to our own server first so i can record the order, before redirecting to paypal for payment details?
You have two options here.
First option that is more simple but can fail if the user did not have javascript, is to make a post to your server with what data you like, with ajax, and only after the return you let the user continue the submit.
Second option is to post your data to your server on code behind, there you prepare a simple page with auto submit to paypal - actually you make a redirect with post. Here you can find source code and one example on how to make it:
http://www.codeproject.com/Articles/37539/Redirect-and-POST-in-ASP-NET
Actually, you have many options.
As you said, the buy now button is nothing more than a form post to PayPal. You can build your own form using any of their standard variables rather than be limited to these buttons. They call this the cart upload method.
With this method you can do whatever you need to do whatever local processing you need to do prior to ever sending the user over to PayPal. It's a good practice to create an order record of some kind in your own system which you can then include with your PayPal payment info. That same value will come back in IPN so you can process it post-payment as well.
Another option that would you open you up even more is to use the Express Checkout APIs. This gives you complete control of your checkout system and has more features than standard payments. I recommend this if you're familiar with web service APIs.
Of course, IPN works with Express Checkout, too, so you can still use that for whatever you want/need as well.

Resources