Skip to content
Permalink
Browse files

Merge branch 'master' into SWE-13-choose-bank-account

# Conflicts:
#	SynchronyFinancial/SynchronyFinancial WatchKit App/Base.lproj/Interface.storyboard
#	SynchronyFinancial/SynchronyFinancial WatchKit Extension/FetchData.swift
#	SynchronyFinancial/SynchronyFinancial WatchKit Extension/PaymentDetailInterfaceController.swift
#	SynchronyFinancial/SynchronyFinancial/Defaults.swift
  • Loading branch information
ahm11003 committed Apr 8, 2019
2 parents 76ef026 + 99e5d21 commit 61ca428bcce025552dfc614299ba733b9c144993
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="14460.31" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Qge-pO-HLc">
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="14490.70" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Qge-pO-HLc">
<device id="watch38" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="watchOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="14460.16"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="14490.21"/>
</dependencies>
<scenes>
<!--root-->
@@ -201,29 +201,36 @@
<objects>
<controller id="t8d-XB-ngB" customClass="PaymentDetailInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target">
<items>
<imageView alignment="left" hidden="YES" id="fzG-LV-j7G"/>
<label width="1" alignment="center" text="Pay From:" textAlignment="center" id="xE5-Zl-U7d"/>
<button width="1" height="40" alignment="left" title="Select Bank" id="SZD-0B-PrF" userLabel="detailButton">
<fontDescription key="font" type="system" pointSize="15"/>
<connections>
<action selector="bankAccountsTapped" destination="t8d-XB-ngB" id="bQR-Mu-nB6"/>
</connections>
</button>
<separator alignment="left" verticalAlignment="center" id="et0-Sq-Qxm">
<color key="color" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</separator>
<label width="1" alignment="center" verticalAlignment="bottom" text="Confirm Payment" textAlignment="center" id="mT0-3D-JGP"/>
<button width="1" height="49" alignment="left" verticalAlignment="bottom" title="Button" id="FgU-iZ-2XU" userLabel="paymentButton">
<color key="titleColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" red="0.16078431369999999" green="0.6705882353" blue="0.8862745098" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<action selector="paymentAction" destination="t8d-XB-ngB" id="Zjv-zI-wCI"/>
</connections>
</button>
<imageView alignment="left" hidden="YES" id="jH5-mg-vuQ"/>
<label width="1" alignment="center" hidden="YES" text="Processing ..." textAlignment="center" id="YNm-eO-7xL"/>
<group width="1" height="1" alignment="left" layout="vertical" id="9VF-fb-CV3">
<items>
<label width="1" alignment="center" text="Pay From:" textAlignment="center" id="xE5-Zl-U7d"/>
<button width="1" height="40" alignment="left" title="Select Bank" id="SZD-0B-PrF" userLabel="detailButton">
<fontDescription key="font" type="system" pointSize="15"/>
<connections>
<action selector="bankAccountsTapped" destination="t8d-XB-ngB" id="bQR-Mu-nB6"/>
</connections>
</button>
<separator alignment="left" verticalAlignment="center" id="et0-Sq-Qxm">
<color key="color" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</separator>
<label width="1" alignment="center" verticalAlignment="bottom" text="Confirm Payment" textAlignment="center" id="mT0-3D-JGP"/>
<button width="1" height="49" alignment="left" verticalAlignment="bottom" title="Button" id="FgU-iZ-2XU" userLabel="paymentButton">
<color key="titleColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" red="0.16078431369999999" green="0.6705882353" blue="0.8862745098" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<action selector="paymentAction" destination="t8d-XB-ngB" id="Zjv-zI-wCI"/>
</connections>
</button>
</items>
</group>
</items>
<connections>
<outlet property="activityIndicator" destination="fzG-LV-j7G" id="zqA-Vd-Kjv"/>
<outlet property="activityIndicator" destination="jH5-mg-vuQ" id="ucI-rB-ebj"/>
<outlet property="activityIndicatorLabel" destination="YNm-eO-7xL" id="okk-cx-k3L"/>
<outlet property="amount" destination="mT0-3D-JGP" id="rff-wG-B82"/>
<outlet property="contentGroup" destination="9VF-fb-CV3" id="vfa-YT-ipt"/>
<outlet property="detailButton" destination="SZD-0B-PrF" id="xEw-gE-yIP"/>
<outlet property="payFrom" destination="xE5-Zl-U7d" id="62t-6n-KSD"/>
<outlet property="paymentButton" destination="FgU-iZ-2XU" id="yZe-dZ-nBV"/>
@@ -262,6 +269,26 @@
</objects>
<point key="canvasLocation" x="1416" y="186"/>
</scene>
<!--PaymentResult-->
<scene sceneID="mFc-oM-oG1">
<objects>
<controller identifier="PaymentResult" id="mpK-7H-pjK" customClass="PaymentResultInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target">
<items>
<label width="1" alignment="center" text="Payment Result:" textAlignment="center" id="gg1-Wq-NeI"/>
<separator width="1" alignment="center" id="Y1o-3Q-hjG"/>
<label width="1" alignment="center" text="Confirmation Number:" textAlignment="center" minimumScaleFactor="0.69999999999999996" id="qAX-bM-U5t"/>
<label width="1" alignment="center" text="Label" textAlignment="center" minimumScaleFactor="0.5" id="cF3-r2-BMf"/>
<label width="1" alignment="center" verticalAlignment="center" text="Payment ID:" textAlignment="center" id="7Cr-Kh-rJ2"/>
<label width="1" alignment="center" verticalAlignment="center" text="Label" textAlignment="center" id="wSp-wZ-Ksf"/>
</items>
<connections>
<outlet property="confirmationNumberLabel" destination="cF3-r2-BMf" id="FBR-K8-kdQ"/>
<outlet property="paymentIDLabel" destination="wSp-wZ-Ksf" id="7MN-ZT-Jxw"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="1416" y="516"/>
</scene>
<!--Transactions-->
<scene sceneID="yXO-yR-k6b">
<objects>
@@ -291,8 +318,35 @@
</objects>
<point key="canvasLocation" x="1085" y="-229"/>
</scene>
<!--TransactionDetails-->
<scene sceneID="aqX-eB-bdU">
<objects>
<controller identifier="TransactionDetails" id="LeA-fL-4Wb" customClass="TransactionDetailsInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target">
<items>
<label width="1" alignment="center" text="Scheduled Online Payment Processing" textAlignment="center" numberOfLines="2" minimumScaleFactor="0.69999999999999996" id="z1i-je-74F">
<fontDescription key="font" type="boldSystem" pointSize="15"/>
</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"/>
</items>
</group>
</items>
<connections>
<outlet property="amountLabel" destination="d4y-NP-GbP" id="WOU-uA-pCu"/>
<outlet property="cancelButton" destination="4Rt-Xc-Vdh" id="TLc-0k-RFv"/>
<outlet property="dateLabel" destination="F4A-wp-ECw" id="J5W-xg-g3R"/>
<outlet property="transactionName" destination="z1i-je-74F" id="i76-Qo-iL9"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="1420" y="-229"/>
</scene>
</scenes>
<inferredMetricsTieBreakers>
<segue reference="AFS-lo-piH"/>
<segue reference="kTV-Eb-cpT"/>
</inferredMetricsTieBreakers>
</document>
@@ -20,7 +20,7 @@ class FetchData {
completion(false, NSError())
return
}

if let token = dict["access_token"]?.string {
// now we should save our token somewhere safe (UserDefaults)
UserDefaults.standard.set(token, forKey: "access_token")
@@ -43,17 +43,14 @@ class FetchData {
guard dict["status"]?.dictionaryValue["response_code"]?.string == "0" else { return }
//print(json)
let formatter = DateFormatter()
formatter.locale = Locale.current
formatter.dateFormat = "yyyyMMdd"
if let accounts = dict["account_number_list"]?.arrayValue {
accounts.forEach {
if let accountAlias = $0.dictionaryValue["account_alias"]?.string,
let last4 = $0["last4_acct_number"].string,
let creditLimitString = $0.dictionaryValue["credit_limit"]?.string,
let creditLimit = Double(creditLimitString),
let payDueDateString = $0.dictionaryValue["next_payment_due_date"]?.string,
let paymentDueDate = formatter.date(from: payDueDateString),
let paymentDueDate = Defaults.careCreditDateFormatter.date(from: payDueDateString),
let curBalString = $0.dictionaryValue["current_balance"]?.string,
let currentBalance = Double(curBalString),
let availCreditString = $0.dictionaryValue["available_credit"]?.string,
@@ -81,20 +78,17 @@ class FetchData {
var header = Defaults.headerForTransaction
header["account_alias"] = accountAlias
var transactions: [Transaction] = []
let formatter = DateFormatter()
formatter.locale = Locale.current
formatter.dateFormat = "yyyyMMdd"

Alamofire.request(Defaults.TRANS_HISTORY_URL, method: .post, parameters: header, 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 }

//let's first parse the pending transactions
dict["pending_transaction_list"]?.arrayValue.forEach {
if let desc = $0["description"].string,
let date = formatter.date(from: $0["transaction_date"].stringValue),
let date = Defaults.careCreditDateFormatter.date(from: $0["transaction_date"].stringValue),
let amountString = $0["transaction_amount"].string,
let amount = Double(amountString),
let confirmationNum = $0["payment_confirmation_number"].string,
@@ -106,11 +100,11 @@ class FetchData {
transactions.append(Transaction(type: type, amount: amount, merchantID: desc, date: date, confirmationNum: confirmationNum, paymentId: paymentId, isPending: true, isModifiable: isModifiable))
}
}

// let's parse just processed transactions now
dict["processed_transaction_list"]?.arrayValue.forEach {
if let desc = $0["description"].string,
let date = formatter.date(from: $0["transaction_date"].stringValue),
let date = Defaults.careCreditDateFormatter.date(from: $0["transaction_date"].stringValue),
let amountString = $0["transaction_amount"].string,
let amount = Double(amountString) {
let type: TransactionType = $0["payment_amount_type"].stringValue == "" ? .purchase : .reimbursement
@@ -124,7 +118,7 @@ class FetchData {
}
}
}

static func getBankInfo(completion: @escaping ([BankAcct], Error?) -> Void) {
var bankIds: [BankAcct] = []
Alamofire.request(Defaults.FETCH_BANKS_URL, method: .post, parameters: Defaults.headerForMulti, encoding: JSONEncoding.default, headers: Defaults.authHeader).responseJSON { payload in
@@ -150,8 +144,8 @@ class FetchData {
}
}
}
static func cancelPayment(accountAlias: String, confirmationNum: String, paymentId: Int, completion: @escaping (String, Error?) -> Void){

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
@@ -169,4 +163,27 @@ class FetchData {
}
}
}

static func submitPayment(for alias: String, type: PaymentType, amount: Double, bankID: String, completion: @escaping (String, String, Error?) -> Void) {
var paymentHeader = Defaults.headerForPmt
paymentHeader["account_alias"] = alias
paymentHeader["bank_account_id"] = bankID
paymentHeader["payment_amount_type"] = type.rawValue
paymentHeader["payment_amount"] = amount
paymentHeader["scheduled_payment_post_date"] = Defaults.careCreditDateFormatter.string(from: Date())

Alamofire.request(Defaults.MAKE_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 paymentConfirmationNum = dict["payment_confirmation_number"]?.stringValue,
let paymentID = dict["payment_id"]?.stringValue {
completion(paymentConfirmationNum, paymentID, nil)
}
case .failure(let error):
NSLog("Error: \(error.localizedDescription)")
}
}
}
}
@@ -60,6 +60,9 @@ class PayBillInterfaceController: WKInterfaceController {
let minimumFormatted = String(format: "$%.2f", valid.minPayDue)
minimumLabel.setText("Minimum Payment:\n\(minimumFormatted)")
payMinimumButton.setTitle("Pay \(minimumFormatted)")

payMinimumButton.setEnabled(valid.minPayDue > 0.0)
payBalanceButton.setEnabled(valid.curBalance > 0.0)
}
}
}

0 comments on commit 61ca428

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