Skip to content

Commit 2ac652d

Browse files
Support plugin E-Wallet
1 parent a0fc913 commit 2ac652d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"provider": "FriendsOfBotble\\PayFS\\Providers\\PayFSServiceProvider",
66
"author": "Friends Of Botble",
77
"url": "https://friendsofbotble.com",
8-
"version": "1.0.2",
8+
"version": "1.0.3",
99
"description": "Tích hợp PayFS vào Botble CMS",
1010
"minimum_core_version": "7.0.5"
1111
}

src/PayFS.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ public static function getQRCodeUrl(float $amount, string $chargeId): string
1919
$accountNumber = get_payment_setting('account_number', PAYFS_PAYMENT_METHOD_NAME);
2020
$accountName = get_payment_setting('account_holder', PAYFS_PAYMENT_METHOD_NAME);
2121

22-
// VietQR API format: https://img.vietqr.io/image/{BANK_ID}-{ACCOUNT_NO}-{TEMPLATE}.jpg
2322
$baseUrl = sprintf(
2423
'https://img.vietqr.io/image/%s-%s-compact2.jpg',
2524
$bankCode,
2625
$accountNumber
2726
);
2827

29-
// Add query parameters
3028
$params = http_build_query([
3129
'amount' => $amount,
3230
'addInfo' => $chargeId,
@@ -108,10 +106,13 @@ public static function getChargeIdFrom(string $content): ?string
108106
{
109107
$prefix = get_payment_setting('prefix', PAYFS_PAYMENT_METHOD_NAME, 'SHD');
110108

111-
preg_match('/(' . preg_quote($prefix, '/') . '\d+)/', $content, $matches);
109+
// Match prefix + optional separator (hyphen, space, or none) + digits
110+
preg_match('/(' . preg_quote($prefix, '/') . ')[\-\s]?(\d+)/', $content, $matches);
112111

113-
if (isset($matches[1])) {
114-
return $matches[1];
112+
if (isset($matches[1]) && isset($matches[2])) {
113+
// Return normalized format: PREFIX + DIGITS (no separator)
114+
// This matches how charge_id is generated in PayFSPaymentService
115+
return $matches[1] . $matches[2];
115116
}
116117

117118
return null;

0 commit comments

Comments
 (0)