使用Webview完美赚钱

时间:2018-10-05 07:36:06

标签: ios swift3 uiwebview payment-gateway

在我的应用程序中,我通过Webview使用Perfect Money,因为我通过post方法发布了隐藏参数。我得到了具有给定细节的完美金钱页面。但是,当我单击“付款方式”时,我又得到了相同的页面。我从“付款”中收到的网址是https://perfectmoney.is/api/step1.asp/account.asp,因此它向我显示了同一页面。谨附上我的网络视图的屏幕截图。我找不到我在哪里做错了。在过去的3天中苦苦挣扎。

代码:

var PayUBaseUrl="https://perfectmoney.is/api/step1.asp"
 func initPayment(){
        let PAYEE_ACCOUNT = perfectmonetArr.username
        let EMarket = "E-Market"
        let track_id = perfectmonetArr.track_id
        let amount = perfectmonetArr.amount
        let frm_sym = perfectmonetArr.frm_sym
        let SUCCESS_URL = "https://myurl/success"
        let PAYMENT_URL = "https://myurl/perfect_ipn"
        let FAILED_URL = "https://myurl/failure"
        let POST = "POST"
        let memo = perfectmonetArr.memo
        var passpharse = perfectmonetArr.passpharse

        //var passpharse = perfectmonetArr.passpharse?.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)
        passpharse = passpharse?.trimmingCharacters(in: .whitespaces)


        let gethash = track_id! + PAYEE_ACCOUNT! + amount! + frm_sym! + passpharse!.trimmingCharacters(in: .whitespacesAndNewlines)
        let digest = MD5(gethash)
        let postStr : String  = "PAYEE_ACCOUNT=\(PAYEE_ACCOUNT!)&PAYEE_NAME=\(EMarket)&PAYMENT_ID=\(track_id!)&PAYMENT_AMOUNT=\(amount!)&PAYMENT_UNITS=\(frm_sym!)&STATUS_URL=\(SUCCESS_URL)&NOPAYMENT_URL=\(FAILED_URL)&SUGGESTED_MEMO=\(memo!)&PAYMENT_URL=\(PAYMENT_URL)&NOPAYMENT_URL_METHOD=\(POST)&PAYMENT_URL_METHOD=\(POST)&V2_HASH=\(digest!)"
        let url = NSURL(string: String.localizedStringWithFormat("%@/step1.asp/_payment", PayUBaseUrl1))
        print("check my url", url!, postStr)
        let request = NSMutableURLRequest(url: url! as URL)
        do {
            DispatchQueue.main.async {
            let postLength = String.localizedStringWithFormat("%lu",postStr.characters.count)
            request.httpMethod = "POST"
            request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Current-Type")
            request.setValue(postLength, forHTTPHeaderField: "Content-Length")
            request.httpBody = postStr.data(using: String.Encoding.utf8)

                self.myWebView.loadRequest(request as URLRequest)
            }
            self.alert.dismiss(withClickedButtonIndex: -1, animated: true)
        } catch {

        }

    }

func MD5(_ string: String) -> String? {
        let length = Int(CC_MD5_DIGEST_LENGTH)
        var digest = [UInt8](repeating: 0, count: length)

        if let d = string.data(using: String.Encoding.utf8) {
            _ = d.withUnsafeBytes { (body: UnsafePointer<UInt8>) in
                CC_MD5(body, CC_LONG(d.count), &digest)
            }
        }[enter image description here][1]

        return (0..<length).reduce("") {
            $0 + String(format: "%02x", digest[$1])
        }
    }

ScreenShot:https://i.stack.imgur.com/hOEs1.png

0 个答案:

没有答案