Add subscription record to woocommerce - php

I have installed woo-commerce subscriptions on my word-press site, integrating a payment gateway for checkout. The gateway is not supported by woo-commerce directly.
I have the checkout page and the payment processing page with code provided by the gateway to process the online payment.
I need to update the subscription status for the customer once his payment has gone through successfully via the gateway and the confirmation is received back.
Any pointers on how to update the subscription record in woocommerce subscriptions using a php code snippet would be very helpful.
I have searched around and found links on how to add a product in woocommerce, but not much on how to update or add a subscription record using a custom php snippet.

The solution is to create an order, then create a subscription, link the order to the subscription using woocommerce classes. A very helpful link found on SO outlines the steps:
wordpress.stackexchange.com/questions/202873/
The response given by Jeremy Warne worked for my website's logical flow.

Related

How to handle payments with Wordpress WooCommerce Mollie REST API

I am wondering how to implement payments in Flutter(or any other framework, like react or angular).
There is an existing website built in Wordpress and WooCommerce. The following plugin is used:
WooCommerce
Mollie payments for woocommerce (https://nl.wordpress.org/plugins/mollie-payments-for-woocommerce/)
How can I handle a payment, that matches the order id and moves the user to the payment banking screen?
When a user presses the "Checkout" button in the frontend, do I need to do the following?
Call a custom function that was made in Wordpress PHP (wp-json/payment/create)
Call the woocommerce endpoint create order in that PHP function. https://woocommerce.github.io/woocommerce-rest-api-docs/#create-an-order.
And then call the mollie endpoint create payment in that PHP function? https://docs.mollie.com/reference/v2/payments-api/create-payment. Put order id in parameters that I received from the woocommerce endpoint.
Then return the redirect link to the react or flutter app
How can I know that the payment is succesful? Then I can call 'update order' and set the status from 'waiting for payment' to 'processing order'. (So Wordpress admin can see that the customer paid.
I could not find a tutorial on this topic and therefore I decided to make this question public. I only saw wordpress tutorials... So I hope this question can help a lot of people.
How far are you with this? Because I don't know if using the regular mollie plugin is going to help out.
Mollie has documentation on how to also implement their api on JS framework.
The question you need to answer first is:
Are you able to create an order using the WooCommerce API. So can you order a product, without actually using a payment gateway (the add to cart to checkout flow)?
Have you tried using the Mollie nodejs version?
A tip:
Any payment gateway(stripe, mollie etc) add the order_id as meta_data on a order. So after going through the payment flow the order has to be created, with the right payment_id + the status (failed, pending blabla).
Edit:
Another option could be to create custom endpoints which loads something like this: https://github.com/mollie/mollie-api-php
So maybe something like:
create the order using the woocommerce api
after creating the order, return to the js app and then trigger another endpoint
this endpoint would load the custom Mollie api
I hope this makes sense?

Enable a payment gateway only if the customer couldn't complete the order with another gateway in woocommerce

I have a woocommerce subscription website with two payment gateways (one is recurring and the other is manual). All my subscriptions are auto-renewable. What I'm trying to achieve is that the customer cannot use the manual payment gateway unless the order status changes to pending/failed for that order. So if the customer couldn't complete the order using the recurring gateway and visit the checkout page again, then they should be able to see the manual payment gateway option on the checkout page and pay using it. Is it possible? How can I achieve that? Thanks in advance.

how to call eway payment gateway form on different location

I have install woocommerce in my wordpress application and also install eway payment gateway plugin. it is showing perfect on my default checkout page.
But i want to call it on different location ( i have donation page in my application and want to use eway there as well) as I am new to wordpress got stuck very badly.
please give me suggestion whatever possible and ask me for code if you want any.
Basically, you can't use eway payment gateway without e-commerce plugin. Which means you need product :), and you can't consider a donation as a product at all. I am sure that you have installed the plugin for Woocommerce only. To integrate eway on donation page you need to use eway API. here is the reference for the same.
https://www.eway.com.au/developers/api

WooCommerce Subscription - PayPal Reference Transactions

I am using woo commerce subscription plugin and integrate pay-pal as a payment method. We are selling one subscription which is monthly based.
My issue is that, in Subscription Product, we received payment through pay-pal but Subscription from woo commerce did not activate.
After doing some research I integrate API Credentials, but now I am getting error about reference transaction.
I am getting below error.
PayPal Reference Transactions are not enabled on your account, some subscription management features are not enabled. Please contact
PayPal and request they enable PayPal Reference Transactions on your
account.
Now I am getting confused that how to set billing agreement, how to set pre-approval payment. where we need to set on pay-pay or on our website. When we called to pay-pay they are saying that Reference Transaction is active on your account.
Thanks in advance
I'm going to assume this is for PayPal Express Checkout; by default Reference Transactions is "not" enabled on any account. However it can be added by request if you call the business support line to get it added.
The steps are described by WooCommerce on how to get this feature added.
Hope this helps 8^)

Paypal Third Party Shopping Cart Retrieve Information

Hi I'm creating a third party shopping cart using paypal for my client and i need retrieve some information after the payment is confirmed. I need to send an email to the seller with the product information like color, font-family, font-size, size of the product. But i have no idea of how can i retrieve the payment confirm information from paypal and then send to the seller this email.
Does someone knows how or just could give me a hint?
Thanks.
If you're not on wordpress, you can still use IPN data: have a read here: https://developer.paypal.com/webapps/developer/docs/classic/products/instant-payment-notification/
Note that Paypal's example code is not very good, and also that their IPN simulator is not currently working properly: Paypal IPN continually returns invalid from Sandbox
The PayPal IPN for WordPress plugin will make that very simple for you.
Just install the plugin and create a basic hook in your theme's functions.php file (or create a simple custom plugin file). The plugin has hooks so you can trigger based on any IPN, or based on the IPN transaction type or payment status.
Here is a link to the general dev guide and another link specific to the hooks available.
You could have the IPN solution working and sending an email within minutes, so then it's just a matter of building your email body the way you want.

Categories