Skip to content

Commit 134bd0e

Browse files
authored
Merge pull request #29 from ndeet/fix-refund-text-limit
Ensure refund text does not exceed API field limit.
2 parents a1220af + 8c96379 commit 134bd0e

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

btcpay-greenfield-for-woocommerce.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
defined( 'ABSPATH' ) || exit();
2828

29-
define( 'BTCPAYSERVER_VERSION', '2.3.0' );
29+
define( 'BTCPAYSERVER_VERSION', '2.3.1' );
3030
define( 'BTCPAYSERVER_VERSION_KEY', 'btcpay_gf_version' );
3131
define( 'BTCPAYSERVER_PLUGIN_FILE_PATH', plugin_dir_path( __FILE__ ) );
3232
define( 'BTCPAYSERVER_PLUGIN_URL', plugin_dir_url(__FILE__ ) );

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Tags: bitcoin, btcpay, BTCPay Server, btcpayserver, WooCommerce, payment gateway
55
Requires at least: 5.2
66
Tested up to: 6.3
77
Requires PHP: 7.4
8-
Stable tag: 2.3.0
8+
Stable tag: 2.3.1
99
License: MIT
1010
License URI: https://github.com/btcpayserver/woocommerce-greenfield-plugin/blob/master/license.txt
1111

@@ -104,6 +104,9 @@ You'll find extensive documentation and answers to many of your questions on [BT
104104

105105
== Changelog ==
106106

107+
= 2.3.1 :: 2023-10-20 =
108+
* Fix: Ensure refunds text does not exceed API field limit.
109+
107110
= 2.3.0 :: 2023-09-06 =
108111
* Support for high performance order storage (HPOS)
109112

src/Gateway/AbstractGateway.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) {
180180

181181
// Make sure the refund amount is not greater than the invoice amount.
182182
if ($amount > $order->get_remaining_refund_amount()) {
183-
$errAmount = __METHOD__ . ': the refund amount can not exceed the order amount, aborting.';
183+
$errAmount = __METHOD__ . ': the refund amount can not exceed the order amount, aborting. Remaining amount ' . $order->get_remaining_refund_amount();
184184
Logger::debug($errAmount);
185185
return new \WP_Error('1', $errAmount);
186186
}
@@ -200,13 +200,17 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) {
200200
$paymentMethods = array_diff($paymentMethods, ['BTC_LNURLPAY']);
201201
}
202202

203+
// Refund name is limited for 50 chars, but we do not have description field available until php lib v3 is out.
204+
$refundName = __('Refund of order ', 'btcpay-greenfield-for-woocommerce') . $order->get_order_number() . '; ' . $reason;
205+
$refundName = substr($refundName, 0, 50);
206+
203207
// Create the payout.
204208
try {
205209
$client = new PullPayment( $this->apiHelper->url, $this->apiHelper->apiKey);
206210
// todo: add reason to description with upcoming php lib v3
207211
$pullPayment = $client->createPullPayment(
208212
$this->apiHelper->storeId,
209-
__('Refund for order no.: ', 'btcpay-greenfield-for-woocommerce') . $order->get_order_number() . ' reason: ' . $reason,
213+
$refundName,
210214
$refundAmount,
211215
$currency,
212216
null,

0 commit comments

Comments
 (0)