Response Block

When the process is complete , it will return to the onResponse or onFail.

[paymentSDK requestWithTarget:self onResponse:^(NSDictionary *response)
{
    NSLog(@"%@",response);
    NSString *message = @"";
    if([response[@"respCode"] isEqualToString:@"00"])
    {
       message = @"Payment Success";
    }
    else {
       message = response[@"failReason"];
    }

    NSLog(@"Payment status: %@",message);

} onFail:^(NSError *error) {
    if(error) {
      NSLog(@"%@",error);
    }
    else {
      NSLog(@"Cancel The Payment From OTP");
    }
}];
}
paymentSDK.request(withTarget: self, onResponse: { (response) in

    guard let respcode:String = response?["respCode"] as? String else {
        print("Cannot get the response")
        return
    }

    guard let failReason:String = response?["failReason"] as? String else {
        print("cannot get the description")
        return
    }

    if respcode != "00" {
        print(failReason)
        return
    }
    else {
        print("Payment Success")
    }

}) { (error) in
    if let err = error {
        print(err.localizedDescription)
    } else {
        print("Cancel The Payment From OTP")
    }
}

onResponse

At the OnResponse , it will include NSDictionary parameter.

onResponse:^(NSDictionary *response)
{
  NSString *respCode = response[@"respCode"];
  NSString *uniqueTransactionCode = response[@"uniqueTransactionCode"];
}
onResponse: { (response) in

    guard let respcode:String = response?["respCode"] as? String else {
        print("Cannot the response")
        return
    }

    guard let uniqueTransactionCode:String = response?["uniqueTransactionCode"] as? String else {
        print("cannot get the uniqueTransactionCode")
        return
    }
}

You can check response detail at here.

OnFail

OnFail has a NSError parameter. This event will arrive when there is no connection or payment cancel from OTP Page.

If payment cancel from OTP page , NSError will nil value.

onFail:^(NSError *error) {
    if(error) {
      NSLog(@"%@",error);
    }
    else {
      NSLog(@"Cancel The Payment From OTP");
    }
}
}) { (error) in
    if let err = error {
        print(err.localizedDescription)
    } else {
        print("Cancel The Payment From OTP")
    }
}

Check the complete response detail and the response code