From ffd4f19259cc10ffff85d738b26852ce079293b0 Mon Sep 17 00:00:00 2001 From: Rahul Kantesaria Date: Wed, 3 Apr 2019 13:46:00 -0400 Subject: [PATCH 1/2] Added request for payment cancelation --- .../FetchData.swift | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/FetchData.swift b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/FetchData.swift index a3f3558..995d6b5 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/FetchData.swift +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/FetchData.swift @@ -151,5 +151,24 @@ class FetchData { } } - + static func cancelPayment(accountAlias: String, confirmationNum: String, paymentId: Int, completion: @escaping (String, Error?) -> 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)") + } + } + } } From 41a9d58cee846c2e15a287b72ad9264f7c7a3c57 Mon Sep 17 00:00:00 2001 From: Alan Maynard Date: Thu, 4 Apr 2019 11:31:58 -0400 Subject: [PATCH 2/2] SWF-21 Implemented last 4 digits display - we now grab the last 4 digits of account number and store on the `Account` object - modified the `AccountCell` and table displays to reflect this change --- .../Base.lproj/Interface.storyboard | 4 +++- .../SynchronyFinancial WatchKit Extension/AccountCell.swift | 1 + .../AccountTableInterfaceController.swift | 1 + .../SynchronyFinancial WatchKit Extension/FetchData.swift | 3 ++- SynchronyFinancial/SynchronyFinancial/Account.swift | 4 +++- 5 files changed, 10 insertions(+), 3 deletions(-) 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..