Skip to content

Commit

Permalink
Merge branch 'release/4.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Jan 10, 2022
2 parents 7b183be + 35aedc5 commit 2a2f7a7
Show file tree
Hide file tree
Showing 19 changed files with 160 additions and 49 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## [Unreleased][unreleased]
-

## [4.0.0] - 2022-01-10
- Updated to https://github.com/pronamic/wp-pay-core/releases/tag/4.0.0.

## [3.0.1] - 2021-09-16
- Fixed capitalization of PayPal gateway filename for case-sensitive filesystems.

Expand Down Expand Up @@ -102,7 +105,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## 1.0.0 - 2015-11-05
- First release.

[unreleased]: https://github.com/wp-pay-extensions/charitable/compare/3.0.1...HEAD
[unreleased]: https://github.com/wp-pay-extensions/charitable/compare/4.0.0...HEAD
[4.0.0]: https://github.com/wp-pay-extensions/charitable/compare/3.0.1...4.0.0
[3.0.1]: https://github.com/wp-pay-extensions/charitable/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/wp-pay-extensions/charitable/compare/2.2.3...3.0.0
[2.2.3]: https://github.com/wp-pay-extensions/charitable/compare/2.2.2...2.2.3
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
],
"require": {
"php": ">=5.6.20",
"wp-pay/core": "^3.0"
"wp-pay/core": "^4.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4",
Expand All @@ -48,8 +48,9 @@
"phpmd/phpmd": "^2.9",
"phpunit/phpunit": "^5.7 || ^6.0",
"pronamic/wp-coding-standards": "^1.0",
"roots/wordpress": "^5.6",
"wp-phpunit/wp-phpunit": "^5.6"
"roots/wordpress": "^5.8",
"wp-phpunit/wp-phpunit": "^5.8",
"yoast/phpunit-polyfills": "^1.0"
},
"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": "charitable",
"version": "3.0.1",
"version": "4.0.0",
"description": "Charitable driver for the WordPress payment processing library.",
"repository": {
"type": "git",
Expand Down
10 changes: 9 additions & 1 deletion src/BancontactGateway.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* Bancontact gateway.
*
* @author Pronamic <[email protected]>
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay
*/

namespace Pronamic\WordPress\Pay\Extensions\Charitable;

Expand All @@ -8,7 +16,7 @@
/**
* Title: Charitable Mister Cash gateway
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
10 changes: 9 additions & 1 deletion src/BankTransferGateway.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* Bank transfer gateway.
*
* @author Pronamic <[email protected]>
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay
*/

namespace Pronamic\WordPress\Pay\Extensions\Charitable;

Expand All @@ -8,7 +16,7 @@
/**
* Title: Charitable Bank Transfer gateway
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
10 changes: 9 additions & 1 deletion src/Charitable.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
<?php
/**
* Charitable.
*
* @author Pronamic <[email protected]>
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay
*/

namespace Pronamic\WordPress\Pay\Extensions\Charitable;

/**
* Title: WordPress pay Charitable
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
2 changes: 1 addition & 1 deletion src/CharitableDependency.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Charitable Dependency
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay\Extensions\Charitable
*/
Expand Down
30 changes: 21 additions & 9 deletions src/CharitableHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,17 @@
* Charitable Helper
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay\Extensions\Charitable
*/

namespace Pronamic\WordPress\Pay\Extensions\Charitable;

use Charitable_Donation;
use Charitable_Donation_Processor;
use Charitable_Gateway;
use Pronamic\WordPress\Money\Parser as MoneyParser;
use Pronamic\WordPress\Pay\Address;
use Pronamic\WordPress\Pay\AddressHelper;
use Pronamic\WordPress\Pay\ContactName;
use Pronamic\WordPress\Pay\ContactNameHelper;
use Pronamic\WordPress\Pay\Customer;
use Pronamic\WordPress\Pay\CustomerHelper;

/**
Expand All @@ -31,6 +26,7 @@ class CharitableHelper {
/**
* Get description.
*
* @param int $donation_id Donation ID.
* @return string
*/
public static function get_title( $donation_id ) {
Expand All @@ -44,18 +40,25 @@ public static function get_title( $donation_id ) {
/**
* Get description.
*
* @param Charitable_Gateway $gateway Charitable gateway.
* @param int $donation_id Donation ID.
* @return string
*/
public static function get_description( $gateway, $donation_id ) {
$description = $gateway->get_value( 'transaction_description' );
$donation = new Charitable_Donation( $donation_id );

if ( '' === $description ) {
$description = self::get_title( $donation_id );
}

// Replacements.
$campaigns = $donation->get_campaigns();

$replacements = array(
'{donation_id}' => $donation_id,
'{donation_id}' => $donation_id,
'{first_campaign_name}' => reset( $campaigns ),
'{campaign_name}' => implode( ', ', $campaigns ),
);

return \strtr( $description, $replacements );
Expand All @@ -77,8 +80,8 @@ public static function get_total_amount_value( $donation_id ) {
/**
* Get value from user data.
*
* @param array $user_data User data.
* @param string $key Array key.
* @param array<string, mixed> $user_data User data.
* @param string $key Array key.
* @return null|string
*/
public static function get_value_from_user_data( $user_data, $key ) {
Expand All @@ -91,6 +94,9 @@ public static function get_value_from_user_data( $user_data, $key ) {

/**
* Get customer from user data.
*
* @param array<string, mixed> $user_data User data.
* @return \Pronamic\WordPress\Pay\Customer|null
*/
public static function get_customer_from_user_data( $user_data ) {
return CustomerHelper::from_array(
Expand All @@ -105,6 +111,9 @@ public static function get_customer_from_user_data( $user_data ) {

/**
* Get name from user data.
*
* @param array<string, mixed> $user_data User data.
* @return \Pronamic\WordPress\Pay\ContactName|null
*/
public static function get_name_from_user_data( $user_data ) {
return ContactNameHelper::from_array(
Expand All @@ -117,6 +126,9 @@ public static function get_name_from_user_data( $user_data ) {

/**
* Get address from user data.
*
* @param array<string, mixed> $user_data User data.
* @return \Pronamic\WordPress\Pay\Address|null
*/
public static function get_address_from_user_data( $user_data ) {
return AddressHelper::from_array(
Expand Down
10 changes: 9 additions & 1 deletion src/CreditCardGateway.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* Credit card gateway.
*
* @author Pronamic <[email protected]>
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay
*/

namespace Pronamic\WordPress\Pay\Extensions\Charitable;

Expand All @@ -8,7 +16,7 @@
/**
* Title: Charitable Credit Card gateway
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
10 changes: 9 additions & 1 deletion src/DirectDebitGateway.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* Direct debit gateway.
*
* @author Pronamic <[email protected]>
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay
*/

namespace Pronamic\WordPress\Pay\Extensions\Charitable;

Expand All @@ -8,7 +16,7 @@
/**
* Title: Charitable iDEAL gateway
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
40 changes: 26 additions & 14 deletions src/Extension.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* Extension.
*
* @author Pronamic <[email protected]>
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay
*/

namespace Pronamic\WordPress\Pay\Extensions\Charitable;

Expand All @@ -12,7 +20,7 @@
/**
* Title: Charitable extension
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down Expand Up @@ -72,10 +80,8 @@ public function setup() {
* Charitable payments gateways.
*
* @link https://github.com/Charitable/Charitable/blob/1.1.4/includes/gateways/class-charitable-gateways.php#L44-L51
*
* @param array $gateways Gateways.
*
* @return array
* @param array<string, string> $gateways Gateways.
* @return array<string, string>
*/
public function charitable_payment_gateways( $gateways ) {
$classes = array(
Expand All @@ -99,7 +105,11 @@ public function charitable_payment_gateways( $gateways ) {
foreach ( $classes as $class ) {
$class = __NAMESPACE__ . '\\' . $class;

$id = call_user_func( array( $class, 'get_gateway_id' ) );
$id = (string) call_user_func( array( $class, 'get_gateway_id' ) );

if ( empty( $id ) ) {
continue;
}

$gateways[ $id ] = $class;

Expand All @@ -125,9 +135,7 @@ public function charitable_payment_gateways( $gateways ) {
* Get the default return URL.
*
* @since 1.0.3
*
* @param Charitable_Donation $donation Donation.
*
* @return string URL
*/
private static function get_return_url( Charitable_Donation $donation ) {
Expand All @@ -138,7 +146,11 @@ private static function get_return_url( Charitable_Donation $donation ) {
$campaign = reset( $donations );

if ( false !== $campaign ) {
$url = get_permalink( $campaign->campaign_id );
$permalink = get_permalink( $campaign->campaign_id );

if ( false !== $permalink ) {
$url = $permalink;
}
}

return $url;
Expand Down Expand Up @@ -175,6 +187,7 @@ public function redirect_url( $url, Payment $payment ) {
* @link https://github.com/Charitable/Charitable/blob/1.1.4/includes/gateways/class-charitable-gateway-paypal.php#L229-L357
*
* @param Payment $payment Payment.
* @return void
*/
public function status_update( Payment $payment ) {
$donation_id = $payment->get_source_id();
Expand Down Expand Up @@ -212,9 +225,8 @@ public function status_update( Payment $payment ) {
/**
* Filter currencies.
*
* @param array $currencies Available currencies.
*
* @return mixed
* @param array<string, string> $currencies Available currencies.
* @return array<string, string>
*/
public function currencies( $currencies ) {
if ( ! is_array( $currencies ) ) {
Expand Down Expand Up @@ -257,7 +269,7 @@ public function source_text( $text, Payment $payment ) {

$text .= sprintf(
'<a href="%s">%s</a>',
get_edit_post_link( $payment->source_id ),
get_edit_post_link( (int) $payment->source_id ),
/* translators: %s: source id */
sprintf( __( 'Donation %s', 'pronamic_ideal' ), $payment->source_id )
);
Expand Down Expand Up @@ -286,6 +298,6 @@ public function source_description( $description, Payment $payment ) {
* @return null|string
*/
public function source_url( $url, Payment $payment ) {
return get_edit_post_link( $payment->source_id );
return get_edit_post_link( (int) $payment->source_id );
}
}
Loading

0 comments on commit 2a2f7a7

Please sign in to comment.