Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegate method of view controllers not called #18

Closed
SalilLuley opened this issue Jun 14, 2020 · 5 comments
Closed

Delegate method of view controllers not called #18

SalilLuley opened this issue Jun 14, 2020 · 5 comments

Comments

@SalilLuley
Copy link

SalilLuley commented Jun 14, 2020

Just copy pasted the kick start frames code in iOS GitHub repo. In that I found a bug that cardViewController.delegate = self does not set the delegate, its still nil and because of that delegate methods of my vc are not called from CardViewController.

@SalilLuley SalilLuley changed the title Delegate method self.delegate?.onTapDone(controller: self, cardToken: cardToken, status: .success) is not called Delegate method of view controllers not called Jun 14, 2020
@daven-gomes-cko
Copy link
Contributor

I've just tried to run the code and it appears to work as expected, calling the delegate method as expected after entering some test card details and tapping the Pay button. Do you mean this isn't working for you when you run the sample code? Or it isn't working in your project?

If you could please post some sample code it might help see where the issue is.

@dhavalgajjar-greenapex
Copy link

dhavalgajjar-greenapex commented Jun 19, 2020

I am facing the same issue.
I just copy and pasted in my project by referring GitHub home page's document.
Using pod 'Frames', '~> 3.0'.
Delegate is nil even after assigning view controller and not getting a call back.

Step 1:
private let checkoutAPIClient = CheckoutAPIClient(publicKey: "public_key",
environment: .sandbox)

Step 2 :
private var cardViewController: CardViewController {
let checkoutAPIClient = CheckoutAPIClient(publicKey: "publc_key",
environment: .sandbox)
return CardViewController(checkoutApiClient: checkoutAPIClient, cardHolderNameState: .hidden, billingDetailsState: .hidden)
}

Step 3:
ViewdidLoad :

cardViewController.delegate = self
cardViewController.rightBarButtonItem = UIBarButtonItem(title: "Pay", style: .done, target: nil, action: nil)
cardViewController.availableSchemes = [.visa, .mastercard , .americanExpress , .discover , .unionPay, .maestro]

Step 4 :
self.navigationController?.pushViewController(cardViewController, animated: true)

Step 5: Handling delegate methods

extension Viewcontroller : CardViewControllerDelegate {
func onSubmit(controller: CardViewController) {
print("Submited")
}

func onTapDone(controller: CardViewController, cardToken: CkoCardTokenResponse?, status: CheckoutTokenStatus) {
print("onTapDone")
}
}

@daven-gomes-cko
Copy link
Contributor

daven-gomes-cko commented Jun 19, 2020

@dhavalgajjar-greenapex Could you try change your cardViewController to lazy var? From your code, it appears every time you call cardViewController, you are creating a new instance rather than retaining one.

@daven-gomes-cko
Copy link
Contributor

Closing this issue for now, if you still experience this problem or the above solution does not work, feel free to re-open it.

@SalilLuley
Copy link
Author

Initialising cardViewController as lazy var did the trick. Thank you for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants