Worldpay / worldpay-lib-ios

iOS Library for Worldpay
https://online.worldpay.com
20 stars 11 forks source link

Could not find setClientKey:YOUR_CLIENT_KEY in Swift ? #3

Closed speaktoalvin closed 8 years ago

speaktoalvin commented 8 years ago

I am trying to integrate World Pay iOS SDK with Swift 2.0 and iOS 9.2. As per the documentation there should be a function called "setClientKey". Unfortunately i could not find any functions like that.

            [ [Worldpay sharedInstance] setClientKey:YOUR_CLIENT_KEY ];

When i type this Xcode helps with auto-completion, but i could see only these.

    Worldpay.sharedInstance().setClass(AnyClass?, forClassName: String)
    Worldpay.sharedInstance().setClassName(String?, forClass: AnyClass)

I found an another on using swift. This returns an error like this "Cannot assign to property: function call returns immutable value"

            Worldpay.sharedInstance().clientKey = ""

But inside World Pay iOS Library, i saw this.

"Property that sets the Client Key which is used for API calls made directly from your customer's browser" @property (nonatomic, retain) NSString *clientKey;

Which means that i can set Client Key using this property. But i could not.

Is there any workaround ? Let me know please.

donaldking commented 8 years ago

Hi, I'm getting 401 when calling https://qa02-api.worldpay.io/v1/tokens to create token. My client key is set correctly.

speaktoalvin commented 8 years ago

You please try to integrate World Pay in a Swift project. Import the header in bridging-header and try to call this method "setClientKey". Please let me know whether you can see any methods like that or not.

ao commented 8 years ago

@donaldking We have identified the problem and will release an updated version tomorrow.

@alvinvarghese The library was written for Objective C, we are in the process of adding Swift support for it. Will let you know once this is ready.

speaktoalvin commented 8 years ago

@ao That's great. Looking forward to it :)

ao commented 8 years ago

@donaldking please pull the repo.

donaldking commented 8 years ago

@ao Thanks! that was a quick fix! :)

donaldking commented 8 years ago

@alvinvarghese You can surely set client key in a swift project. It works perfectly fine and there are many ways you could do this. The way i've implemented it is by simply subclassing WorldPay and calling self.clientKey = "my-client-key" in my swift project. Works perfectly fine. @ao ObjC proj / lib would work PERFECTLY well with Swift projects :) I have lots! @alvinvarghese see my screen shot attached. Let me know if you have any issues. Cheers screen shot 2016-01-22 at 02 47 59

speaktoalvin commented 8 years ago

Ohh great. I didn't think about that.

ao commented 8 years ago

Version 1.3.0 has just been released. This should resolve your Swift issues.

speaktoalvin commented 8 years ago

Thats really great :)