Skip to content
Permalink
Browse files

SWE-13 Integration of UserDefaults+Extension as the getter for bankAc…

…ctInfo from UserDefaults in updating the selected bank account label as well as passing bankId in submit payment
  • Loading branch information
rrk12005 committed Apr 10, 2019
1 parent 8b78622 commit d60bd62a24c3ffccd38ffd971695aa909ccc1c33
@@ -267,7 +267,7 @@
</connections>
</controller>
</objects>
<point key="canvasLocation" x="1416" y="186"/>
<point key="canvasLocation" x="1400" y="186"/>
</scene>
<!--PaymentResult-->
<scene sceneID="mFc-oM-oG1">
@@ -287,7 +287,7 @@
</connections>
</controller>
</objects>
<point key="canvasLocation" x="1416" y="516"/>
<point key="canvasLocation" x="1400" y="516"/>
</scene>
<!--Transactions-->
<scene sceneID="yXO-yR-k6b">
@@ -316,7 +316,7 @@
</connections>
</controller>
</objects>
<point key="canvasLocation" x="1085" y="-229"/>
<point key="canvasLocation" x="1085" y="-233"/>
</scene>
<!--TransactionDetails-->
<scene sceneID="aqX-eB-bdU">
@@ -356,7 +356,7 @@
</connections>
</controller>
</objects>
<point key="canvasLocation" x="1420" y="-229.5"/>
<point key="canvasLocation" x="1400" y="-233"/>
</scene>
<!--Cancellation-->
<scene sceneID="ZZZ-KP-exO">
@@ -375,7 +375,7 @@
</connections>
</controller>
</objects>
<point key="canvasLocation" x="1806" y="-229"/>
<point key="canvasLocation" x="1722" y="-229"/>
</scene>
</scenes>
<inferredMetricsTieBreakers>
@@ -51,12 +51,11 @@ class PaymentDetailInterfaceController: WKInterfaceController {
let type: PaymentType = self.paymentAmount == self.selectedAccount?.curBalance ? .currentBal : .minimumDue

// process this payment using default bank account (9999) until ability to change account is implemented
guard let bankacct = UserDefaults.standard.dictionary(forKey: "default_bank_acct") as? [String: String],
let bankID = bankacct["bankAcctId"] else {
NSLog("Error retrieving Payment Option")
return
guard let bankacct = UserDefaults.standard.getDefaultBankAccount() else {
NSLog("Error retrieving Payment Option")
return
}
FetchData.submitPayment(for: alias, type: type, amount: self.paymentAmount, bankID: bankID) { confirmationNum, paymentID, error in
FetchData.submitPayment(for: alias, type: type, amount: self.paymentAmount, bankID: bankacct.bankAcctId) { confirmationNum, paymentID, error in
guard error == nil else {
let dismiss = WKAlertAction(title: "Dismiss", style: .cancel, handler: {})
self.presentAlert(withTitle: "Error", message: "We were unable to process your payment at this time. Please try again later.", preferredStyle: .alert, actions: [dismiss])
@@ -101,9 +100,15 @@ class PaymentDetailInterfaceController: WKInterfaceController {
override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
if let bankacct = UserDefaults.standard.dictionary(forKey: "default_bank_acct") as? [String: String] {
/*if let bankacct = UserDefaults.standard.dictionary(forKey: "default_bank_acct") as? [String: String] {
detailButton.setTitle(bankacct["bankName"])
}*/
//let userDefaults = UserDefaults.standard
guard let bankacct = UserDefaults.standard.getDefaultBankAccount() else {
NSLog("Error recieving default bank account in Payment Details Controller")
return
}
detailButton.setTitle(bankacct.bankName)
}

override func didDeactivate() {
@@ -222,6 +222,7 @@
67293CF022542F15009E0E7A /* TransactionDetailsInterfaceController.swift */,
674BD1522239A39D0076AFD6 /* PayBillInterfaceController.swift */,
481864A7224802BB0059CF7A /* PaymentDetailInterfaceController.swift */,
112969412257B8920082AAC5 /* PaymentOptionsInterfaceController.swift */,
676392B322429DC800740A8C /* TransactionsInterfaceController.swift */,
673F396C21A644460051469E /* MainMenuInterfaceController.swift */,
67228CD7224D6E2700CA29E4 /* WKInterfaceImage+Extensions.swift */,
@@ -231,10 +232,9 @@
67BAC291219E254900713FEF /* Assets.xcassets */,
48DA0057221D12E70081A500 /* AccountCell.swift */,
676392B52242A3F800740A8C /* TransactionCell.swift */,
112B56502257C3D9003E9C78 /* BankAcctCell.swift */,
67BAC293219E254900713FEF /* Info.plist */,
1123372D223ABD6400B70925 /* FetchData.swift */,
112969412257B8920082AAC5 /* PaymentOptionsInterfaceController.swift */,
112B56502257C3D9003E9C78 /* BankAcctCell.swift */,
);
path = "SynchronyFinancial WatchKit Extension";
sourceTree = "<group>";
@@ -14,8 +14,13 @@ extension UserDefaults {
}

func getDefaultBankAccount() -> BankAcct? {
if let bank = UserDefaults.standard.value(forKey: "default_bank_acct") as? BankAcct {
return bank
if let bankDict = UserDefaults.standard.value(forKey: "default_bank_acct") as? [String: String],
let bankAcctId = bankDict["bankAcctId"],
let acctTypeRaw: String = bankDict["acctType"],
let bankName = bankDict["bankName"],
let last4Acct = bankDict["last4Acct"],
let acctType: AccountType = AccountType(rawValue: acctTypeRaw) {
return BankAcct(bankAcctId: bankAcctId, acctType: acctType, bankName: bankName, last4Acct: last4Acct)
}
return nil
}

0 comments on commit d60bd62

Please sign in to comment.
You can’t perform that action at this time.