razorpay / razorpay-pod

:iphone: CocoaPod implementation of Razorpay's Payment SDK. Refer for instructions:
https://docs.razorpay.com/v1/page/ios-integration
MIT License
22 stars 18 forks source link

Error on successful payment - webview "The operation couldn’t be completed NSURLErrorDomain error -999" #187

Open Sumitarvikar opened 1 year ago

Sumitarvikar commented 1 year ago

Xcode: Version 13.2.1 (12D4e) Razorpay SDK: Razorpay pod version - '1.3.1' Swift: 5.4

****issue *****

issue - most of time working fine on successful payment but randomly getting error on successful payment - webview error The operation couldn’t be completed NSURLErrorDomain error -999

*****code to open razorpay *

private func showPaymentForm(amount : Double , orderId : String){

    let accountEmail = UserDefaultsManager.getParentUserData()?.email
    let accountPhone =  UserDefaultsManager.getParentUserData()?.mobile
    let options: [AnyHashable:Any] = [
        "prefill": [
            "contact": accountPhone,
            "email": accountEmail
        ],
        "image": "",
        "amount" : amount,
        "name": "Docterz",
        "order_id" : orderId ,
        "theme": [
            "color": UIColor.blue.toHexString()
        ]
        // follow link for more options - https://razorpay.com/docs/payment-gateway/web-integration/standard/checkout-form/
    ]
    razorpay = RazorpayCheckout.initWithKey(APIConstant.KURL.KRazorpayURL, andDelegate: self)
    if let rzp = razorpay {
        rzp.open(options, displayController: (delegate?.viewController ?? delegate?.viewController.navigationController)!)
    }
    else{
        print("Unable to initialize")
    }
}

}

**success and failure method **

extension BillingViewModel : RazorpayPaymentCompletionProtocol {
func onPaymentError(_ code: Int32, description str: String) {
    if code != 2 {
       //Showing alert

//Getting Errow here : "The operation couldn’t be completed NSURLErrorDomain error -999" // code parameter received - 0 Helper.shared.showAlert("FAILURE \n (str)", vc: delegate!.viewController) } }

func onPaymentSuccess(_ payment_id: String) {
  // navigating to successful screen
    self.transpherOrderToPatner(patnerId: patnerId ?? 0, ClinicId: clinicId ?? 0 , paymentId:payment_id)
}

}

** note *** please help as soon as possible we stuck on production release .

66123