Skip to content

Swe 12 enable payment suite #13

Merged
merged 14 commits into from Apr 8, 2019

SWE-12 Define web service call for making payment

  • Loading branch information
ahm11003 committed Mar 29, 2019
commit a2689bdd39e083f2201cdd7b170607abe5e1f430
@@ -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")
@@ -107,4 +107,28 @@ class FetchData {
}
}
}

static func submitPayment(for alias: String, type: String, 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
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)")
}
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.