Skip to content

Commit

Permalink
Merge pull request #16 from rrk12005/SWE-24-show-pending-transactions…
Browse files Browse the repository at this point in the history
…-and-allow-cancel

Swe 24 show pending transactions and allow cancel
  • Loading branch information
ahm11003 authored Apr 9, 2019
2 parents 99e5d21 + 017b782 commit 851a96a
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 19 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -289,27 +289,59 @@
<objects> <objects>
<controller identifier="TransactionDetails" id="LeA-fL-4Wb" customClass="TransactionDetailsInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target"> <controller identifier="TransactionDetails" id="LeA-fL-4Wb" customClass="TransactionDetailsInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target">
<items> <items>
<label width="1" alignment="center" text="Scheduled Online Payment Processing" textAlignment="center" numberOfLines="2" minimumScaleFactor="0.69999999999999996" id="z1i-je-74F"> <imageView alignment="left" hidden="YES" id="579-gg-q4m"/>
<fontDescription key="font" type="boldSystem" pointSize="15"/> <label width="1" alignment="left" verticalAlignment="center" hidden="YES" text="Cancelling..." textAlignment="center" id="fN3-48-fyV"/>
</label> <group width="1" alignment="left" layout="vertical" id="w3k-a5-ZaU">
<separator alignment="left" id="HuQ-dl-7Ni"/>
<group width="1" height="105" alignment="left" verticalAlignment="center" layout="vertical" id="EcM-m6-j4G">
<items> <items>
<label width="1" alignment="center" verticalAlignment="center" text="Label" textAlignment="center" id="F4A-wp-ECw"/> <label width="1" alignment="center" text="Scheduled Online Payment Processing" textAlignment="center" numberOfLines="2" minimumScaleFactor="0.69999999999999996" id="z1i-je-74F">
<label width="1" alignment="center" verticalAlignment="center" text="Label" textAlignment="center" id="d4y-NP-GbP"/> <fontDescription key="font" type="boldSystem" pointSize="15"/>
<button width="1" alignment="center" verticalAlignment="bottom" title="Cancel Payment" id="4Rt-Xc-Vdh"/> </label>
<separator alignment="left" id="HuQ-dl-7Ni"/>
<group width="1" height="105" alignment="left" verticalAlignment="center" layout="vertical" id="EcM-m6-j4G">
<items>
<label width="1" alignment="center" verticalAlignment="center" text="Label" textAlignment="center" id="F4A-wp-ECw"/>
<label width="1" alignment="center" verticalAlignment="center" text="Label" textAlignment="center" id="d4y-NP-GbP"/>
<button width="1" alignment="center" verticalAlignment="bottom" title="Cancel Payment" id="4Rt-Xc-Vdh">
<connections>
<action selector="cancelButtonTapped" destination="LeA-fL-4Wb" id="OZd-NZ-CFc"/>
</connections>
</button>
</items>
</group>
</items> </items>
</group> </group>
</items> </items>
<connections> <connections>
<outlet property="activityIndicator" destination="579-gg-q4m" id="9r5-DE-Ise"/>
<outlet property="activityIndicatorLabel" destination="fN3-48-fyV" id="gy3-Ci-bwx"/>
<outlet property="amountLabel" destination="d4y-NP-GbP" id="WOU-uA-pCu"/> <outlet property="amountLabel" destination="d4y-NP-GbP" id="WOU-uA-pCu"/>
<outlet property="cancelButton" destination="4Rt-Xc-Vdh" id="TLc-0k-RFv"/> <outlet property="cancelButton" destination="4Rt-Xc-Vdh" id="TLc-0k-RFv"/>
<outlet property="contentGroup" destination="w3k-a5-ZaU" id="rQo-G8-l7A"/>
<outlet property="dateLabel" destination="F4A-wp-ECw" id="J5W-xg-g3R"/> <outlet property="dateLabel" destination="F4A-wp-ECw" id="J5W-xg-g3R"/>
<outlet property="transactionName" destination="z1i-je-74F" id="i76-Qo-iL9"/> <outlet property="transactionName" destination="z1i-je-74F" id="i76-Qo-iL9"/>
</connections> </connections>
</controller> </controller>
</objects> </objects>
<point key="canvasLocation" x="1420" y="-229"/> <point key="canvasLocation" x="1420" y="-229.5"/>
</scene>
<!--Cancellation-->
<scene sceneID="ZZZ-KP-exO">
<objects>
<controller identifier="Cancellation" id="Cwl-i7-4Od" customClass="CancellationInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<label width="1" alignment="center" text="Cancellation Result:" textAlignment="center" numberOfLines="2" id="UKx-cb-xBx">
<fontDescription key="font" type="boldSystem" pointSize="15"/>
</label>
<separator alignment="left" id="9Q6-wJ-WvP"/>
<label width="1" alignment="center" text="Confirmation Number:" textAlignment="center" minimumScaleFactor="0.69999999999999996" id="YZm-kP-QEl"/>
<label width="1" alignment="center" text="Label" textAlignment="center" id="mS7-FX-NiH"/>
</items>
<connections>
<outlet property="confirmationLabel" destination="mS7-FX-NiH" id="HNE-E7-kF1"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="1806" y="-229"/>
</scene> </scene>
</scenes> </scenes>
<inferredMetricsTieBreakers> <inferredMetricsTieBreakers>
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Foundation
class AccountDetailsInterfaceController: WKInterfaceController { class AccountDetailsInterfaceController: WKInterfaceController {
var selectedAccount: Account? var selectedAccount: Account?
var dictForAcct: [String: Account] = [:] var dictForAcct: [String: Account] = [:]
var transactionDict: [String: [Transaction]] = [:] var transactionDict: [String: Any] = [:]


@IBOutlet var loadingLabel: WKInterfaceLabel! @IBOutlet var loadingLabel: WKInterfaceLabel!
@IBOutlet var activityIndicator: WKInterfaceImage! @IBOutlet var activityIndicator: WKInterfaceImage!
Expand Down Expand Up @@ -41,6 +41,9 @@ class AccountDetailsInterfaceController: WKInterfaceController {
return return
} }


if let acct = self.selectedAccount {
self.transactionDict.updateValue(acct, forKey: "acct")
}
self.transactionDict.updateValue(transactions, forKey: "transactions") self.transactionDict.updateValue(transactions, forKey: "transactions")
self.pushController(withName: "Transactions", context: self.transactionDict) self.pushController(withName: "Transactions", context: self.transactionDict)
self.configureInterfaceObjects(false) self.configureInterfaceObjects(false)
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// CancellationInterfaceController.swift
// SynchronyFinancial WatchKit Extension
//
// Created by Alan Maynard on 4/8/19.
// Copyright © 2019 Alan Maynard. All rights reserved.
//

import WatchKit
import Foundation

class CancellationInterfaceController: WKInterfaceController {
@IBOutlet var confirmationLabel: WKInterfaceLabel!

override func awake(withContext context: Any?) {
super.awake(withContext: context)

guard let data = context as? [String: String], let confirmation = data["cancellation_confirm"] else {
NSLog("Error receiving context for payment cancellation")
return
}

setTitle("Done")
confirmationLabel.setText(confirmation)
}

override func willActivate() {
super.willActivate()
}

override func didDeactivate() {
super.didDeactivate()
}
}
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,29 +10,63 @@ import WatchKit
import Foundation import Foundation


class TransactionDetailsInterfaceController: WKInterfaceController { class TransactionDetailsInterfaceController: WKInterfaceController {
@IBOutlet var activityIndicator: WKInterfaceImage!
@IBOutlet var activityIndicatorLabel: WKInterfaceLabel!
@IBOutlet weak var contentGroup: WKInterfaceGroup!
@IBOutlet var transactionName: WKInterfaceLabel! @IBOutlet var transactionName: WKInterfaceLabel!
@IBOutlet var dateLabel: WKInterfaceLabel! @IBOutlet var dateLabel: WKInterfaceLabel!
@IBOutlet var amountLabel: WKInterfaceLabel! @IBOutlet var amountLabel: WKInterfaceLabel!
@IBOutlet var cancelButton: WKInterfaceButton! @IBOutlet var cancelButton: WKInterfaceButton!

var transaction: Transaction?
var account: Account?

override func awake(withContext context: Any?) { override func awake(withContext context: Any?) {
super.awake(withContext: context) super.awake(withContext: context)


guard let data = context as? [String: Any], guard let data = context as? [String: Any],
let transaction = data["transaction"] as? Transaction, let transaction = data["transaction"] as? Transaction,
let merchant = data["merchant"] as? String, let merchant = data["merchant"] as? String,
let date = data["date"] as? Date, let date = data["date"] as? Date,
let amount = data["amount"] as? Double else { let amount = data["amount"] as? Double,
let acct = data["acct"] as? Account else {
NSLog("Error receiving context in TransactionDetails.") NSLog("Error receiving context in TransactionDetails.")
return return
} }


setTitle("Dismiss") self.transaction = transaction
account = acct
transactionName.setText(merchant) transactionName.setText(merchant)
dateLabel.setText("Date: \(DateFormatter.localizedString(from: date, dateStyle: .short, timeStyle: .none))") dateLabel.setText("Date: \(DateFormatter.localizedString(from: date, dateStyle: .short, timeStyle: .none))")
amountLabel.setText(String(format: "Amount: $%.2f", amount)) amountLabel.setText(String(format: "Amount: $%.2f", amount))
cancelButton.setHidden(!transaction.isModifiable) cancelButton.setHidden(!transaction.isModifiable)
} }


@IBAction func cancelButtonTapped() {
guard let t = transaction, let acct = account else {
NSLog("Error: no values for transaction or account.")
return
}

activityIndicator.configureForActivityIndicator()
activityIndicatorLabel.setHidden(false)
contentGroup.setHidden(true)

FetchData.cancelPayment(accountAlias: acct.accountAlias, confirmationNum: t.confirmationNum, paymentId: t.paymentId) { conf, error in
guard error == nil else {
self.presentAlert(withTitle: "Error", message: "We were unable to process your cancellation at this time. Please try again later.", preferredStyle: .alert, actions: [WKAlertAction(title: "Dismiss", style: .default, handler:{})])
return
}

self.activityIndicatorLabel.setHidden(true)
self.activityIndicator.stopAnimating()
self.contentGroup.setHidden(false)
let context: [String: String] = ["cancellation_confirm": conf]
self.presentController(withName: "Cancellation", context: context)
self.popToRootController()
}
}

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()
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ import Foundation
class TransactionsInterfaceController: WKInterfaceController { class TransactionsInterfaceController: WKInterfaceController {
@IBOutlet weak var transactionsTable: WKInterfaceTable! @IBOutlet weak var transactionsTable: WKInterfaceTable!
var transactions: [Transaction] = [] var transactions: [Transaction] = []
var account: Account?


override func awake(withContext context: Any?) { override func awake(withContext context: Any?) {
super.awake(withContext: context) super.awake(withContext: context)


guard let data = context as? [String: [Transaction]], let trans = data["transactions"] else { guard let data = context as? [String: Any],
NSLog("Error receiving context containing transactions in TransactionsInterfaceController") let trans = data["transactions"] as? [Transaction],
return let acct = data["acct"] as? Account else {
NSLog("Error receiving context containing transactions in TransactionsInterfaceController")
return
} }


account = acct
transactions = trans transactions = trans
configureRows() configureRows()
} }
Expand All @@ -36,13 +40,14 @@ class TransactionsInterfaceController: WKInterfaceController {
} }


override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) { override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) {
guard let acct = account else { return }
let transaction = transactions[rowIndex] let transaction = transactions[rowIndex]
let context: [String: Any] = ["transaction": transaction, let context: [String: Any] = ["transaction": transaction,
"merchant": transaction.merchantID, "merchant": transaction.merchantID,
"date": transaction.date, "date": transaction.date,
"amount": transaction.amount] "amount": transaction.amount,

"acct": acct]
presentController(withName: "TransactionDetails", context: context) pushController(withName: "TransactionDetails", context: context)
} }


private func configureRows() { private func configureRows() {
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
678C3885223098C400FEAAF6 /* Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48F2430B2214CBF700B9C894 /* Account.swift */; }; 678C3885223098C400FEAAF6 /* Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48F2430B2214CBF700B9C894 /* Account.swift */; };
678C388622309F7D00FEAAF6 /* AccountCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48DA0057221D12E70081A500 /* AccountCell.swift */; }; 678C388622309F7D00FEAAF6 /* AccountCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48DA0057221D12E70081A500 /* AccountCell.swift */; };
678C62BA224ECDFD0007AD53 /* PaymentResultInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678C62B9224ECDFD0007AD53 /* PaymentResultInterfaceController.swift */; }; 678C62BA224ECDFD0007AD53 /* PaymentResultInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678C62B9224ECDFD0007AD53 /* PaymentResultInterfaceController.swift */; };
679A9069225C1B0E00247F39 /* CancellationInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 679A9068225C1B0E00247F39 /* CancellationInterfaceController.swift */; };
67BAC269219E254700713FEF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67BAC268219E254700713FEF /* AppDelegate.swift */; }; 67BAC269219E254700713FEF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67BAC268219E254700713FEF /* AppDelegate.swift */; };
67BAC26E219E254700713FEF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 67BAC26C219E254700713FEF /* Main.storyboard */; }; 67BAC26E219E254700713FEF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 67BAC26C219E254700713FEF /* Main.storyboard */; };
67BAC270219E254800713FEF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 67BAC26F219E254800713FEF /* Assets.xcassets */; }; 67BAC270219E254800713FEF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 67BAC26F219E254800713FEF /* Assets.xcassets */; };
Expand Down Expand Up @@ -107,6 +108,7 @@
676392B52242A3F800740A8C /* TransactionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionCell.swift; sourceTree = "<group>"; }; 676392B52242A3F800740A8C /* TransactionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionCell.swift; sourceTree = "<group>"; };
678C38832230950100FEAAF6 /* AccountDetailsInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountDetailsInterfaceController.swift; sourceTree = "<group>"; }; 678C38832230950100FEAAF6 /* AccountDetailsInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountDetailsInterfaceController.swift; sourceTree = "<group>"; };
678C62B9224ECDFD0007AD53 /* PaymentResultInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentResultInterfaceController.swift; sourceTree = "<group>"; }; 678C62B9224ECDFD0007AD53 /* PaymentResultInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentResultInterfaceController.swift; sourceTree = "<group>"; };
679A9068225C1B0E00247F39 /* CancellationInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CancellationInterfaceController.swift; sourceTree = "<group>"; };
67BAC265219E254700713FEF /* SynchronyFinancial.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SynchronyFinancial.app; sourceTree = BUILT_PRODUCTS_DIR; }; 67BAC265219E254700713FEF /* SynchronyFinancial.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SynchronyFinancial.app; sourceTree = BUILT_PRODUCTS_DIR; };
67BAC268219E254700713FEF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 67BAC268219E254700713FEF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
67BAC26D219E254700713FEF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; 67BAC26D219E254700713FEF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
Expand Down Expand Up @@ -207,6 +209,7 @@
67BAC28A219E254900713FEF /* SynchronyFinancial WatchKit Extension */ = { 67BAC28A219E254900713FEF /* SynchronyFinancial WatchKit Extension */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
679A9068225C1B0E00247F39 /* CancellationInterfaceController.swift */,
678C62B9224ECDFD0007AD53 /* PaymentResultInterfaceController.swift */, 678C62B9224ECDFD0007AD53 /* PaymentResultInterfaceController.swift */,
67293CF022542F15009E0E7A /* TransactionDetailsInterfaceController.swift */, 67293CF022542F15009E0E7A /* TransactionDetailsInterfaceController.swift */,
674BD1522239A39D0076AFD6 /* PayBillInterfaceController.swift */, 674BD1522239A39D0076AFD6 /* PayBillInterfaceController.swift */,
Expand Down Expand Up @@ -476,7 +479,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 @@ -497,6 +499,7 @@
67E17B87223812C2008871FE /* Defaults.swift in Sources */, 67E17B87223812C2008871FE /* Defaults.swift in Sources */,
67293CF122542F15009E0E7A /* TransactionDetailsInterfaceController.swift in Sources */, 67293CF122542F15009E0E7A /* TransactionDetailsInterfaceController.swift in Sources */,
1123372E223ABD6400B70925 /* FetchData.swift in Sources */, 1123372E223ABD6400B70925 /* FetchData.swift in Sources */,
679A9069225C1B0E00247F39 /* CancellationInterfaceController.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

0 comments on commit 851a96a

Please sign in to comment.