Как сделать интеграцию платежного шлюза Razorpay в мой проект Xcode? - PullRequest
0 голосов
/ 08 ноября 2019

Я впервые пытаюсь внедрить платежный шлюз в свой проект.

Я правильно выполнил все шаги по официальной ссылке Razorpay https://razorpay.com/docs/payment-gateway/ios-integration/standard/

Я добавил модуль import Razorpay и установил его протокол делегата.

Пожалуйста, помогите мне решить эту проблему.

Моя версия Xcode - 11.1

//
//  RPViewController.swift

import UIKit
import Razorpay
class RPViewController: UIViewController  , RazorpayPaymentCompletionProtocol {
   var razorpay : Razorpay!
    override func viewDidLoad() {
        super.viewDidLoad()
razorpay = Razorpay.initWithKey("rzp_test_oaXFcpSvVQ9Ry9", andDelegate: self)

        showPaymentForm()
        // Do any additional setup after loading the view.
    }

    internal func showPaymentForm(){
        let options: [String:Any] = [
                    "amount": "100", //This is in currency subunits. 100 = 100 paise= INR 1.
                    "currency": "INR",//We support more that 92 international currencies.
                    "description": "purchase description",
                    "order_id": "order_4xbQrmEoA5WJ0G",
                    "image": "https://image.flaticon.com/icons/svg/124/124010.svg",
                    "name": "business or product name" ,
                    "prefill": [
                        "contact": "9797979797",
                        "email": "foo@bar.com"
                    ],
                    "theme": [
                        "color": "#F37254"
                    ]
                ]


        print(options)
        razorpay.open(options)
    }

    func onPaymentError(_ code: Int32, description str: String) {
           let alertController = UIAlertController(title: "FAILURE", message: str, preferredStyle: UIAlertController.Style.alert)
           let cancelAction = UIAlertAction(title: "OK", style: UIAlertAction.Style.cancel, handler: nil)
           alertController.addAction(cancelAction)
           print("code",code)
           self.view.window?.rootViewController?.present(alertController, animated: true, completion: nil)
       }

       func onPaymentSuccess(_ payment_id: String) {
           let alertController = UIAlertController(title: "SUCCESS", message: "Payment Id \(payment_id)", preferredStyle: UIAlertController.Style.alert)
           print("hdfvsd",payment_id)
           let cancelAction = UIAlertAction(title: "OK", style: UIAlertAction.Style.cancel, handler: nil)
              alertController.addAction(cancelAction)
              self.view.window?.rootViewController?.present(alertController, animated: true, completion: nil)
       }


}
//But I'm getting this error

2019-11-11 09:52:25.298995+0530 PaymentGateway[2355:30306] [Client] Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.}

1 Ответ

2 голосов
/ 08 ноября 2019

Я получил ответ. Ошибка была в том, что я передаю нежелательный параметр orderId.

...