Skip to content

Commit

Permalink
reated PaymentOptions interface and controller for selecting payment …
Browse files Browse the repository at this point in the history
…type. Fetching bank account info and populating table with it. Updated getbankacctinfo request to grab the bank name and last 4 digits of bank account.
  • Loading branch information
rrk12005 committed Apr 5, 2019
1 parent 63bb56b commit 6ffbf64
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 16 deletions.
Original file line number Original file line Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="14490.70" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Qge-pO-HLc"> <document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="14460.31" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Qge-pO-HLc">
<device id="watch38" orientation="portrait"> <device id="watch38" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
<dependencies> <dependencies>
<deployment identifier="watchOS"/> <deployment identifier="watchOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="14490.21"/> <plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="14460.16"/>
</dependencies> </dependencies>
<scenes> <scenes>
<!--root--> <!--root-->
Expand Down Expand Up @@ -202,8 +202,11 @@
<controller id="t8d-XB-ngB" customClass="PaymentDetailInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target"> <controller id="t8d-XB-ngB" customClass="PaymentDetailInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target">
<items> <items>
<label width="1" alignment="center" text="Pay From:" textAlignment="center" id="xE5-Zl-U7d"/> <label width="1" alignment="center" text="Pay From:" textAlignment="center" id="xE5-Zl-U7d"/>
<button width="1" height="40" alignment="left" title="Synchrony (1234)" id="SZD-0B-PrF" userLabel="detailButton"> <button width="1" height="40" alignment="left" title="Select Bank" id="SZD-0B-PrF" userLabel="detailButton">
<fontDescription key="font" type="system" pointSize="15"/> <fontDescription key="font" type="system" pointSize="15"/>
<connections>
<action selector="bankAccountsTapped" destination="t8d-XB-ngB" id="bQR-Mu-nB6"/>
</connections>
</button> </button>
<separator alignment="left" verticalAlignment="center" id="et0-Sq-Qxm"> <separator alignment="left" verticalAlignment="center" id="et0-Sq-Qxm">
<color key="color" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="color" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand All @@ -226,6 +229,35 @@
</objects> </objects>
<point key="canvasLocation" x="1085" y="186"/> <point key="canvasLocation" x="1085" y="186"/>
</scene> </scene>
<!--PaymentOptions-->
<scene sceneID="T56-bi-gCI">
<objects>
<controller identifier="PaymentOptions" id="jbp-Bi-Bk7" userLabel="PaymentOptions" customClass="PaymentOptionsInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<table alignment="left" id="RJQ-am-qV6" userLabel="Banks Table">
<items>
<tableRow identifier="bankAcctCell" id="Mfw-7m-ih3" customClass="BankAcctCell" customModule="SynchronyFinancial_WatchKit_Extension">
<group key="rootItem" width="1" height="43" alignment="left" layout="vertical" id="8u2-82-z5f">
<items>
<label width="136" alignment="left" text="Bank Name" id="y0D-7u-Qtr" userLabel="Bank Name Label"/>
<label width="58" height="20" alignment="left" text="(1234)" id="FMl-Jx-r2b" userLabel="last4 Label"/>
</items>
</group>
<connections>
<outlet property="BankNameLabel" destination="y0D-7u-Qtr" id="viE-xk-diN"/>
<outlet property="Last4Label" destination="FMl-Jx-r2b" id="1ho-kI-jgE"/>
</connections>
</tableRow>
</items>
</table>
</items>
<connections>
<outlet property="bankAcctTable" destination="RJQ-am-qV6" id="mjy-8f-Qzt"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="1416" y="186"/>
</scene>
<!--Transactions--> <!--Transactions-->
<scene sceneID="yXO-yR-k6b"> <scene sceneID="yXO-yR-k6b">
<objects> <objects>
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@
// //


import Foundation import Foundation
import WatchKit

class BankAcctCell: NSObject{
@IBOutlet weak var BankNameLabel: WKInterfaceLabel!
@IBOutlet weak var Last4Label: WKInterfaceLabel!

}
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ class FetchData {
//"fetch_bank_account_details" //"fetch_bank_account_details"
dict["fetch_bank_account_details"]?.arrayValue.forEach { dict["fetch_bank_account_details"]?.arrayValue.forEach {
if let bankId = $0["bank_account_id"].string, if let bankId = $0["bank_account_id"].string,
let bankName = $0["bank_name"].string,
let last4Acct = $0["last4_bank_acct_number"].string,
let accttype: AccountType = $0["bank_account_type"].stringValue == let accttype: AccountType = $0["bank_account_type"].stringValue ==
"C" ? .checkings : .savings { "C" ? .checkings : .savings {
//print(bankId) print(bankId)
//print(accttype) print(accttype)
bankIds.append(BankAcct(bankAcctId: bankId, acctType: accttype)) bankIds.append(BankAcct(bankAcctId: bankId, acctType: accttype, bankName: bankName, last4Acct: last4Acct))
} }
} }
completion(bankIds, nil) completion(bankIds, nil)
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
import WatchKit import WatchKit
import Foundation import Foundation



class PaymentDetailInterfaceController: WKInterfaceController { class PaymentDetailInterfaceController: WKInterfaceController {
var selectedAccount: Account? var selectedAccount: Account?
var dictForAcct: [String: Account] = [:] var dictForAcct: [String: Account] = [:]
var paymentButtonArmed: Bool = false var paymentButtonArmed: Bool = false
var paymentAmount: Double = 0.0 var paymentAmount: Double = 0.0
var dictForBankAcct: [String:[BankAcct]] = [:]


@IBOutlet weak var detailButton: WKInterfaceButton! @IBOutlet weak var detailButton: WKInterfaceButton!
@IBOutlet weak var amount: WKInterfaceLabel! @IBOutlet weak var amount: WKInterfaceLabel!
Expand Down Expand Up @@ -44,6 +46,17 @@ class PaymentDetailInterfaceController: WKInterfaceController {
paymentButton.setTitle("Pay Now") paymentButton.setTitle("Pay Now")
} }
} }

@IBAction func bankAccountsTapped(){
FetchData.getBankInfo{ accts, error in guard error == nil else{
NSLog("Error retrieving payment methods for account in paymentDetailInterfaceController.")
return
}

self.dictForBankAcct.updateValue(accts, forKey: "paymentOptions")
self.pushController(withName: "PaymentOptions", context: self.dictForBankAcct)
}
}


override func willActivate() { override func willActivate() {
// This method is called when watch view controller is about to be visible to user // This method is called when watch view controller is about to be visible to user
Expand All @@ -54,4 +67,5 @@ class PaymentDetailInterfaceController: WKInterfaceController {
// This method is called when watch view controller is no longer visible // This method is called when watch view controller is no longer visible
super.didDeactivate() super.didDeactivate()
} }

} }
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,22 +9,37 @@
import WatchKit import WatchKit
import Foundation import Foundation


class BankSelectionInterfaceController: WKInterfaceController { class PaymentOptionsInterfaceController: WKInterfaceController {



@IBOutlet weak var bankAcctTable: WKInterfaceTable!
var bankAccts: [BankAcct] = []
override func awake(withContext context: Any?) { override func awake(withContext context: Any?) {
super.awake(withContext: context)

guard let data = context as? [String: [BankAcct]], let accts = data["paymentOptions"] else {
NSLog("Error receiving context containing bank accounts in PaymentOptionsInterfaceController")
return
}


bankAccts = accts
print(bankAccts.count)
configureRows()
} }

override func willActivate() { override func willActivate() {
// This method is called when watch view controller is about to be visible to user // This method is called when watch view controller is about to be visible to user
super.willActivate() super.willActivate()
} }

override func didDeactivate() { override func didDeactivate() {
// This method is called when watch view controller is no longer visible // This method is called when watch view controller is no longer visible
super.didDeactivate() super.didDeactivate()
} }

private func configureRows(){

bankAcctTable.setNumberOfRows(bankAccts.count, withRowType: "bankAcctCell")
for index in 0..<bankAcctTable.numberOfRows{
if let row = bankAcctTable.rowController(at: index) as? BankAcctCell {
row.BankNameLabel.setText(bankAccts[index].bankName)
row.Last4Label.setText("(\(bankAccts[index].last4Acct))")
}
}
}
} }
10 changes: 8 additions & 2 deletions SynchronyFinancial/SynchronyFinancial.xcodeproj/project.pbxproj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@


/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
1123372E223ABD6400B70925 /* FetchData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1123372D223ABD6400B70925 /* FetchData.swift */; }; 1123372E223ABD6400B70925 /* FetchData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1123372D223ABD6400B70925 /* FetchData.swift */; };
112969422257B8920082AAC5 /* PaymentOptionsInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 112969412257B8920082AAC5 /* PaymentOptionsInterfaceController.swift */; };
112B56512257C3D9003E9C78 /* BankAcctCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 112B56502257C3D9003E9C78 /* BankAcctCell.swift */; };
11E6ADB92253FA050009922E /* BankAcct.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11E6ADB82253FA050009922E /* BankAcct.swift */; }; 11E6ADB92253FA050009922E /* BankAcct.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11E6ADB82253FA050009922E /* BankAcct.swift */; };
11E6ADBA225401DB0009922E /* BankAcct.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11E6ADB82253FA050009922E /* BankAcct.swift */; }; 11E6ADBA225401DB0009922E /* BankAcct.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11E6ADB82253FA050009922E /* BankAcct.swift */; };
281283568A34D3C5D9C7B383 /* libPods-SynchronyFinancial WatchKit Extension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CAA6D46F907ADAABF49FD409 /* libPods-SynchronyFinancial WatchKit Extension.a */; }; 281283568A34D3C5D9C7B383 /* libPods-SynchronyFinancial WatchKit Extension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CAA6D46F907ADAABF49FD409 /* libPods-SynchronyFinancial WatchKit Extension.a */; };
481864A8224802BB0059CF7A /* PaymentDetailInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 481864A7224802BB0059CF7A /* PaymentDetailInterfaceController.swift */; };
481864A9224802BB0059CF7A /* PaymentDetailInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 481864A7224802BB0059CF7A /* PaymentDetailInterfaceController.swift */; }; 481864A9224802BB0059CF7A /* PaymentDetailInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 481864A7224802BB0059CF7A /* PaymentDetailInterfaceController.swift */; };
48DA0058221D12E70081A500 /* AccountCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48DA0057221D12E70081A500 /* AccountCell.swift */; }; 48DA0058221D12E70081A500 /* AccountCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48DA0057221D12E70081A500 /* AccountCell.swift */; };
48F243072214C98600B9C894 /* AccountTableInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48F243062214C98600B9C894 /* AccountTableInterfaceController.swift */; }; 48F243072214C98600B9C894 /* AccountTableInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48F243062214C98600B9C894 /* AccountTableInterfaceController.swift */; };
Expand Down Expand Up @@ -87,6 +88,8 @@


/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
1123372D223ABD6400B70925 /* FetchData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchData.swift; sourceTree = "<group>"; }; 1123372D223ABD6400B70925 /* FetchData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchData.swift; sourceTree = "<group>"; };
112969412257B8920082AAC5 /* PaymentOptionsInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentOptionsInterfaceController.swift; sourceTree = "<group>"; };
112B56502257C3D9003E9C78 /* BankAcctCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BankAcctCell.swift; sourceTree = "<group>"; };
11E6ADB82253FA050009922E /* BankAcct.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BankAcct.swift; sourceTree = "<group>"; }; 11E6ADB82253FA050009922E /* BankAcct.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BankAcct.swift; sourceTree = "<group>"; };
1BEF4B8BF190D117CA6104E5 /* Pods-SynchronyFinancial WatchKit App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SynchronyFinancial WatchKit App.release.xcconfig"; path = "Pods/Target Support Files/Pods-SynchronyFinancial WatchKit App/Pods-SynchronyFinancial WatchKit App.release.xcconfig"; sourceTree = "<group>"; }; 1BEF4B8BF190D117CA6104E5 /* Pods-SynchronyFinancial WatchKit App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SynchronyFinancial WatchKit App.release.xcconfig"; path = "Pods/Target Support Files/Pods-SynchronyFinancial WatchKit App/Pods-SynchronyFinancial WatchKit App.release.xcconfig"; sourceTree = "<group>"; };
250BDAF6AD4E1CCA82995E30 /* Pods-SynchronyFinancial WatchKit Extension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SynchronyFinancial WatchKit Extension.release.xcconfig"; path = "Pods/Target Support Files/Pods-SynchronyFinancial WatchKit Extension/Pods-SynchronyFinancial WatchKit Extension.release.xcconfig"; sourceTree = "<group>"; }; 250BDAF6AD4E1CCA82995E30 /* Pods-SynchronyFinancial WatchKit Extension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SynchronyFinancial WatchKit Extension.release.xcconfig"; path = "Pods/Target Support Files/Pods-SynchronyFinancial WatchKit Extension/Pods-SynchronyFinancial WatchKit Extension.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -217,6 +220,8 @@
676392B52242A3F800740A8C /* TransactionCell.swift */, 676392B52242A3F800740A8C /* TransactionCell.swift */,
67BAC293219E254900713FEF /* Info.plist */, 67BAC293219E254900713FEF /* Info.plist */,
1123372D223ABD6400B70925 /* FetchData.swift */, 1123372D223ABD6400B70925 /* FetchData.swift */,
112969412257B8920082AAC5 /* PaymentOptionsInterfaceController.swift */,
112B56502257C3D9003E9C78 /* BankAcctCell.swift */,
); );
path = "SynchronyFinancial WatchKit Extension"; path = "SynchronyFinancial WatchKit Extension";
sourceTree = "<group>"; sourceTree = "<group>";
Expand Down Expand Up @@ -471,7 +476,6 @@
674BD1532239A39D0076AFD6 /* PayBillInterfaceController.swift in Sources */, 674BD1532239A39D0076AFD6 /* PayBillInterfaceController.swift in Sources */,
48F2430D2214CBF700B9C894 /* Account.swift in Sources */, 48F2430D2214CBF700B9C894 /* Account.swift in Sources */,
678C388622309F7D00FEAAF6 /* AccountCell.swift in Sources */, 678C388622309F7D00FEAAF6 /* AccountCell.swift in Sources */,
481864A8224802BB0059CF7A /* PaymentDetailInterfaceController.swift in Sources */,
11E6ADB92253FA050009922E /* BankAcct.swift in Sources */, 11E6ADB92253FA050009922E /* BankAcct.swift in Sources */,
48F2430E2214CBF700B9C894 /* Transaction.swift in Sources */, 48F2430E2214CBF700B9C894 /* Transaction.swift in Sources */,
67BAC269219E254700713FEF /* AppDelegate.swift in Sources */, 67BAC269219E254700713FEF /* AppDelegate.swift in Sources */,
Expand All @@ -483,13 +487,15 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
11E6ADBA225401DB0009922E /* BankAcct.swift in Sources */, 11E6ADBA225401DB0009922E /* BankAcct.swift in Sources */,
112B56512257C3D9003E9C78 /* BankAcctCell.swift in Sources */,
678C3885223098C400FEAAF6 /* Account.swift in Sources */, 678C3885223098C400FEAAF6 /* Account.swift in Sources */,
67BAC28E219E254900713FEF /* ExtensionDelegate.swift in Sources */, 67BAC28E219E254900713FEF /* ExtensionDelegate.swift in Sources */,
674BD1542239A39D0076AFD6 /* PayBillInterfaceController.swift in Sources */, 674BD1542239A39D0076AFD6 /* PayBillInterfaceController.swift in Sources */,
678C38842230950100FEAAF6 /* AccountDetailsInterfaceController.swift in Sources */, 678C38842230950100FEAAF6 /* AccountDetailsInterfaceController.swift in Sources */,
673F396E21A644570051469E /* MainMenuInterfaceController.swift in Sources */, 673F396E21A644570051469E /* MainMenuInterfaceController.swift in Sources */,
67E17B87223812C2008871FE /* Defaults.swift in Sources */, 67E17B87223812C2008871FE /* Defaults.swift in Sources */,
1123372E223ABD6400B70925 /* FetchData.swift in Sources */, 1123372E223ABD6400B70925 /* FetchData.swift in Sources */,
112969422257B8920082AAC5 /* PaymentOptionsInterfaceController.swift in Sources */,
48F243072214C98600B9C894 /* AccountTableInterfaceController.swift in Sources */, 48F243072214C98600B9C894 /* AccountTableInterfaceController.swift in Sources */,
676392B62242A3F800740A8C /* TransactionCell.swift in Sources */, 676392B62242A3F800740A8C /* TransactionCell.swift in Sources */,
48F2430F2214CC2200B9C894 /* Transaction.swift in Sources */, 48F2430F2214CC2200B9C894 /* Transaction.swift in Sources */,
Expand Down
6 changes: 5 additions & 1 deletion SynchronyFinancial/SynchronyFinancial/BankAcct.swift
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ public enum AccountType: Int {
class BankAcct: NSObject { class BankAcct: NSObject {
var bankAcctId: String var bankAcctId: String
var acctType: AccountType var acctType: AccountType
init(bankAcctId: String, acctType: AccountType) { var bankName: String
var last4Acct: String
init(bankAcctId: String, acctType: AccountType, bankName: String, last4Acct: String) {
self.bankAcctId = bankAcctId self.bankAcctId = bankAcctId
self.acctType = acctType self.acctType = acctType
self.bankName = bankName
self.last4Acct = last4Acct
} }
} }

0 comments on commit 6ffbf64

Please sign in to comment.