Skip to content

Commit

Permalink
Merge pull request #244 from omise/feature/MIT-1747-Truemoney
Browse files Browse the repository at this point in the history
Add payment method Truemoney JumpApp
  • Loading branch information
Andrei Solovev authored Nov 28, 2023
2 parents 8983418 + 0c2715c commit 501b7ee
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 118 deletions.
162 changes: 90 additions & 72 deletions ExampleApp/Resources/Main.storyboard

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions ExampleApp/Shared/PaymentSettingTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class PaymentSettingTableViewController: UITableViewController {
@IBOutlet private var promptpayPaymentCell: UITableViewCell!
@IBOutlet private var paynowPaymentCell: UITableViewCell!
@IBOutlet private var truemoneyPaymentCell: UITableViewCell!
@IBOutlet private var truemoneyJumpAppPaymentCell: UITableViewCell!
@IBOutlet private var pointsCitiCell: UITableViewCell!
@IBOutlet private var fpxCell: UITableViewCell!
@IBOutlet private var rabbitLinepayCell: UITableViewCell!
Expand Down Expand Up @@ -329,6 +330,8 @@ extension PaymentSettingTableViewController {
return .payNow
case truemoneyPaymentCell:
return .trueMoney
case truemoneyJumpAppPaymentCell:
return .trueMoneyJumpApp
case pointsCitiCell:
return .pointsCiti
case fpxCell:
Expand Down Expand Up @@ -425,6 +428,8 @@ extension PaymentSettingTableViewController {
return payPayPaymentCell
case .trueMoney:
return truemoneyPaymentCell
case .trueMoneyJumpApp:
return truemoneyJumpAppPaymentCell
case .pointsCiti:
return pointsCitiCell
case .fpx:
Expand Down
15 changes: 10 additions & 5 deletions OmiseSDK/Capability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ extension Capability {
case promptpay
case paynow
case truemoney
case truemoneyJumpApp
case points(PaymentInformation.Points)
case eContext
case fpx
Expand Down Expand Up @@ -276,6 +277,8 @@ extension Capability.Backend {
self.payment = .paynow
case .source(.trueMoney):
self.payment = .truemoney
case .source(.trueMoneyJumpApp):
self.payment = .truemoneyJumpApp
case .source(.pointsCiti):
self.payment = .points(.citiPoints)
case .source(.billPaymentTescoLotus):
Expand Down Expand Up @@ -331,12 +334,12 @@ extension Capability.Backend {
case .installment(_, availableNumberOfTerms: let availableNumberOfTerms):
try container.encode(Array(availableNumberOfTerms), forKey: .allowedInstallmentTerms)
try container.encode(Array(supportedCurrencies), forKey: .supportedCurrencies)
case .internetBanking, .alipay, .alipayCN, .alipayHK, .atome, .dana, .gcash, .kakaoPay, .touchNGoAlipayPlus, .touchNGo, .promptpay, .paynow, .truemoney, .truemoneyJumpApp, .points, .billPayment, .eContext, .mobileBanking, .fpx, .rabbitLinepay, .ocbcPao, .ocbcDigital, .grabPay, .grabPayRms, .boost, .shopeePay, .shopeePayJumpApp, .maybankQRPay, .duitNowQR, .duitNowOBW, .payPay:
// swiftlint:disable:previous line_length
try container.encode(Array(supportedCurrencies), forKey: .supportedCurrencies)
case .unknownSource(_, configurations: let configurations):
try encoder.encodeJSONDictionary(configurations)
try container.encode(Array(supportedCurrencies), forKey: .supportedCurrencies)
// swiftlint:disable:next line_length
case .internetBanking, .alipay, .alipayCN, .alipayHK, .atome, .dana, .gcash, .kakaoPay, .touchNGoAlipayPlus, .touchNGo, .promptpay, .paynow, .truemoney, .points, .billPayment, .eContext, .mobileBanking, .fpx, .rabbitLinepay, .ocbcPao, .ocbcDigital, .grabPay, .grabPayRms, .boost, .shopeePay, .shopeePayJumpApp, .maybankQRPay, .duitNowQR, .duitNowOBW, .payPay:
try container.encode(Array(supportedCurrencies), forKey: .supportedCurrencies)
}
}
}
Expand Down Expand Up @@ -401,14 +404,14 @@ extension Capability.Backend {
self = .source(OMSSourceTypeValue(banking.type))
case .billPayment(let billPayment):
self = .source(OMSSourceTypeValue(billPayment.type))
case .unknownSource(let sourceType, configurations: _):
self = .source(.init(sourceType))
case .promptpay:
self = .source(.promptPay)
case .paynow:
self = .source(.payNow)
case .truemoney:
self = .source(.trueMoney)
case .truemoneyJumpApp:
self = .source(.trueMoneyJumpApp)
case .points(let points):
self = .source(OMSSourceTypeValue(points.type))
case .eContext:
Expand Down Expand Up @@ -439,6 +442,8 @@ extension Capability.Backend {
self = .source(.duitNowOBW)
case .payPay:
self = .source(.payPay)
case .unknownSource(let sourceType, configurations: _):
self = .source(.init(sourceType))
}
}

Expand Down
5 changes: 5 additions & 0 deletions OmiseSDK/Compatibility/OmiseCapability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public class __OmiseCapabilitySourceBackendPayment: __OmiseCapabilityBackendPaym
static let truemoneySourceBackendPayment =
__OmiseCapabilitySourceBackendPayment(sourceType: OMSSourceTypeValue.trueMoney)

static let truemoneyJumpAppSourceBackendPayment =
__OmiseCapabilitySourceBackendPayment(sourceType: OMSSourceTypeValue.trueMoneyJumpApp)

static let cityPointsSourceBackendPayment =
__OmiseCapabilitySourceBackendPayment(sourceType: OMSSourceTypeValue.pointsCiti)

Expand Down Expand Up @@ -202,6 +205,8 @@ extension __OmiseCapabilityBackendPayment {
return __OmiseCapabilitySourceBackendPayment.paynowSourceBackendPayment
case .truemoney:
return __OmiseCapabilitySourceBackendPayment.truemoneySourceBackendPayment
case .truemoneyJumpApp:
return __OmiseCapabilitySourceBackendPayment.truemoneyJumpAppSourceBackendPayment
case .points(let points):
return __OmiseCapabilitySourceBackendPayment(sourceType: OMSSourceTypeValue(points.type))
case .eContext:
Expand Down
6 changes: 6 additions & 0 deletions OmiseSDK/Compatibility/OmiseSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public class __SourcePaymentInformation: NSObject {

/// Payment Information for a PayPay Payment
public static let paypayPayment = __SourcePaymentInformation(type: OMSSourceTypeValue.payPay)!

/// Payment Information for an Truemoney JumpApp
public static let truemoneyJumpAppPayment = __SourcePaymentInformation(type: OMSSourceTypeValue.trueMoneyJumpApp)!
}

/// Internet Bankning Source Payment Information
Expand Down Expand Up @@ -649,6 +652,9 @@ extension __SourcePaymentInformation {
case .truemoney(let trueMoney):
return __SourceTrueMoneyPayment(phoneNumber: trueMoney.phoneNumber)

case .truemoneyJumpApp:
return __SourcePaymentInformation.truemoneyJumpAppPayment

case .points(let points):
switch points {
case .citiPoints:
Expand Down
2 changes: 1 addition & 1 deletion OmiseSDK/Globals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ extension OMSSourceTypeValue {
return "promptpay"
case .payNow:
return "paynow"
case .trueMoney:
case .trueMoney, .trueMoneyJumpApp:
return "truemoney"
case .pointsCiti:
return "points"
Expand Down
50 changes: 11 additions & 39 deletions OmiseSDK/PaymentChooserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ enum PaymentChooserOption: CaseIterable, Equatable, CustomStringConvertible {
case promptpay
case paynow
case truemoney
case truemoneyJumpApp
case citiPoints
case fpx
case rabbitLinepay
Expand All @@ -38,45 +39,6 @@ enum PaymentChooserOption: CaseIterable, Equatable, CustomStringConvertible {
case grabPayRms
case payPay

static var allCases: [PaymentChooserOption] {
return [
.creditCard,
.installment,
.truemoney,
.promptpay,
.citiPoints,
.alipay,
.alipayCN,
.alipayHK,
.atome,
.dana,
.gcash,
.kakaoPay,
.touchNGoAlipayPlus,
.internetBanking,
.mobileBanking,
.tescoLotus,
.paynow,
.conbini,
.payEasy,
.netBanking,
.fpx,
.rabbitLinepay,
.ocbcPao,
.ocbcDigital,
.grabPay,
.boost,
.shopeePay,
.shopeePayJumpApp,
.maybankQRPay,
.duitNowQR,
.duitNowOBW,
.touchNGo,
.grabPayRms,
.payPay
]
}

var description: String {
switch self {
case .creditCard:
Expand Down Expand Up @@ -116,6 +78,8 @@ enum PaymentChooserOption: CaseIterable, Equatable, CustomStringConvertible {
case .paynow:
return "PayNow"
case .truemoney:
return "TrueMoney Wallet"
case .truemoneyJumpApp:
return "TrueMoney"
case .citiPoints:
return "CitiPoints"
Expand Down Expand Up @@ -157,6 +121,8 @@ extension PaymentChooserOption {
switch sourceType {
case .trueMoney:
return [.truemoney]
case .trueMoneyJumpApp:
return [.truemoneyJumpApp]
case .installmentFirstChoice, .installmentMBB, .installmentKBank, .installmentKTC,
.installmentBBL, .installmentBAY, .installmentSCB, .installmentCiti, .installmentTTB, .installmentUOB:
return [.installment]
Expand Down Expand Up @@ -397,6 +363,8 @@ class PaymentChooserViewController: AdaptableStaticTableViewController<PaymentCh
case .atome:
goToAtome()
return
case .truemoneyJumpApp:
payment = .truemoneyJumpApp
default:
return
}
Expand Down Expand Up @@ -491,6 +459,8 @@ class PaymentChooserViewController: AdaptableStaticTableViewController<PaymentCh
return IndexPath(row: 31, section: 0)
case .payPay:
return IndexPath(row: 32, section: 0)
case .truemoneyJumpApp:
return IndexPath(row: 33, section: 0)
}
}

Expand Down Expand Up @@ -526,6 +496,8 @@ class PaymentChooserViewController: AdaptableStaticTableViewController<PaymentCh
return OMSSourceTypeValue.payNow
case .truemoney:
return OMSSourceTypeValue.trueMoney
case .truemoneyJumpApp:
return OMSSourceTypeValue.trueMoneyJumpApp
case .points(let points):
return OMSSourceTypeValue(points.type)
case .installment(let brand, availableNumberOfTerms: _):
Expand Down
6 changes: 6 additions & 0 deletions OmiseSDK/PaymentInformation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public enum PaymentInformation: Codable, Equatable {

/// TrueMoney Payment Source
case truemoney(TrueMoney)
case truemoneyJumpApp

/// The name of the supported services to process the Points Payment
public enum Points: PaymentMethod {
Expand Down Expand Up @@ -479,6 +480,9 @@ public enum PaymentInformation: Codable, Equatable {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(OMSSourceTypeValue.trueMoney.rawValue, forKey: .type)
try trueMoney.encode(to: encoder)
case .truemoneyJumpApp:
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(OMSSourceTypeValue.trueMoneyJumpApp.rawValue, forKey: .type)
case .points(let points):
try points.encode(to: encoder)
case .mobileBanking(let value):
Expand Down Expand Up @@ -641,6 +645,8 @@ extension PaymentInformation {
return OMSSourceTypeValue.payNow.rawValue
case .truemoney:
return OMSSourceTypeValue.trueMoney.rawValue
case .truemoneyJumpApp:
return OMSSourceTypeValue.trueMoneyJumpApp.rawValue
case .rabbitLinepay:
return OMSSourceTypeValue.rabbitLinepay.rawValue
case .ocbcPao:
Expand Down
32 changes: 31 additions & 1 deletion OmiseSDK/Resources/Base.lproj/OmiseSDK.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@
<edgeInsets key="layoutMargins" top="0.0" left="16" bottom="0.0" right="16"/>
</view>
<view key="tableFooterView" contentMode="scaleToFill" id="g6L-kx-hv0">
<rect key="frame" x="0.0" y="2190" width="375" height="0.0"/>
<rect key="frame" x="0.0" y="2234" width="375" height="0.0"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
Expand Down Expand Up @@ -1541,6 +1541,35 @@
<outlet property="accessoryView" destination="D7y-S8-lpb" id="xc1-ck-phc"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" textLabel="ext-Bd-tya" imageView="DqM-AD-5EN" rowHeight="64" style="IBUITableViewCellStyleDefault" id="8Jf-6P-yPa" customClass="PaymentOptionTableViewCell" customModule="OmiseSDK">
<rect key="frame" x="0.0" y="2162" width="375" height="64"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="8Jf-6P-yPa" id="btz-8Q-gzS">
<rect key="frame" x="0.0" y="0.0" width="375" height="64"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" ambiguous="YES" insetsLayoutMarginsFromSafeArea="NO" text="TrueMoney" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="ext-Bd-tya">
<rect key="frame" x="55" y="0.0" width="312" height="64"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>
<color key="textColor" red="0.23999999999999999" green="0.25" blue="0.29999999999999999" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" insetsLayoutMarginsFromSafeArea="NO" image="TrueMoney" adjustsImageSizeForAccessibilityContentSizeCategory="YES" id="DqM-AD-5EN">
<rect key="frame" x="8" y="16" width="32" height="32"/>
<autoresizingMask key="autoresizingMask"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" image="Redirect" translatesAutoresizingMaskIntoConstraints="NO" id="XXk-p5-owH">
<rect key="frame" x="345" y="23" width="16" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<color key="tintColor" red="0.89019607840000003" green="0.90588235289999997" blue="0.92549019610000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</imageView>
</subviews>
</tableViewCellContentView>
<connections>
<outlet property="accessoryView" destination="XXk-p5-owH" id="5Fe-1O-OnN"/>
</connections>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
Expand Down Expand Up @@ -1591,6 +1620,7 @@
<outletCollection property="paymentMethodNameLables" destination="fi0-U5-Eu6" collectionClass="NSMutableArray" id="UGU-T7-caB"/>
<outletCollection property="paymentMethodNameLables" destination="gf2-Jc-sHw" collectionClass="NSMutableArray" id="7eO-oS-VyU"/>
<outletCollection property="paymentMethodNameLables" destination="ydy-jp-KSj" collectionClass="NSMutableArray" id="f5v-xU-SnZ"/>
<outletCollection property="paymentMethodNameLables" destination="ext-Bd-tya" collectionClass="NSMutableArray" id="nP2-zR-ud7"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="zoe-8g-RM3" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
1 change: 1 addition & 0 deletions OmiseSDKObjc/OMSConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValuePayNow;
extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueTouchNGo;
extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueTouchNGoAlipayPlus;
extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueTrueMoney;
extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueTrueMoneyJumpApp;
extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValuePointsCiti;
extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueFpx;
extern OMSSourceTypeValue const _Nonnull OMSSourceTypeValueMobileBankingKBank;
Expand Down
1 change: 1 addition & 0 deletions OmiseSDKObjc/OMSConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
OMSSourceTypeValue const _Nonnull OMSSourceTypeValuePromptPay = @"promptpay";
OMSSourceTypeValue const _Nonnull OMSSourceTypeValuePayNow = @"paynow";
OMSSourceTypeValue const _Nonnull OMSSourceTypeValueTrueMoney = @"truemoney";
OMSSourceTypeValue const _Nonnull OMSSourceTypeValueTrueMoneyJumpApp = @"truemoney_jumpapp";
OMSSourceTypeValue const _Nonnull OMSSourceTypeValuePointsCiti = @"points_citi";
OMSSourceTypeValue const _Nonnull OMSSourceTypeValueFpx = @"fpx";
OMSSourceTypeValue const _Nonnull OMSSourceTypeValueRabbitLinepay = @"rabbit_linepay";
Expand Down
24 changes: 24 additions & 0 deletions OmiseSDKTests/PaymentInformationTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,30 @@ class PaymentInformationTestCase: XCTestCase {
}
}

func testEncodeTrueMoneyJumpAppSourceParameter() throws {
let encoder = PaymentInformationTestCase.makeJSONEncoder()

do {
let sourceParameter = Source.CreateParameter(paymentInformation: .truemoneyJumpApp,
amount: 10_000_00,
currency: .thb)
let encodedJSONString = String(data: try encoder.encode(sourceParameter), encoding: .utf8)
XCTAssertEqual(
"""
{
"amount" : 1000000,
"currency" : "THB",
"email" : null,
"items" : null,
"name" : null,
"phone_number" : null,
"platform_type" : "IOS",
"shipping" : null,
"type" : "truemoney_jumpapp"
}
""", encodedJSONString)
}
}
func testEncodePointsSourceParameter() throws {
let encoder = PaymentInformationTestCase.makeJSONEncoder()

Expand Down

0 comments on commit 501b7ee

Please sign in to comment.