Woo Viet 1.5.0 and OnePay Gateways

It has been one year since my previous release 1.4.5 for Woo Viet – WooCommerce for Vietnam. In this version 1.5.0, I focused on two main issues:

I tracked this version with the milestone feature in GitHub.

Add OnePay International Gateway

Basically, all what I did is here. After researching differences between OnePay Domestic (implemented three years ago) and OnePay International, I could notice a few differences and a lot of codes can be shared between two gateways. Actually, in my mind, there were several approaches:

  1. Add the international class that extends the current OnePay Domestic class.
  2. Create a parent class, then extend two gateways as child classes.
  3. Use abstract then extend it for two gateways.
  4. Use trait to share the same methods.

(1) This may be an easy way to but it’s not very natural in terms of organization. Therefore, it is not selected.

(2) I think this can work but not well. Somehow the parent class can still be initialized is not what I want.

(3) This alleviates my concern mentioned in the method (2). Another advantage is that I can define and require which methods should be implemented. Last but not least, this implementation makes the relationship between two gateways more natural.

(4) I did not research more about this as I was quite happy with (3). I think this can work OK too but it may not demonstrate the close relationship between two gateways.


When option (3) was clear, I thought it would be easy to make changes. However, it turns out it takes more time than I expected. Even so, I really enjoyed working on this implementation as I learnt a bunch on the way.

  • Which methods and variables I should choose for abstract.
  • For variables, it was quite complicated as I need support for translation. That means I can not use WordPress gettext functions when declaring these variables. I solved this by moving their definitions into an abstract function and they will be defined in child classes.
  • get_called_class() is a super helpful function to get child class names, which are used for payment IDs.

After that, there were some other small issues that I need to tweak and test. Nonetheless, they’re working great at the end!

Not a great experience with OnePay

It would say that was a terrible experience both three years ago and one month ago!

  • It seems they did not change their example codes although these examples are so bad. I think they can publish their codes to GitHub and keep improving them.
  • These examples are even inconsistent with their documents. For example, they have only a few errors in their code while there are many more in their documents.
  • Last, the code style and organization are bad. I know it’s quite subjective but you can really feel that when downloading their examples.

Fix any issues between Woo Viet and Woo core

We got a few errors for the feature supporting VND in the PayPal Checkout extension.

The main plugin had made a few changes, which caused some errors when I tried testing this feature.


Actually, there are some small improvements but they’re quite trivial. I am not writing them down in detail here.

The release is quite smooth except a typo/bug!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s