Skip to content

Commit debc39f

Browse files
Merge pull request #477 from omise/release-v3.7.0
Updating metadata for v3.7.0 release
2 parents 7943203 + de074d0 commit debc39f

29 files changed

+556
-253
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## [v3.7.0 _(Apr, 9, 2024)_](https://github.com/omise/omise-magento/releases/tag/v3.7.0)
4+
- Added WeChat Pay (PR: [#475](https://github.com/omise/omise-magento/pull/475))
5+
- Removed Pay with Points and Citi installment (PR: [#476](https://github.com/omise/omise-magento/pull/476))
6+
37
## [v3.6.1 _(Feb, 12, 2024)_](https://github.com/omise/omise-magento/releases/tag/v3.6.1)
48
- Fixed redirect issue on cancelled card payment. (PR: [#470](https://github.com/omise/omise-magento/pull/470))
59

Cron/OrderSyncStatus.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class OrderSyncStatus
4343
"omise_offsite_shopeepay",
4444
"omise_offsite_atome",
4545
"omise_offsite_paypay",
46+
"omise_offiste_wechat_pay"
4647
];
4748

4849
/**

Gateway/Request/APMBuilder.php

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323
use Omise\Payment\Model\Config\Truemoney;
2424
use Omise\Payment\Model\Config\Alipayplus;
2525
use Omise\Payment\Model\Config\DuitnowOBW;
26-
use Omise\Payment\Model\Config\Pointsciti;
2726
use Omise\Payment\Model\Config\Installment;
2827
use Omise\Payment\Model\Config\Mobilebanking;
2928
use Omise\Payment\Model\Config\Rabbitlinepay;
3029
use Omise\Payment\Model\Config\PayPay;
30+
use Omise\Payment\Model\Config\WeChatPay;
3131

3232
use Omise\Payment\Helper\OmiseMoney;
33-
use Omise\Payment\Helper\OmiseHelper as Helper;
3433
use Omise\Payment\Model\Config\Internetbanking;
3534
use Omise\Payment\Model\Config\Conveniencestore;
3635
use Magento\Payment\Gateway\Helper\SubjectReader;
@@ -43,6 +42,7 @@
4342
use Omise\Payment\Observer\MobilebankingDataAssignObserver;
4443
use Omise\Payment\Observer\InternetbankingDataAssignObserver;
4544
use Omise\Payment\Observer\ConveniencestoreDataAssignObserver;
45+
use Omise\Payment\Helper\RequestHelper;
4646

4747
class APMBuilder implements BuilderInterface
4848
{
@@ -107,14 +107,14 @@ class APMBuilder implements BuilderInterface
107107
const SOURCE_SHIPPING = 'shipping';
108108

109109
/**
110-
* @var \Omise\Payment\Helper\ReturnUrlHelper
110+
* @var string
111111
*/
112-
protected $returnUrl;
112+
const SOURCE_IP = 'ip';
113113

114114
/**
115-
* @var Helper
115+
* @var \Omise\Payment\Helper\ReturnUrlHelper
116116
*/
117-
protected $helper;
117+
protected $returnUrl;
118118

119119
/**
120120
* @var OmiseMoney
@@ -131,22 +131,27 @@ class APMBuilder implements BuilderInterface
131131
*/
132132
protected $config;
133133

134+
/**
135+
* @var \Omise\Payment\Helper\RequestHelper
136+
*/
137+
private $requestHelper;
138+
134139
/**
135140
* @param $helper \Omise\Payment\Helper\OmiseHelper
136141
* @param $returnUrl \Omise\Payment\Helper\ReturnUrl
137142
*/
138143
public function __construct(
139-
Helper $helper,
140144
ReturnUrlHelper $returnUrl,
141145
Config $config,
142146
Capabilities $capabilities,
143-
OmiseMoney $money
147+
OmiseMoney $money,
148+
RequestHelper $requestHelper
144149
) {
145-
$this->helper = $helper;
146150
$this->returnUrl = $returnUrl;
147151
$this->config = $config;
148152
$this->capabilities = $capabilities;
149153
$this->money = $money;
154+
$this->requestHelper = $requestHelper;
150155
}
151156

152157
/**
@@ -218,11 +223,6 @@ public function build(array $buildSubject)
218223
self::SOURCE_TYPE => 'promptpay'
219224
];
220225
break;
221-
case Pointsciti::CODE:
222-
$paymentInfo[self::SOURCE] = [
223-
self::SOURCE_TYPE => 'points_citi'
224-
];
225-
break;
226226
case Fpx::CODE:
227227
$paymentInfo[self::SOURCE] = [
228228
self::SOURCE_TYPE => 'fpx',
@@ -234,43 +234,43 @@ public function build(array $buildSubject)
234234
case Alipayplus::ALIPAY_CODE:
235235
$paymentInfo[self::SOURCE] = [
236236
self::SOURCE_TYPE => 'alipay_cn',
237-
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
237+
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
238238
];
239239
break;
240240
case Alipayplus::ALIPAYHK_CODE:
241241
$paymentInfo[self::SOURCE] = [
242242
self::SOURCE_TYPE => 'alipay_hk',
243-
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
243+
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
244244
];
245245
break;
246246
case Alipayplus::DANA_CODE:
247247
$paymentInfo[self::SOURCE] = [
248248
self::SOURCE_TYPE => 'dana',
249-
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
249+
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
250250
];
251251
break;
252252
case Alipayplus::GCASH_CODE:
253253
$paymentInfo[self::SOURCE] = [
254254
self::SOURCE_TYPE => 'gcash',
255-
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
255+
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
256256
];
257257
break;
258258
case Alipayplus::KAKAOPAY_CODE:
259259
$paymentInfo[self::SOURCE] = [
260260
self::SOURCE_TYPE => 'kakaopay',
261-
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
261+
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
262262
];
263263
break;
264264
case Touchngo::CODE:
265265
$paymentInfo[self::SOURCE] = [
266266
self::SOURCE_TYPE => 'touch_n_go',
267-
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
267+
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
268268
];
269269
break;
270270
case Mobilebanking::CODE:
271271
$paymentInfo[self::SOURCE] = [
272272
self::SOURCE_TYPE => $method->getAdditionalInformation(MobilebankingDataAssignObserver::OFFSITE),
273-
self::PLATFORM_TYPE => $this->helper->getPlatformType()
273+
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType()
274274
];
275275
break;
276276
case Rabbitlinepay::CODE:
@@ -281,19 +281,19 @@ public function build(array $buildSubject)
281281
case Ocbcpao::CODE:
282282
$paymentInfo[self::SOURCE] = [
283283
self::SOURCE_TYPE => 'mobile_banking_ocbc_pao',
284-
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
284+
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
285285
];
286286
break;
287287
case OcbcDigital::CODE:
288288
$paymentInfo[self::SOURCE] = [
289289
self::SOURCE_TYPE => OcbcDigital::ID,
290-
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
290+
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
291291
];
292292
break;
293293
case Grabpay::CODE:
294294
$paymentInfo[self::SOURCE] = [
295295
self::SOURCE_TYPE => 'grabpay',
296-
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
296+
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
297297
];
298298
break;
299299
case Boost::CODE:
@@ -339,6 +339,12 @@ public function build(array $buildSubject)
339339
self::SOURCE_TYPE => PayPay::ID,
340340
];
341341
break;
342+
case WeChatPay::CODE:
343+
$paymentInfo[self::SOURCE] = [
344+
self::SOURCE_TYPE => WeChatPay::ID,
345+
self::SOURCE_IP => $this->requestHelper->getClientIp()
346+
];
347+
break;
342348
}
343349

344350
return $paymentInfo;
@@ -350,7 +356,7 @@ private function getShopeepaySource()
350356
$isShopeepayEnabled = $this->capabilities->isBackendEnabled(Shopeepay::ID);
351357

352358
// If user is in mobile and jump app is enabled then return shopeepay_jumpapp as source
353-
if ($this->helper->isMobilePlatform() && $isShopeepayJumpAppEnabled) {
359+
if ($this->requestHelper->isMobilePlatform() && $isShopeepayJumpAppEnabled) {
354360
return Shopeepay::JUMPAPP_ID;
355361
}
356362

Helper/OmiseHelper.php

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Omise\Payment\Model\Config\Config;
1717
use Omise\Payment\Model\Config\Paynow;
1818
use Omise\Payment\Model\Config\PayPay;
19-
use Magento\Framework\App\Request\Http;
2019
use Magento\Store\Model\ScopeInterface;
2120
use Omise\Payment\Model\Config\Grabpay;
2221
use Omise\Payment\Model\Config\Ocbcpao;
@@ -29,7 +28,6 @@
2928
use Omise\Payment\Model\Config\Truemoney;
3029
use Omise\Payment\Model\Config\Alipayplus;
3130
use Omise\Payment\Model\Config\DuitnowOBW;
32-
use Omise\Payment\Model\Config\Pointsciti;
3331
use Omise\Payment\Model\Config\CcGooglePay;
3432
use Omise\Payment\Model\Config\Installment;
3533
use Omise\Payment\Model\Config\Mobilebanking;
@@ -38,14 +36,10 @@
3836
use Omise\Payment\Model\Config\Internetbanking;
3937
use Magento\Framework\App\Helper\AbstractHelper;
4038
use Omise\Payment\Model\Config\Conveniencestore;
39+
use Omise\Payment\Model\Config\WeChatPay;
4140

4241
class OmiseHelper extends AbstractHelper
4342
{
44-
/**
45-
* @var \Magento\Framework\HTTP\Header
46-
*/
47-
protected $header;
48-
4943
/**
5044
* @var array
5145
*/
@@ -54,7 +48,6 @@ class OmiseHelper extends AbstractHelper
5448
Internetbanking::CODE,
5549
Installment::CODE,
5650
Truemoney::CODE,
57-
Pointsciti::CODE,
5851
Fpx::CODE,
5952
Alipayplus::ALIPAY_CODE,
6053
Alipayplus::ALIPAYHK_CODE,
@@ -73,7 +66,8 @@ class OmiseHelper extends AbstractHelper
7366
MaybankQR::CODE,
7467
Shopeepay::CODE,
7568
Atome::CODE,
76-
PayPay::CODE
69+
PayPay::CODE,
70+
WeChatPay::CODE
7771
];
7872

7973
/**
@@ -123,7 +117,6 @@ class OmiseHelper extends AbstractHelper
123117
Alipay::ID => Alipay::CODE,
124118
Truemoney::ID => Truemoney::CODE,
125119
Truemoney::JUMPAPP_ID => Truemoney::CODE,
126-
Pointsciti::ID => Pointsciti::CODE,
127120
Fpx::ID => Fpx::CODE,
128121
Alipayplus::ALIPAY_ID => Alipayplus::ALIPAY_CODE,
129122
Alipayplus::ALIPAYHK_ID => Alipayplus::ALIPAYHK_CODE,
@@ -143,6 +136,7 @@ class OmiseHelper extends AbstractHelper
143136
Shopeepay::JUMPAPP_ID => Shopeepay::CODE,
144137
Atome::ID => Atome::CODE,
145138
PayPay::ID => PayPay::CODE,
139+
WeChatPay::ID => WeChatPay::CODE,
146140

147141
// offsite internet banking payment
148142
Internetbanking::BBL_ID => Internetbanking::CODE,
@@ -151,7 +145,6 @@ class OmiseHelper extends AbstractHelper
151145
// offsite installment banking payment
152146
Installment::BAY_ID => Installment::CODE,
153147
Installment::BBL_ID => Installment::CODE,
154-
Installment::CITI_ID => Installment::CODE,
155148
Installment::UOB_ID => Installment::CODE,
156149
Installment::FIRST_CHOICE_ID => Installment::CODE,
157150
Installment::KBANK_ID => Installment::CODE,
@@ -189,7 +182,6 @@ class OmiseHelper extends AbstractHelper
189182
Internetbanking::CODE => "Internet Banking Payment",
190183
Installment::CODE => "Installment Payment",
191184
Truemoney::CODE => "TrueMoney Payment",
192-
Pointsciti::CODE => "Citi Pay with Points",
193185
Fpx::CODE => "FPX Payment",
194186
Alipayplus::ALIPAY_CODE => "Alipay (Alipay+ Partner) Payment",
195187
Alipayplus::ALIPAYHK_CODE => "AlipayHK (Alipay+ Partner) Payment",
@@ -209,6 +201,7 @@ class OmiseHelper extends AbstractHelper
209201
Shopeepay::CODE => "ShopeePay Payment",
210202
Atome::CODE => "Atome Payment",
211203
PayPay::CODE => "PayPay Payment",
204+
WeChatPay::CODE => "WeChat Pay Payment",
212205

213206
// offline payment
214207
Paynow::CODE => "PayNow QR Payment",
@@ -225,16 +218,10 @@ class OmiseHelper extends AbstractHelper
225218
/**
226219
* @param Header $header
227220
* @param Config $config
228-
* @param Http $httpRequest
229221
*/
230-
public function __construct(
231-
Header $header,
232-
Config $config,
233-
Http $httpRequest
234-
) {
235-
$this->header = $header;
222+
public function __construct(Config $config)
223+
{
236224
$this->config = $config;
237-
$this->httpRequest = $httpRequest;
238225

239226
$this->omisePaymentMethods = array_merge(
240227
$this->offsitePaymentMethods,
@@ -406,33 +393,6 @@ public function is3DSecureEnabled($charge)
406393
return false;
407394
}
408395

409-
/**
410-
* Get platform Type of WEB, IOS or ANDROID to add to source API parameter.
411-
* @return string
412-
*/
413-
public function getPlatformType()
414-
{
415-
$userAgent = $this->header->getHttpUserAgent();
416-
417-
if (preg_match("/(Android)/i", $userAgent)) {
418-
return "ANDROID";
419-
}
420-
421-
if (preg_match("/(iPad|iPhone|iPod)/i", $userAgent)) {
422-
return "IOS";
423-
}
424-
425-
return "WEB";
426-
}
427-
428-
/**
429-
* Check if current platform is mobile or not
430-
*/
431-
public function isMobilePlatform()
432-
{
433-
return 'WEB' !== $this->getPlatformType();
434-
}
435-
436396
/**
437397
* Depending on the setting of state to generate invoice, we will either create an invoice or return a created one.
438398
* Invoice will be marked as successfully paid and returned.

0 commit comments

Comments
 (0)