solved payment problems

This commit is contained in:
quique 2018-06-13 09:02:59 +02:00
parent 5885c68bda
commit f8df6ea06d
8 changed files with 29 additions and 25 deletions

View File

@ -7,7 +7,7 @@
<key>BaseLibrary.xcscheme</key> <key>BaseLibrary.xcscheme</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>0</integer> <integer>1</integer>
</dict> </dict>
</dict> </dict>
</dict> </dict>

View File

@ -7,7 +7,7 @@
<key>Verdnaturaventas.xcscheme</key> <key>Verdnaturaventas.xcscheme</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>1</integer> <integer>0</integer>
</dict> </dict>
</dict> </dict>
</dict> </dict>

View File

@ -166,8 +166,10 @@ class ControllerPedido: NSObject {
let order = getPedido() let order = getPedido()
order.customer_id = order.cliente!.Id_Cliente order.customer_id = order.cliente!.Id_Cliente
order.delivery_method_id = order.agencia!.Vista if order.agencia != nil {
order.agency_id = order.agencia!.Id_Agencia order.delivery_method_id = order.agencia!.Vista
order.agency_id = order.agencia!.Id_Agencia
}
order.address_id = order.consignatarioActivo?.Id_Consigna order.address_id = order.consignatarioActivo?.Id_Consigna
order.source_app = "IOS" order.source_app = "IOS"

View File

@ -319,7 +319,7 @@
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Wpn-Qt-7HE"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Wpn-Qt-7HE">
<rect key="frame" x="15" y="0.0" width="290" height="30"/> <rect key="frame" x="15" y="0.0" width="290" height="29.5"/>
<fontDescription key="fontDescription" name="Roboto-Regular" family="Roboto" pointSize="20"/> <fontDescription key="fontDescription" name="Roboto-Regular" family="Roboto" pointSize="20"/>
<color key="textColor" red="0.62860941889999999" green="0.62909907099999995" blue="0.62868529559999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="textColor" red="0.62860941889999999" green="0.62909907099999995" blue="0.62868529559999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>

View File

@ -20,7 +20,9 @@ class ParserOrder: Parser {
let order = Order() let order = Order()
order.parseJson(jsonDictionary) order.parseJson(jsonDictionary)
order.consignatarioActivo = ParserConsignatario().parse(jsonDictionary["consignatarioActivo"]! as AnyObject) order.consignatarioActivo = ParserConsignatario().parse(jsonDictionary["consignatarioActivo"]! as AnyObject)
order.agencia = ParserAgencias().parseAgencia(jsonDictionary["agencia"] as! NSDictionary) if jsonDictionary["agencia"] != nil {
order.agencia = ParserAgencias().parseAgencia(jsonDictionary["agencia"] as! NSDictionary)
}
order.PedidoSplitado = (jsonDictionary["PedidoSplitado"] as AnyObject).boolValue order.PedidoSplitado = (jsonDictionary["PedidoSplitado"] as AnyObject).boolValue
if let cliente = jsonDictionary["cliente"] if let cliente = jsonDictionary["cliente"]
{ {

View File

@ -43,23 +43,21 @@ class ViewNavegador: MyViewVentas, UIWebViewDelegate {
@IBAction func clickBack(_ sender: AnyObject) { @IBAction func clickBack(_ sender: AnyObject) {
back() back()
} }
func generateWebView() func generateWebView()
{ {
/*Request*/
let url = URL(string: datos!.Url!) var request = URLRequest(url: URL(string:datos!.Url!)!)
let mutableURL = NSMutableURLRequest(url:url!) request.httpMethod = "POST"
mutableURL.httpMethod = "POST" request.httpBody = generateData().data(using:String.Encoding.ascii, allowLossyConversion: false)
let data = generateData().data(using: String.Encoding.utf8) webView.loadRequest(request)
mutableURL.httpBody = data
webView.loadRequest(mutableURL as URLRequest)
} }
func generateData() -> String func generateData() -> String
{ {
let data = "Ds_SignatureVersion=\(datos!.DSSignature!)&Ds_MerchantParameters=\(datos!.EncodedParams!)&Ds_Signature=\(datos!.Signature!)" let data = "Ds_SignatureVersion=\(datos!.DSSignature!)&Ds_MerchantParameters=\(datos!.EncodedParams!)&Ds_Signature=\(datos!.Signature!)".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!.replacingOccurrences(of: "+", with: "%2B")
print(data)
return data return data
} }
@ -77,11 +75,11 @@ class ViewNavegador: MyViewVentas, UIWebViewDelegate {
handlerFinish: { handlerFinish: {
self.datos = cmd.datos! self.datos = cmd.datos!
self.generateWebView() self.generateWebView()
}, },
handlerRetry: { handlerRetry: {
self.showProgress(false) self.showProgress(false)
self.obtenerDatosPasarBanco() self.obtenerDatosPasarBanco()
}, },
handlerAccept: {} handlerAccept: {}
) )
@ -101,7 +99,7 @@ class ViewNavegador: MyViewVentas, UIWebViewDelegate {
status = "ko" status = "ko"
pagado = false pagado = false
} }
showProgress(true); showProgress(true);
let cmd = CmdTransactionEnd(s: status, t: transaccion) let cmd = CmdTransactionEnd(s: status, t: transaccion)
cmd.callbacks = CommandCallbacks( cmd.callbacks = CommandCallbacks(
@ -109,19 +107,19 @@ class ViewNavegador: MyViewVentas, UIWebViewDelegate {
handlerFinish: { handlerFinish: {
self.showProgress(false) self.showProgress(false)
self.launchSegue("segueNavegadorFinalizar", sender: Values.CALLBACK_PAGO_OK as AnyObject?) self.launchSegue("segueNavegadorFinalizar", sender: Values.CALLBACK_PAGO_OK as AnyObject?)
}, },
handlerRetry: { handlerRetry: {
self.transactionEnd(url, transaccion: transaccion) self.transactionEnd(url, transaccion: transaccion)
}, },
handlerAccept: { handlerAccept: {
self.back() self.back()
} }
) )
execute(cmd); execute(cmd);
} }
func back() func back()
{ {
launchSegue("segueNavegadorFinalizar", sender: Values.CALLBACK_PAGO_ERROR as AnyObject?) launchSegue("segueNavegadorFinalizar", sender: Values.CALLBACK_PAGO_ERROR as AnyObject?)
@ -129,6 +127,8 @@ class ViewNavegador: MyViewVentas, UIWebViewDelegate {
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool
{ {
if(request.url!.absoluteString == Values.CALLBACK_PAGO_OK || request.url!.absoluteString == Values.CALLBACK_PAGO_ERROR){ if(request.url!.absoluteString == Values.CALLBACK_PAGO_OK || request.url!.absoluteString == Values.CALLBACK_PAGO_ERROR){
transactionEnd((request.url?.absoluteString)!, transaccion: NSNumber(value: Int(datos!.DSOrder!)! as Int)) transactionEnd((request.url?.absoluteString)!, transaccion: NSNumber(value: Int(datos!.DSOrder!)! as Int))
} }
@ -140,7 +140,7 @@ class ViewNavegador: MyViewVentas, UIWebViewDelegate {
let vc = segue.destination as! DialogFinalizarPedido let vc = segue.destination as! DialogFinalizarPedido
vc.transaction = sender as! String vc.transaction = sender as! String
vc.deuda = deuda vc.deuda = deuda
} }
override func viewWillDisappear(_ animated: Bool) { override func viewWillDisappear(_ animated: Bool) {
@ -155,5 +155,5 @@ class ViewNavegador: MyViewVentas, UIWebViewDelegate {
func webViewDidFinishLoad(_ webView: UIWebView) { func webViewDidFinishLoad(_ webView: UIWebView) {
showProgress(false) showProgress(false)
} }
} }