Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update version and get rid of deprecation warnings #105

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM wordpress:6.1.1
FROM wordpress:6.4.2

ARG woocommerce_version

Expand Down
8 changes: 8 additions & 0 deletions class-wc-gateway-komoju.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
context: .
dockerfile: Dockerfile
args:
woocommerce_version: 6.3.1
woocommerce_version: 8.5.1
ports:
- "8000:80"
restart: always
Expand Down
18 changes: 15 additions & 3 deletions docs/dev_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
53 changes: 33 additions & 20 deletions includes/class-wc-gateway-komoju-single-slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions komoju-php/komoju-php/lib/komoju/KomojuApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

class KomojuApi
{
private $endpoint;
private $via;
private $secretKey;

public static function defaultEndpoint()
{
return 'https://komoju.com';
Expand Down
Loading