diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit App/Base.lproj/Interface.storyboard b/SynchronyFinancial/SynchronyFinancial WatchKit App/Base.lproj/Interface.storyboard index ed397d2..037b541 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit App/Base.lproj/Interface.storyboard +++ b/SynchronyFinancial/SynchronyFinancial WatchKit App/Base.lproj/Interface.storyboard @@ -99,11 +99,13 @@ - + diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountCell.swift b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountCell.swift index 8bba624..55d6587 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountCell.swift +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountCell.swift @@ -11,4 +11,5 @@ import WatchKit class AccountCell: NSObject { @IBOutlet weak var accountName: WKInterfaceLabel! + @IBOutlet weak var last4Label: WKInterfaceLabel! } diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift index 6f06f1a..72518cd 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift @@ -48,6 +48,7 @@ class AccountTableInterfaceController: WKInterfaceController { for index in 0.. Void){ + + var paymentHeader = Defaults.headerForCancelPmt + paymentHeader["account_alias"] = accountAlias + paymentHeader["payment_confirmation_number"] = confirmationNum + paymentHeader["payment_id"] = paymentId + + Alamofire.request(Defaults.CANCEL_PAYMENT_URL, method: .post, parameters: paymentHeader, encoding: JSONEncoding.default, headers: Defaults.authHeader).responseJSON { payload in + switch payload.result { + case .success(let value): + let dict = JSON(value).dictionaryValue + guard dict["status"]?.dictionaryValue["response_code"]?.string == "0" else { return } + if let paymentCancelNum = dict["cancellation_confirmation_number"]?.stringValue { + completion(paymentCancelNum, nil) + } + case .failure(let error): + NSLog("Error: \(error.localizedDescription)") + } + } + } } diff --git a/SynchronyFinancial/SynchronyFinancial/Account.swift b/SynchronyFinancial/SynchronyFinancial/Account.swift index 21875b7..f44c8a6 100644 --- a/SynchronyFinancial/SynchronyFinancial/Account.swift +++ b/SynchronyFinancial/SynchronyFinancial/Account.swift @@ -10,6 +10,7 @@ import Foundation class Account: NSObject { var accountAlias: String var creditLimit: Double + var last4: String //var transactions: [Transaction] var paymentDueDate: Date //var cycleEndDate: Date @@ -20,9 +21,10 @@ class Account: NSObject { var statementBal: Double var accountName: String - init(accountAlias: String, creditLimit: Double, paymentDueDate: Date, curBalance: Double, availCredit: Double, minPayDue: Double, statementBal: Double, accountName: String) { + init(_ accountAlias: String, _ creditLimit: Double, _ last4: String, _ paymentDueDate: Date, _ curBalance: Double, _ availCredit: Double, _ minPayDue: Double, _ statementBal: Double, _ accountName: String) { self.accountAlias = accountAlias self.creditLimit = creditLimit + self.last4 = last4 //self.transactions = transactions //self.balance = transactions.map { $0.amount }.reduce(0.0, +) self.paymentDueDate = paymentDueDate