-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
160 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
@@ -8,7 +16,7 @@ | |
/** | ||
* Title: Charitable Mister Cash gateway | ||
* Description: | ||
* Copyright: 2005-2021 Pronamic | ||
* Copyright: 2005-2022 Pronamic | ||
* Company: Pronamic | ||
* | ||
* @author Remco Tolsma | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
@@ -8,7 +16,7 @@ | |
/** | ||
* Title: Charitable Bank Transfer gateway | ||
* Description: | ||
* Copyright: 2005-2021 Pronamic | ||
* Copyright: 2005-2022 Pronamic | ||
* Company: Pronamic | ||
* | ||
* @author Remco Tolsma | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
/** | ||
|
@@ -31,6 +26,7 @@ class CharitableHelper { | |
/** | ||
* Get description. | ||
* | ||
* @param int $donation_id Donation ID. | ||
* @return string | ||
*/ | ||
public static function get_title( $donation_id ) { | ||
|
@@ -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 ); | ||
|
@@ -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 ) { | ||
|
@@ -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( | ||
|
@@ -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( | ||
|
@@ -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( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
@@ -8,7 +16,7 @@ | |
/** | ||
* Title: Charitable Credit Card gateway | ||
* Description: | ||
* Copyright: 2005-2021 Pronamic | ||
* Copyright: 2005-2022 Pronamic | ||
* Company: Pronamic | ||
* | ||
* @author Remco Tolsma | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
@@ -8,7 +16,7 @@ | |
/** | ||
* Title: Charitable iDEAL gateway | ||
* Description: | ||
* Copyright: 2005-2021 Pronamic | ||
* Copyright: 2005-2022 Pronamic | ||
* Company: Pronamic | ||
* | ||
* @author Remco Tolsma | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
@@ -12,7 +20,7 @@ | |
/** | ||
* Title: Charitable extension | ||
* Description: | ||
* Copyright: 2005-2021 Pronamic | ||
* Copyright: 2005-2022 Pronamic | ||
* Company: Pronamic | ||
* | ||
* @author Remco Tolsma | ||
|
@@ -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( | ||
|
@@ -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; | ||
|
||
|
@@ -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 ) { | ||
|
@@ -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; | ||
|
@@ -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(); | ||
|
@@ -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 ) ) { | ||
|
@@ -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 ) | ||
); | ||
|
@@ -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 ); | ||
} | ||
} |
Oops, something went wrong.