-
Notifications
You must be signed in to change notification settings - Fork 0
Swe 13 choose bank account #15
Changes from 9 commits
63bb56b
6ffbf64
18c29c8
0b6fb67
76ef026
61ca428
520d31a
cc16cdf
3594b68
0c9a242
8b78622
d60bd62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// BankAcctCell.swift | ||
// SynchronyFinancial WatchKit Extension | ||
// | ||
// Created by Rahul Kantesaria on 4/5/19. | ||
// Copyright © 2019 Alan Maynard. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import WatchKit | ||
|
||
class BankAcctCell: NSObject { | ||
@IBOutlet weak var bankNameLabel: WKInterfaceLabel! | ||
@IBOutlet weak var last4Label: WKInterfaceLabel! | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,22 +15,24 @@ class PaymentDetailInterfaceController: WKInterfaceController { | |
var dictForPayment: [String: String] = [:] | ||
var paymentButtonArmed: Bool = false | ||
var paymentAmount: Double = 0.0 | ||
|
||
@IBOutlet weak var contentGroup: WKInterfaceGroup! | ||
var dictForBankAcct: [String: [BankAcct]] = [:] | ||
//var bankID: String = "" | ||
@IBOutlet weak var activityIndicator: WKInterfaceImage! | ||
@IBOutlet weak var activityIndicatorLabel: WKInterfaceLabel! | ||
@IBOutlet weak var contentGroup: WKInterfaceGroup! | ||
@IBOutlet weak var detailButton: WKInterfaceButton! | ||
@IBOutlet weak var amount: WKInterfaceLabel! | ||
@IBOutlet weak var paymentButton: WKInterfaceButton! | ||
@IBOutlet weak var payFrom: WKInterfaceLabel! | ||
@IBOutlet weak var separate: WKInterfaceSeparator! | ||
|
||
|
||
override func awake(withContext context: Any?) { | ||
super.awake(withContext: context) | ||
|
||
guard let data = context as? [String: Any], | ||
let acct = data["acct"] as? Account, | ||
let amount = data["payment_amount"] as? Double else { | ||
NSLog("Error getting account object and payment amount") | ||
return | ||
|
||
guard let data = context as? [String: Any], let acct = data["acct"] as? Account, let amount = data["payment_amount"] as? Double else { | ||
NSLog("Error getting account object and payment amount") | ||
return | ||
} | ||
|
||
self.paymentAmount = amount | ||
|
@@ -50,12 +52,17 @@ 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 | ||
FetchData.submitPayment(for: alias, type: type, amount: self.paymentAmount, bankID: "9999") { confirmationNum, paymentID, error in | ||
guard let bankacct = UserDefaults.standard.dictionary(forKey: "default_bank_acct") as? [String: String], let bankID = bankacct["bankAcctId"] else{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our extension on |
||
NSLog("Error retrieving Payment Option") | ||
return | ||
} | ||
FetchData.submitPayment(for: alias, type: type, amount: self.paymentAmount, bankID: bankID) { 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]) | ||
return | ||
} | ||
|
||
self.dictForPayment.updateValue(confirmationNum, forKey: "payment_confirmation_number") | ||
self.dictForPayment.updateValue(paymentID, forKey: "payment_id") | ||
self.activityIndicator.stopAnimatingAsIndicator() | ||
|
@@ -74,14 +81,45 @@ class PaymentDetailInterfaceController: WKInterfaceController { | |
} | ||
} | ||
} | ||
|
||
@IBAction func bankAccountsTapped() { | ||
configureInterfaceObjects(true) | ||
activityIndicator.configureForActivityIndicator() | ||
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.configureInterfaceObjects(false) | ||
//self.detailButton.setTitle("Hello") | ||
self.activityIndicator.stopAnimatingAsIndicator() | ||
self.pushController(withName: "PaymentOptions", context: self.dictForBankAcct) | ||
} | ||
|
||
} | ||
|
||
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] { | ||
detailButton.setTitle(bankacct["bankName"]) | ||
} | ||
} | ||
|
||
override func didDeactivate() { | ||
// This method is called when watch view controller is no longer visible | ||
super.didDeactivate() | ||
} | ||
|
||
private func configureInterfaceObjects(_ hide: Bool) { | ||
detailButton.setHidden(hide) | ||
amount.setHidden(hide) | ||
paymentButton.setHidden(hide) | ||
payFrom.setHidden(hide) | ||
separate.setHidden(hide) | ||
contentGroup.setHidden(hide) | ||
activityIndicatorLabel.setVerticalAlignment(.center) | ||
activityIndicatorLabel.setHidden(!hide) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// BankSelectionInterfaceController.swift | ||
// SynchronyFinancial WatchKit Extension | ||
// | ||
// Created by Rahul Kantesaria on 4/5/19. | ||
// Copyright © 2019 Alan Maynard. All rights reserved. | ||
// | ||
|
||
import WatchKit | ||
import Foundation | ||
|
||
class PaymentOptionsInterfaceController: WKInterfaceController { | ||
@IBOutlet weak var bankAcctTable: WKInterfaceTable! | ||
var bankAccts: [BankAcct] = [] | ||
var dictForDefault: [String: String] = [:] | ||
override func awake(withContext context: Any?) { | ||
super.awake(withContext: context) | ||
//grab the potential list of bank accounts from the payment detail controller | ||
guard let data = context as? [String: [BankAcct]], let accts = data["paymentOptions"] else { | ||
NSLog("Error receiving context containing bank accounts in PaymentOptionsInterfaceController") | ||
return | ||
} | ||
bankAccts = accts | ||
configureRows() | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. insert new line after this closing brace |
||
|
||
override func willActivate() { | ||
// This method is called when watch view controller is about to be visible to user | ||
super.willActivate() | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. insert new line after this closing brace |
||
|
||
override func didDeactivate() { | ||
// This method is called when watch view controller is no longer visible | ||
super.didDeactivate() | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. insert new line after this closing brace |
||
|
||
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))") | ||
} | ||
} | ||
} | ||
|
||
override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) { | ||
let acct = bankAccts[rowIndex] | ||
dictForDefault.updateValue(acct.acctType.rawValue, forKey: "acctType") | ||
dictForDefault.updateValue(acct.bankAcctId, forKey: "bankAcctId") | ||
dictForDefault.updateValue(acct.bankName, forKey: "bankName") | ||
dictForDefault.updateValue(acct.last4Acct, forKey: "last4Acct") | ||
UserDefaults.standard.set(dictForDefault, forKey: "default_bank_acct") | ||
pop() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super.awake(withContext: context)
should be the first call within this functionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think you intend to show the
activityIndicatorLabel
here and then hide it again once web service returns