{"action":"created","issue":{"url":"https://api.github.com/repos/paymentwall/paymentwall-ios-sdk/issues/10","repository_url":"https://api.github.com/repos/paymentwall/paymentwall-ios-sdk","labels_url":"https://api.github.com/repos/paymentwall/paymentwall-ios-sdk/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/paymentwall/paymentwall-ios-sdk/issues/10/comments","events_url":"https://api.github.com/repos/paymentwall/paymentwall-ios-sdk/issues/10/events","html_url":"https://github.com/paymentwall/paymentwall-ios-sdk/issues/10","id":351954242,"node_id":"MDU6SXNzdWUzNTE5NTQyNDI=","number":10,"title":"The webview does not close after 3DSecure","user":{"login":"Dukmasta","id":6385430,"node_id":"MDQ6VXNlcjYzODU0MzA=","avatar_url":"https://avatars2.githubusercontent.com/u/6385430?v=4","gravatar_id":"","url":"https://api.github.com/users/Dukmasta","html_url":"https://github.com/Dukmasta","followers_url":"https://api.github.com/users/Dukmasta/followers","following_url":"https://api.github.com/users/Dukmasta/following{/other_user}","gists_url":"https://api.github.com/users/Dukmasta/gists{/gist_id}","starred_url":"https://api.github.com/users/Dukmasta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dukmasta/subscriptions","organizations_url":"https://api.github.com/users/Dukmasta/orgs","repos_url":"https://api.github.com/users/Dukmasta/repos","events_url":"https://api.github.com/users/Dukmasta/events{/privacy}","received_events_url":"https://api.github.com/users/Dukmasta/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2018-08-20T01:13:57Z","updated_at":"2018-08-20T11:16:56Z","closed_at":null,"author_association":"NONE","body":"According to your API, the webview supposed to close itself after 3D secure. \r\n\r\n> After 3D secure, Paymentwall backend will report the 3DS result to your server, now you can make the charge again and print the result on the webView, the webView will catch the result JSON and close the webView:\r\n>              - {\"success\":1} will mark the result as success without asking to store user card.\r\n>              - Charge object JSON will mark the result as success and ask to store user card.\r\n>              - {\"error\": \"error_message\"} will mark the result as failed with the error message\r\n> \r\n\r\nIt prints \"{success:1}\" but the webiew doesn't close itself. I have the following merchant processing case:\r\n\r\n\r\n```\r\ncase .merchantProcessing:\r\n            /**\r\n             \r\n             Process the one-time token in your backend asynchronously\r\n             After finish:\r\n             - Success without asking to store card:\r\n             brick.handleBackendChargeResult(true, chargeObject: nil, secureURL: nil, errorMessage: nil)\r\n             - Success with asking to store card:\r\n             brick.handleBackendChargeResult(true, chargeObject: chargedObjectDict, secureURL: nil, errorMessage: nil)\r\n             - Error:\r\n             brick.handleBackendChargeResult(false, chargeObject: nil, secureURL: nil, errorMessage: \"some error\")\r\n             - 3D secure:\r\n             brick.handleBackendChargeResult(false, chargeObject: nil, secureURL: url, errorMessage: nil)\r\n             \r\n             >After 3D secure, Paymentwall backend will report the 3DS result to your server, now you can make the charge again and print the result on the webView, the webView will catch the result JSON and close the webView:\r\n             - {\"success\":1} will mark the result as success without asking to store user card.\r\n             - Charge object JSON will mark the result as success and ask to store user card.\r\n             - {\"error\": \"error_message\"} will mark the result as failed with the error message\r\n             \r\n             */\r\n            let token = response.token?.token\r\n            let fingerprint = (response.token?.fingerprint == nil) ? \"\" : response.token?.fingerprint\r\n            let amount = String(format: \"%d\", `(self.data?.price)!` * Int(self.quantityTextField.text!)!)\r\n            let currency = self.data?.currencyType\r\n            let email = response.token?.email\r\n            let description = self.data?.ticketName\r\n          \r\n            let params = [\r\n                \"uniqueId\" : JoinUserInfo.getInstance.uniqueId,\r\n                \"couponId\" : self.couponId!,\r\n                \"quantity\" : self.quantityTextField.text!,\r\n                \"token\" : token!,\r\n                \"fingerprint\" : fingerprint!,\r\n                \"amount\" : amount,\r\n                \"currency\" : currency!,\r\n                \"email\" : email!,\r\n                \"description\": description!\r\n                \r\n            ] as [String : Any]\r\n            \r\n            do{\r\n                let jsonParams = try JSONSerialization.data(withJSONObject: params, options: [])\r\n                var request = URLRequest(url: URL(string: RestApi.purchase)!)\r\n                request.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\r\n                request.httpMethod = \"POST\"\r\n                request.httpBody = jsonParams\r\n                \r\n                URLSession.shared.dataTask(with: request){(data, res, error) in\r\n                    if data == nil {\r\n                        return\r\n                    }\r\n                    \r\n                    do{\r\n                        let json = try JSONSerialization.jsonObject(with: data!, options: []) as! [String:Any]\r\n                        let result = Mapper<Message>().map(JSON: json)\r\n                                   \r\n                        self.message = (result?.message)!\r\n                        \r\n                        DispatchQueue.main.async {\r\n                            if response.paymentType == PWPaymentTypeBrick {\r\n                                \r\n                                if let secureUrl = result?.redirectUrl{\r\n                                    \r\n                                    self.brick.handleBackendChargeResult(false, chargeObject: nil, secureURL: URL(string: secureUrl), errorMessage: nil)\r\n                                }\r\n                                \r\n                \r\n                            }\r\n                        }\r\n                        \r\n                    }catch{\r\n                        \r\n                    }\r\n                }.resume()\r\n            }catch{\r\n                \r\n            }\r\n```\r\n\r\n![image](https://user-images.githubusercontent.com/6385430/44315659-75cdba80-a461-11e8-92da-82719c0e72aa.png)\r\n![image](https://user-images.githubusercontent.com/6385430/44315674-8da53e80-a461-11e8-85fd-ccdcb9fe4f52.png)\r\n\r\nAfter the {success:1} gets printed, the webview doesn't close itself. What am I doing wrong?\r\nPlease help"},"comment":{"url":"https://api.github.com/repos/paymentwall/paymentwall-ios-sdk/issues/comments/414281791","html_url":"https://github.com/paymentwall/paymentwall-ios-sdk/issues/10#issuecomment-414281791","issue_url":"https://api.github.com/repos/paymentwall/paymentwall-ios-sdk/issues/10","id":414281791,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDI4MTc5MQ==","user":{"login":"TienVu-PW","id":23113471,"node_id":"MDQ6VXNlcjIzMTEzNDcx","avatar_url":"https://avatars3.githubusercontent.com/u/23113471?v=4","gravatar_id":"","url":"https://api.github.com/users/TienVu-PW","html_url":"https://github.com/TienVu-PW","followers_url":"https://api.github.com/users/TienVu-PW/followers","following_url":"https://api.github.com/users/TienVu-PW/following{/other_user}","gists_url":"https://api.github.com/users/TienVu-PW/gists{/gist_id}","starred_url":"https://api.github.com/users/TienVu-PW/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TienVu-PW/subscriptions","organizations_url":"https://api.github.com/users/TienVu-PW/orgs","repos_url":"https://api.github.com/users/TienVu-PW/repos","events_url":"https://api.github.com/users/TienVu-PW/events{/privacy}","received_events_url":"https://api.github.com/users/TienVu-PW/received_events","type":"User","site_admin":false},"created_at":"2018-08-20T11:16:56Z","updated_at":"2018-08-20T11:16:56Z","author_association":"COLLABORATOR","body":"Yes, the body should only be contains the JSON without any styling."}}
{"actor":{"display_login":"TienVu-PW"}}