Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Aug 5, 2021
1 parent 1afcf66 commit 02365ce
Show file tree
Hide file tree
Showing 8 changed files with 331 additions and 260 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## [Unreleased][unreleased]
-

## [3.0.0] - 2021-08-05
- Updated to `pronamic/wp-pay-core` version `3.0.0`.
- Updated to `pronamic/wp-money` version `2.0.0`.
- Switched to `pronamic/wp-coding-standards`.

## [2.1.1] - 2021-04-26
- Happy 2021.

Expand Down Expand Up @@ -101,7 +106,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## 1.0.0 - 2014-12-12
- First release.

[unreleased]: https://github.com/wp-pay-gateways/sisow/compare/2.1.1...HEAD
[unreleased]: https://github.com/wp-pay-gateways/sisow/compare/3.0.0...HEAD
[3.0.0]: https://github.com/wp-pay-gateways/sisow/compare/3.0.0...3.0.0
[2.1.1]: https://github.com/wp-pay-gateways/sisow/compare/2.1.0...2.1.1
[2.1.0]: https://github.com/wp-pay-gateways/sisow/compare/2.0.4...2.1.0
[2.0.4]: https://github.com/wp-pay-gateways/sisow/compare/2.0.3...2.0.4
Expand Down
14 changes: 5 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,19 @@
"sort-packages": true
},
"require": {
"ext-simplexml": "*",
"php": ">=5.6.20",
"wp-pay/core": "^2.6"
"ext-simplexml": "*",
"wp-pay/core": "^3.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"overtrue/phplint": "^1.2",
"php-coveralls/php-coveralls": "^2.4",
"phpcompatibility/php-compatibility": "^9.2",
"phpcompatibility/phpcompatibility-wp": "^2.0",
"phpmd/phpmd": "^2.7",
"phpunit/phpunit": "^5.7 || ^6.0",
"roots/wordpress": "^5.6",
"squizlabs/php_codesniffer": "^3.4",
"wp-coding-standards/wpcs": "^2.3",
"wp-phpunit/wp-phpunit": "^5.6"
"pronamic/wp-coding-standards": "^1.0",
"roots/wordpress": "^5.8",
"wp-phpunit/wp-phpunit": "^5.8"
},
"scripts": {
"coveralls": "vendor/bin/php-coveralls -v",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sisow",
"version": "2.1.1",
"version": "3.0.0",
"description": "Sisow driver for the WordPress payment processing library.",
"repository": {
"type": "git",
Expand Down
20 changes: 2 additions & 18 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
<?xml version="1.0"?>

<ruleset name="WordPress Pay Sisow rules">
<config name="minimum_supported_wp_version" value="4.7" />

<config name="testVersion" value="5.6-" />

<file>.</file>

<arg name="colors"/>
<arg name="extensions" value="php" />
<arg name="parallel" value="8" />
<arg value="sp" />

<exclude-pattern>node_modules/*</exclude-pattern>
<exclude-pattern>tests/bootstrap.php</exclude-pattern>
<exclude-pattern>tests/wp-config.php</exclude-pattern>
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>wordpress/*</exclude-pattern>
<exclude-pattern type="relative">^wp-content/*</exclude-pattern>

<rule ref="PHPCompatibilityWP" />

<rule ref="WordPress">
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
<rule ref="PronamicWP">
<exclude name="WordPressVIPMinimum.Security.PHPFilterFunctions.MissingThirdParameter" />
</rule>

<rule ref="WordPress.DB.SlowDBQuery.slow_db_query_meta_key">
Expand Down
4 changes: 0 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>

<php>
<env name="WP_PHPUNIT__TESTS_CONFIG" value="tests/wp-config.php" />
</php>
Expand Down
52 changes: 30 additions & 22 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace Pronamic\WordPress\Pay\Gateways\Sisow;

use Pronamic\WordPress\Money\Money;
use Pronamic\WordPress\Money\TaxedMoney;
use Pronamic\WordPress\Pay\Core\Gateway as Core_Gateway;
use Pronamic\WordPress\Pay\Core\PaymentMethods;
use Pronamic\WordPress\Pay\Core\Util as Core_Util;
Expand Down Expand Up @@ -175,7 +177,7 @@ public function payment_method_is_required() {

/**
* Format amount.
*
*
* @param Money $amount Money.
* @return string
*/
Expand Down Expand Up @@ -334,40 +336,44 @@ public function start( Payment $payment ) {
$x = 1;

foreach ( $lines as $line ) {
// Product ID.
$product_id = $line->get_id();
// Product type.
$product_type = 'physical';

switch ( $line->get_type() ) {
case PaymentLineType::SHIPPING:
$product_id = 'shipping';
$product_type = 'shipping_fee';

break;
case PaymentLineType::DISCOUNT:
$product_type = 'discount';

break;
case PaymentLineType::DIGITAL:
case PaymentLineType::FEE:
$product_id = 'paymentfee';
$product_id = 'digital';

break;
case PaymentLineType::PHYSICAL:
$product_id = 'physical';

break;
}

// Price.
$net_price = null;
$request->set_parameter( 'product_id_' . $x, $line->get_id() );
$request->set_parameter( 'product_description_' . $x, $line->get_name() );
$request->set_parameter( 'product_quantity_' . $x, $line->get_quantity() );
$request->set_parameter( 'product_type_' . $x, $product_type );

$unit_price = $line->get_unit_price();

if ( null !== $unit_price ) {
$net_price = $this->format_amount( $unit_price->get_excluding_tax() );
$request->set_parameter( 'product_netprice_' . $x, $unit_price instanceof TaxedMoney ? $unit_price->get_excluding_tax() : $unit_price );
}

// Request parameters.
$request->merge_parameters(
array(
'product_id_' . $x => $product_id,
'product_description_' . $x => $line->get_name(),
'product_quantity_' . $x => $line->get_quantity(),
'product_netprice_' . $x => $net_price,
'product_total_' . $x => $this->format_amount( $line->get_total_amount()->get_including_tax() ),
'product_nettotal_' . $x => $this->format_amount( $line->get_total_amount()->get_excluding_tax() ),
)
);
$total_amount = $line->get_total_amount();

$request->set_parameter( 'product_total_' . $x, $total_amount instanceof TaxedMoney ? $total_amount->get_including_tax() : $total_amount );
$request->set_parameter( 'product_nettotal_' . $x, $total_amount instanceof TaxedMoney ? $total_amount->get_excluding_tax() : $total_amount );

// Tax request parameters.
$tax_amount = $line->get_tax_amount();
Expand All @@ -376,10 +382,12 @@ public function start( Payment $payment ) {
$request->set_parameter( 'product_tax_' . $x, $this->format_amount( $tax_amount ) );
}

$tax_percentage = $line->get_total_amount()->get_tax_percentage();
if ( $total_amount instanceof TaxedMoney ) {
$tax_percentage = $total_amount->get_tax_percentage();

if ( null !== $tax_percentage ) {
$request->set_parameter( 'product_taxrate_' . $x, strval( $tax_percentage * 100 ) );
if ( null !== $tax_percentage ) {
$request->set_parameter( 'product_taxrate_' . $x, strval( $tax_percentage * 100 ) );
}
}

$x++;
Expand Down
64 changes: 34 additions & 30 deletions vendor-bin/phpstan/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 02365ce

Please sign in to comment.