Closed AkshayNG closed 4 years ago
I've managed to get this work with the help of UIViewController extension:
@AkshayNG I am also using the extension still not getting called.
extension CheckoutViewController: RazorpayPaymentCompletionProtocol {
func onPaymentSuccess(_ payment_id: String) {}
func onPaymentError(_ code: Int32, description str: String) {}
}
Any idea or help you can provide?
Getting this error when RazorPay payment screen dismissed:
/Users/travis/build/razorpay/razorpay-ios/RazorpayIOS/CheckoutOtpelf/Classes/RazorpayCheckoutVC.swift deinitialized
@Neeraj204, please verify your passed parameters again. Also please verify your passing parameters.
@Nautiyalsachin All the parameters are ok it is problem of RazorpayPaymentCompletionProtocol which not being called with extension.
@Neeraj204 Below is the extension I've implemented, working fine for me:
extension UIViewController: RazorpayPaymentCompletionProtocol
{
func purchaseUsingRazorPay(price : Int)
{
. . .
let rp = Razorpay.initWithKey(RazorPayment.apiKey, andDelegate: self)
rp.open(opt)
}
public func onPaymentError(_ code: Int32, description str: String) {
if code == 2 { return }
ToastView.shared.show(message:str)
RazorPayment.shared.clear()
}
public func onPaymentSuccess(_ payment_id: String)
{
RazorPayment.shared.paymentSucessful()
}
}
So you can call purchaseUsingRazorPay() from any viewController.
Hi, I'm using RazorPay version 1.1.2 with cocoapods on Xcode 10.3.
The Code:
I'm using test API key. The issue is in checkout, on clicking Success Or Error button the form is getting dismissed but the delegate functions are not being called. Also when we simply close, it dismisses the form/controller but the func onPaymentError not called at all. Whats going wrong with delegates ?
UPDATE
So now I moved my logic from helper class to actual viewcontroller, and delegates got called. The question now is why delegate not called inside for helper class(subclass of nsobject as in above code).