diff --git a/Dockerfile b/Dockerfile index 88bf1cc..395c4ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM wordpress:6.1.1 +FROM wordpress:6.4.2 ARG woocommerce_version diff --git a/class-wc-gateway-komoju.php b/class-wc-gateway-komoju.php index 8241ff2..10dcf16 100755 --- a/class-wc-gateway-komoju.php +++ b/class-wc-gateway-komoju.php @@ -28,6 +28,14 @@ class WC_Gateway_Komoju extends WC_Payment_Gateway /** @var WC_Logger Logger instance */ public static $log; + protected $debug; + protected $invoice_prefix; + protected $secretKey; + protected $webhookSecretToken; + protected $komoju_api; + protected $instructions; + protected $useOnHold; + /** * Constructor for the gateway. */ diff --git a/docker-compose.yml b/docker-compose.yml index d4f8080..2790464 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,7 +21,7 @@ services: context: . dockerfile: Dockerfile args: - woocommerce_version: 6.3.1 + woocommerce_version: 8.5.1 ports: - "8000:80" restart: always diff --git a/docs/dev_setup.md b/docs/dev_setup.md index c50204f..e5f036e 100644 --- a/docs/dev_setup.md +++ b/docs/dev_setup.md @@ -2,22 +2,34 @@ This document provides a detailed setup guide for the development environment, including instructions for WordPress and WooCommerce. This was written on WordPress version 6.1.1 and WooCommerce 6.3.1. -To begin, start the docker containers: +To begin, start the docker containers, using the --build option to watch for changes: ``` -$ docker-compose up +docker-compose up --build ``` This will download the docker images and WordPress plugins. Once the initial setup is done (docker is no longer constantly writing text to screen), you can navigate to `127.0.0.1:8000` to setup WordPress. **Note:** It _has_ to be `127.0.0.1`, not `localhost` +If you've made changes to your files, you can manually rebuild using build. If you've made changes to your Docker configuration, you can do a fresh build with --no-cache option. + +``` +docker-compose build --no-cache +``` + +If you want to completely start fresh, including removing any data stored in Docker volumes (such as your MySQL database data), you can use the -v option: + +``` +docker-compose down -v +``` + ## Configuring Ngrok Because the Komoju plugin uses webhooks to receive notifications once the payment is complete the wordpress instance will need to be accessible to the internet. This can be done with [ngrok](https://ngrok.com/): ``` -ngrok http -host-header=rewrite http://127.0.0.1:8000 +ngrok http --host-header=rewrite http://127.0.0.1:8000 ``` **Note:** Accessing the website using the ngrok endpoint doesn't work particularly well, so you're better off using 127.0.0.1 to go through the checkout flow and just use ngrok for the webhook integration. diff --git a/includes/class-wc-gateway-komoju-single-slug.php b/includes/class-wc-gateway-komoju-single-slug.php index 7988bf7..d4d76a5 100644 --- a/includes/class-wc-gateway-komoju-single-slug.php +++ b/includes/class-wc-gateway-komoju-single-slug.php @@ -12,6 +12,16 @@ */ class WC_Gateway_Komoju_Single_Slug extends WC_Gateway_Komoju { + protected $publishableKey; + protected $payment_method; + protected $debug; + protected $invoice_prefix; + protected $secretKey; + protected $webhookSecretToken; + protected $komoju_api; + protected $instructions; + protected $useOnHold; + public function __construct($payment_method) { $slug = $payment_method['type_slug']; @@ -24,28 +34,31 @@ public function __construct($payment_method) if ($this->get_option('showIcon') == 'yes') { $this->icon = "https://komoju.com/payment_methods/$slug.svg"; + } - if ($slug == 'credit_card') { - // Show dynamic icon with supported brands. - $brands = $payment_method['subtypes']; - - $sort_order = [ - 'visa' => 0, - 'master' => 1, - 'jcb' => 2, - 'american_express' => 3, - 'diners_club' => 4, - 'discover' => 5, - ]; - - // Sort by the order defined above. - usort($brands, function ($a, $b) use ($sort_order) { - return $sort_order[$a] - $sort_order[$b]; - }); + if ($slug == 'credit_card') { + // Show dynamic icon with supported brands. + $brands = isset($payment_method['subtypes']) ? $payment_method['subtypes'] : []; + $sort_order = [ + 'visa' => 0, + 'master' => 1, + 'jcb' => 2, + 'american_express' => 3, + 'diners_club' => 4, + 'discover' => 5, + ]; + + // Sort by the order defined above. + usort($brands, function ($a, $b) use ($sort_order) { + // Get the sort order for $a and $b, providing a default value if the key doesn't exist + $sort_a = isset($sort_order[$a]) ? $sort_order[$a] : count($sort_order); + $sort_b = isset($sort_order[$b]) ? $sort_order[$b] : count($sort_order); + + return $sort_a - $sort_b; + }); - $brands = implode(',', $brands); - $this->icon .= "?brands=$brands"; - } + $brands = implode(',', $brands); + $this->icon .= "?brands=$brands"; } // TODO: It would be nice if KOMOJU told us in the payment method object whether or diff --git a/komoju-php/komoju-php/lib/komoju/KomojuApi.php b/komoju-php/komoju-php/lib/komoju/KomojuApi.php index b76f9ee..d0877be 100644 --- a/komoju-php/komoju-php/lib/komoju/KomojuApi.php +++ b/komoju-php/komoju-php/lib/komoju/KomojuApi.php @@ -2,6 +2,10 @@ class KomojuApi { + private $endpoint; + private $via; + private $secretKey; + public static function defaultEndpoint() { return 'https://komoju.com';