Skip to content

Commit

Permalink
Merge pull request #477 from omise/release-v3.7.0
Browse files Browse the repository at this point in the history
Updating metadata for v3.7.0 release
  • Loading branch information
aashishgurung authored Apr 9, 2024
2 parents 7943203 + de074d0 commit debc39f
Show file tree
Hide file tree
Showing 29 changed files with 556 additions and 253 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## [v3.7.0 _(Apr, 9, 2024)_](https://github.com/omise/omise-magento/releases/tag/v3.7.0)
- Added WeChat Pay (PR: [#475](https://github.com/omise/omise-magento/pull/475))
- Removed Pay with Points and Citi installment (PR: [#476](https://github.com/omise/omise-magento/pull/476))

## [v3.6.1 _(Feb, 12, 2024)_](https://github.com/omise/omise-magento/releases/tag/v3.6.1)
- Fixed redirect issue on cancelled card payment. (PR: [#470](https://github.com/omise/omise-magento/pull/470))

Expand Down
1 change: 1 addition & 0 deletions Cron/OrderSyncStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class OrderSyncStatus
"omise_offsite_shopeepay",
"omise_offsite_atome",
"omise_offsite_paypay",
"omise_offiste_wechat_pay"
];

/**
Expand Down
56 changes: 31 additions & 25 deletions Gateway/Request/APMBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
use Omise\Payment\Model\Config\Truemoney;
use Omise\Payment\Model\Config\Alipayplus;
use Omise\Payment\Model\Config\DuitnowOBW;
use Omise\Payment\Model\Config\Pointsciti;
use Omise\Payment\Model\Config\Installment;
use Omise\Payment\Model\Config\Mobilebanking;
use Omise\Payment\Model\Config\Rabbitlinepay;
use Omise\Payment\Model\Config\PayPay;
use Omise\Payment\Model\Config\WeChatPay;

use Omise\Payment\Helper\OmiseMoney;
use Omise\Payment\Helper\OmiseHelper as Helper;
use Omise\Payment\Model\Config\Internetbanking;
use Omise\Payment\Model\Config\Conveniencestore;
use Magento\Payment\Gateway\Helper\SubjectReader;
Expand All @@ -43,6 +42,7 @@
use Omise\Payment\Observer\MobilebankingDataAssignObserver;
use Omise\Payment\Observer\InternetbankingDataAssignObserver;
use Omise\Payment\Observer\ConveniencestoreDataAssignObserver;
use Omise\Payment\Helper\RequestHelper;

class APMBuilder implements BuilderInterface
{
Expand Down Expand Up @@ -107,14 +107,14 @@ class APMBuilder implements BuilderInterface
const SOURCE_SHIPPING = 'shipping';

/**
* @var \Omise\Payment\Helper\ReturnUrlHelper
* @var string
*/
protected $returnUrl;
const SOURCE_IP = 'ip';

/**
* @var Helper
* @var \Omise\Payment\Helper\ReturnUrlHelper
*/
protected $helper;
protected $returnUrl;

/**
* @var OmiseMoney
Expand All @@ -131,22 +131,27 @@ class APMBuilder implements BuilderInterface
*/
protected $config;

/**
* @var \Omise\Payment\Helper\RequestHelper
*/
private $requestHelper;

/**
* @param $helper \Omise\Payment\Helper\OmiseHelper
* @param $returnUrl \Omise\Payment\Helper\ReturnUrl
*/
public function __construct(
Helper $helper,
ReturnUrlHelper $returnUrl,
Config $config,
Capabilities $capabilities,
OmiseMoney $money
OmiseMoney $money,
RequestHelper $requestHelper
) {
$this->helper = $helper;
$this->returnUrl = $returnUrl;
$this->config = $config;
$this->capabilities = $capabilities;
$this->money = $money;
$this->requestHelper = $requestHelper;
}

/**
Expand Down Expand Up @@ -218,11 +223,6 @@ public function build(array $buildSubject)
self::SOURCE_TYPE => 'promptpay'
];
break;
case Pointsciti::CODE:
$paymentInfo[self::SOURCE] = [
self::SOURCE_TYPE => 'points_citi'
];
break;
case Fpx::CODE:
$paymentInfo[self::SOURCE] = [
self::SOURCE_TYPE => 'fpx',
Expand All @@ -234,43 +234,43 @@ public function build(array $buildSubject)
case Alipayplus::ALIPAY_CODE:
$paymentInfo[self::SOURCE] = [
self::SOURCE_TYPE => 'alipay_cn',
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
];
break;
case Alipayplus::ALIPAYHK_CODE:
$paymentInfo[self::SOURCE] = [
self::SOURCE_TYPE => 'alipay_hk',
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
];
break;
case Alipayplus::DANA_CODE:
$paymentInfo[self::SOURCE] = [
self::SOURCE_TYPE => 'dana',
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
];
break;
case Alipayplus::GCASH_CODE:
$paymentInfo[self::SOURCE] = [
self::SOURCE_TYPE => 'gcash',
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
];
break;
case Alipayplus::KAKAOPAY_CODE:
$paymentInfo[self::SOURCE] = [
self::SOURCE_TYPE => 'kakaopay',
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
];
break;
case Touchngo::CODE:
$paymentInfo[self::SOURCE] = [
self::SOURCE_TYPE => 'touch_n_go',
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
];
break;
case Mobilebanking::CODE:
$paymentInfo[self::SOURCE] = [
self::SOURCE_TYPE => $method->getAdditionalInformation(MobilebankingDataAssignObserver::OFFSITE),
self::PLATFORM_TYPE => $this->helper->getPlatformType()
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType()
];
break;
case Rabbitlinepay::CODE:
Expand All @@ -281,19 +281,19 @@ public function build(array $buildSubject)
case Ocbcpao::CODE:
$paymentInfo[self::SOURCE] = [
self::SOURCE_TYPE => 'mobile_banking_ocbc_pao',
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
];
break;
case OcbcDigital::CODE:
$paymentInfo[self::SOURCE] = [
self::SOURCE_TYPE => OcbcDigital::ID,
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
];
break;
case Grabpay::CODE:
$paymentInfo[self::SOURCE] = [
self::SOURCE_TYPE => 'grabpay',
self::PLATFORM_TYPE => $this->helper->getPlatformType(),
self::PLATFORM_TYPE => $this->requestHelper->getPlatformType(),
];
break;
case Boost::CODE:
Expand Down Expand Up @@ -339,6 +339,12 @@ public function build(array $buildSubject)
self::SOURCE_TYPE => PayPay::ID,
];
break;
case WeChatPay::CODE:
$paymentInfo[self::SOURCE] = [
self::SOURCE_TYPE => WeChatPay::ID,
self::SOURCE_IP => $this->requestHelper->getClientIp()
];
break;
}

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

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

Expand Down
54 changes: 7 additions & 47 deletions Helper/OmiseHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Omise\Payment\Model\Config\Config;
use Omise\Payment\Model\Config\Paynow;
use Omise\Payment\Model\Config\PayPay;
use Magento\Framework\App\Request\Http;
use Magento\Store\Model\ScopeInterface;
use Omise\Payment\Model\Config\Grabpay;
use Omise\Payment\Model\Config\Ocbcpao;
Expand All @@ -29,7 +28,6 @@
use Omise\Payment\Model\Config\Truemoney;
use Omise\Payment\Model\Config\Alipayplus;
use Omise\Payment\Model\Config\DuitnowOBW;
use Omise\Payment\Model\Config\Pointsciti;
use Omise\Payment\Model\Config\CcGooglePay;
use Omise\Payment\Model\Config\Installment;
use Omise\Payment\Model\Config\Mobilebanking;
Expand All @@ -38,14 +36,10 @@
use Omise\Payment\Model\Config\Internetbanking;
use Magento\Framework\App\Helper\AbstractHelper;
use Omise\Payment\Model\Config\Conveniencestore;
use Omise\Payment\Model\Config\WeChatPay;

class OmiseHelper extends AbstractHelper
{
/**
* @var \Magento\Framework\HTTP\Header
*/
protected $header;

/**
* @var array
*/
Expand All @@ -54,7 +48,6 @@ class OmiseHelper extends AbstractHelper
Internetbanking::CODE,
Installment::CODE,
Truemoney::CODE,
Pointsciti::CODE,
Fpx::CODE,
Alipayplus::ALIPAY_CODE,
Alipayplus::ALIPAYHK_CODE,
Expand All @@ -73,7 +66,8 @@ class OmiseHelper extends AbstractHelper
MaybankQR::CODE,
Shopeepay::CODE,
Atome::CODE,
PayPay::CODE
PayPay::CODE,
WeChatPay::CODE
];

/**
Expand Down Expand Up @@ -123,7 +117,6 @@ class OmiseHelper extends AbstractHelper
Alipay::ID => Alipay::CODE,
Truemoney::ID => Truemoney::CODE,
Truemoney::JUMPAPP_ID => Truemoney::CODE,
Pointsciti::ID => Pointsciti::CODE,
Fpx::ID => Fpx::CODE,
Alipayplus::ALIPAY_ID => Alipayplus::ALIPAY_CODE,
Alipayplus::ALIPAYHK_ID => Alipayplus::ALIPAYHK_CODE,
Expand All @@ -143,6 +136,7 @@ class OmiseHelper extends AbstractHelper
Shopeepay::JUMPAPP_ID => Shopeepay::CODE,
Atome::ID => Atome::CODE,
PayPay::ID => PayPay::CODE,
WeChatPay::ID => WeChatPay::CODE,

// offsite internet banking payment
Internetbanking::BBL_ID => Internetbanking::CODE,
Expand All @@ -151,7 +145,6 @@ class OmiseHelper extends AbstractHelper
// offsite installment banking payment
Installment::BAY_ID => Installment::CODE,
Installment::BBL_ID => Installment::CODE,
Installment::CITI_ID => Installment::CODE,
Installment::UOB_ID => Installment::CODE,
Installment::FIRST_CHOICE_ID => Installment::CODE,
Installment::KBANK_ID => Installment::CODE,
Expand Down Expand Up @@ -189,7 +182,6 @@ class OmiseHelper extends AbstractHelper
Internetbanking::CODE => "Internet Banking Payment",
Installment::CODE => "Installment Payment",
Truemoney::CODE => "TrueMoney Payment",
Pointsciti::CODE => "Citi Pay with Points",
Fpx::CODE => "FPX Payment",
Alipayplus::ALIPAY_CODE => "Alipay (Alipay+ Partner) Payment",
Alipayplus::ALIPAYHK_CODE => "AlipayHK (Alipay+ Partner) Payment",
Expand All @@ -209,6 +201,7 @@ class OmiseHelper extends AbstractHelper
Shopeepay::CODE => "ShopeePay Payment",
Atome::CODE => "Atome Payment",
PayPay::CODE => "PayPay Payment",
WeChatPay::CODE => "WeChat Pay Payment",

// offline payment
Paynow::CODE => "PayNow QR Payment",
Expand All @@ -225,16 +218,10 @@ class OmiseHelper extends AbstractHelper
/**
* @param Header $header
* @param Config $config
* @param Http $httpRequest
*/
public function __construct(
Header $header,
Config $config,
Http $httpRequest
) {
$this->header = $header;
public function __construct(Config $config)
{
$this->config = $config;
$this->httpRequest = $httpRequest;

$this->omisePaymentMethods = array_merge(
$this->offsitePaymentMethods,
Expand Down Expand Up @@ -406,33 +393,6 @@ public function is3DSecureEnabled($charge)
return false;
}

/**
* Get platform Type of WEB, IOS or ANDROID to add to source API parameter.
* @return string
*/
public function getPlatformType()
{
$userAgent = $this->header->getHttpUserAgent();

if (preg_match("/(Android)/i", $userAgent)) {
return "ANDROID";
}

if (preg_match("/(iPad|iPhone|iPod)/i", $userAgent)) {
return "IOS";
}

return "WEB";
}

/**
* Check if current platform is mobile or not
*/
public function isMobilePlatform()
{
return 'WEB' !== $this->getPlatformType();
}

/**
* Depending on the setting of state to generate invoice, we will either create an invoice or return a created one.
* Invoice will be marked as successfully paid and returned.
Expand Down
Loading

0 comments on commit debc39f

Please sign in to comment.