Woocommerce + Snapscan and Payfast Integration

AntennaMan

Expert Member
Joined
Apr 17, 2014
Messages
2,310
Hi everyone

I hope someone here can point me in the right direction.

I have a small store set up in Woocommerce and I have integrated Snapscan and Payfast as payment methods.
The only problem is that I can't seem to get it set up to change the order status to complete after payment has been made. I receive email notification that payment has been made, whereafter I need to login to my site and manually change the order status to "Completed". I need a way to do this automatically.

The snapscan api documentation is a bit fuzzy on this, but from what I gather I need to set up a webhook to handle this. In Woocommerce I can see where to set up the webhook, but I'm not sure about the URL needed and what else I need to do on the backend to process this.

The same goes for Payfast. They have an option to set a instant transaction notification URL (ITN Callback), but again I'm not sure how to implement this on my website.

And just for info, I'm not a web developer. I know the basics of php, html, etc, just enough to at least understand that I don't know enough :)

Any help will be appreciated.
 

Thor

Honorary Master
Joined
Jun 5, 2014
Messages
44,236
Does the payfast plugin not have some sort of setting? I assume you checked, but just want to make sure.
 

rward

Senior Member
Joined
Oct 26, 2007
Messages
865
Check the plugin documentation as it should show you what URL to put in the ITN callback.

You should have to do this for payfast and snapscan.

The process flow is along the lines of:
User clicks Checkout
User fllls in account/shipping details
User selects payment option
User redirected to payment site (let's call it SITEB) to enter credit card details
SITEB processes details
User redirected back to your "Order completed / Thank you" page
SITEB sends details of the transaction to the ITN callback url you specified
Your site receives (already part of woocommerce or the plugin) the information and adjusts the order accordingly.
 

AntennaMan

Expert Member
Joined
Apr 17, 2014
Messages
2,310
Does the payfast plugin not have some sort of setting? I assume you checked, but just want to make sure.

No, there is no such setting. In Woocommerce, the only settings are the merchant ID and key.

In the payfast dashboard, the only setting is the notification URL. But I don't know how to set up this URL and what php I will have to write to make it work.
 

AntennaMan

Expert Member
Joined
Apr 17, 2014
Messages
2,310
Check the plugin documentation as it should show you what URL to put in the ITN callback.

You should have to do this for payfast and snapscan.

The process flow is along the lines of:
User clicks Checkout
User fllls in account/shipping details
User selects payment option
User redirected to payment site (let's call it SITEB) to enter credit card details
SITEB processes details
User redirected back to your "Order completed / Thank you" page
SITEB sends details of the transaction to the ITN callback url you specified
Your site receives (already part of woocommerce or the plugin) the information and adjusts the order accordingly.

That process looks correct, the problem is in implementing it.

Payfast documentation shows that there is quite a lot of php involved in setting this up, and they don't really specify the URL. And like I mentioned, I'm not really a web developer. I chose Woocommerce to start with because it looked quite easy to set everything up, and it was easy, until it came to the auto-completion of orders once payment has been received.

Snapscan support sent the following:


The webhook should actually be like a standard WooCommerce one.

It should be in the WooCommerce documentation, but below is the URL:
https://example.co.za/wc-api/WC_Gateway_SnapScan/?token=TOKEN

In there the "example.co.za" needs to be your destination and the TOKEN should be your token.
But using that, I get a cURL Error 56 when creating the webhook.
 

Fulcrum29

Honorary Master
Joined
Jun 25, 2010
Messages
55,031
How did you guys get in contact with SnapScan so quickly, do you have a Standard Bank account? I have been waiting on SnapScan since day 1 to be visited by their agent. Numerous times have I have been in contact with no response on when I may contract with their payment service. In the beginning they told me that I’m not in their coverage area as I’m based outside Cape Town, yet they sign up other stores in my area… even the markets in the vicinity have them as a payment option.
 

rward

Senior Member
Joined
Oct 26, 2007
Messages
865
That process looks correct, the problem is in implementing it.

Payfast documentation shows that there is quite a lot of php involved in setting this up, and they don't really specify the URL. And like I mentioned, I'm not really a web developer. I chose Woocommerce to start with because it looked quite easy to set everything up, and it was easy, until it came to the auto-completion of orders once payment has been received.

Snapscan support sent the following:



But using that, I get a cURL Error 56 when creating the webhook.

What's the URL/name for the snapscan plugin that you're using?
 

AntennaMan

Expert Member
Joined
Apr 17, 2014
Messages
2,310
What's the URL/name for the snapscan plugin that you're using?

In the URL they supplied, it looks like it points towards the Snapscan gateway directory inside the Woocommerce api folder.

I just had a look at the directory structure on my host and it looks like it might be something like this:

http://www.example.co.za/wp-content/woocommerce-gateway-snapscan/?token=TOKEN

instead of the URL they sent me.

This is assuming that the URL needs to point to the woocommerce-gateway-snapscan.php file.
 

c10n3d_0r6

Senior Member
Joined
Nov 1, 2005
Messages
626
Did you manage to get this right? I've been having the same problem with PayFast where I have to manually mark all orders as complete.
 

ld13

Honorary Master
Joined
Oct 28, 2005
Messages
12,997
I am pretty sure the stock standard payfast/woocommerce plugin I use marks the order as paid... I will have to test it.
 

AntennaMan

Expert Member
Joined
Apr 17, 2014
Messages
2,310
I am pretty sure the stock standard payfast/woocommerce plugin I use marks the order as paid... I will have to test it.


Ok, so something interesting I noticed. I decided to test it again myself.

I just bought something off my own website and used Payfast. It does mark the payment as complete and it changed the status from " Pending" to "Processing". However it doesn't change from "Processing" to "Complete". And since I'm selling digital goods, the goods are only issued once the order status changes to "Complete". Any idea what I can do to get this last step automated?
 

chopsky

Expert Member
Joined
Oct 12, 2003
Messages
1,480
Hi AntennaMan

In WooCommerce, the standard procedure is for the order status to change from "On Hold" to "Processing" once payment has been received.
Typically, the store owner will then manually Complete the order once the shipment has been sent off for delivery, at which point the customer will receive a shipment notice.
In your case, since you want to auto-complete the order, there are several plugins available which should be able to assist you:
https://woocommerce.com/products/woocommerce-order-status-control/
https://wordpress.org/plugins/woocommerce-autocomplete-order/

Hope that helps.

Cheers!
 

c10n3d_0r6

Senior Member
Joined
Nov 1, 2005
Messages
626
Hi AntennaMan

In WooCommerce, the standard procedure is for the order status to change from "On Hold" to "Processing" once payment has been received.
Typically, the store owner will then manually Complete the order once the shipment has been sent off for delivery, at which point the customer will receive a shipment notice.
In your case, since you want to auto-complete the order, there are several plugins available which should be able to assist you:
https://woocommerce.com/products/woocommerce-order-status-control/
https://wordpress.org/plugins/woocommerce-autocomplete-order/

Hope that helps.

Cheers!

Thank you. This is precisely the problem I was having as well.
 

AntennaMan

Expert Member
Joined
Apr 17, 2014
Messages
2,310
Hi AntennaMan

In WooCommerce, the standard procedure is for the order status to change from "On Hold" to "Processing" once payment has been received.
Typically, the store owner will then manually Complete the order once the shipment has been sent off for delivery, at which point the customer will receive a shipment notice.
In your case, since you want to auto-complete the order, there are several plugins available which should be able to assist you:
https://woocommerce.com/products/woocommerce-order-status-control/
https://wordpress.org/plugins/woocommerce-autocomplete-order/

Hope that helps.

Cheers!

Hi

This solved the problem. I've used Payfast to test it, and it works. Still need to test it with Snapscan.

What confuses me is that in the Woocommerce documentation on order handling for digital goods, if you go to the Usage section, it states that
If items in the order are all downloadable + virtual, the order is complete.
.

I don't know if there is something in my setup that is wrong, but this never happened.

Anyway, will test with Snapscan and leave feedback here, for future reference.
 

c10n3d_0r6

Senior Member
Joined
Nov 1, 2005
Messages
626
Are all your products marked as downloadable and virtual? Mine were only marked as virtual, hence orders being marked as processing and not complete. I could mark them as downloadable as well, but then users have a tab on their account page for downloads even if there aren't any.

This is a bit annoying as I had many user's emailing me asking why their product is not available there when the subscription actually unlocked content on the website. Those plugins solve the problem for me.
 

AntennaMan

Expert Member
Joined
Apr 17, 2014
Messages
2,310
Are all your products marked as downloadable and virtual? Mine were only marked as virtual, hence orders being marked as processing and not complete. I could mark them as downloadable as well, but then users have a tab on their account page for downloads even if there aren't any.

This is a bit annoying as I had many user's emailing me asking why their product is not available there when the subscription actually unlocked content on the website. Those plugins solve the problem for me.

The products are all marked as virtual and downloadable because that was supposed to fix the problem. It hasn't.

Is it safe to mark them only as virtual when using that plugin?
 

AntennaMan

Expert Member
Joined
Apr 17, 2014
Messages
2,310
Are all your products marked as downloadable and virtual? Mine were only marked as virtual, hence orders being marked as processing and not complete. I could mark them as downloadable as well, but then users have a tab on their account page for downloads even if there aren't any.

This is a bit annoying as I had many user's emailing me asking why their product is not available there when the subscription actually unlocked content on the website. Those plugins solve the problem for me.

Do you by any chance use Snapscan on your site?
 
Top