Skip to content
Permalink
Browse files

Added request for payment cancelation

  • Loading branch information
rrk12005 committed Apr 3, 2019
1 parent 86153df commit ffd4f19259cc10ffff85d738b26852ce079293b0
Showing with 20 additions and 1 deletion.
  1. +20 −1 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)")
}
}
}
} }

0 comments on commit ffd4f19

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