diff --git a/PaykunSampleApp.xcodeproj/project.pbxproj b/PaykunSampleApp.xcodeproj/project.pbxproj index 71e9dda..7069fae 100644 --- a/PaykunSampleApp.xcodeproj/project.pbxproj +++ b/PaykunSampleApp.xcodeproj/project.pbxproj @@ -7,13 +7,13 @@ objects = { /* Begin PBXBuildFile section */ + 01153CA5226747F1004A6C43 /* PayKun.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01153CA3226747EA004A6C43 /* PayKun.framework */; }; + 01153CA6226747F1004A6C43 /* PayKun.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 01153CA3226747EA004A6C43 /* PayKun.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 0177EE9B217DE4C0007BF559 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0177EE9A217DE4C0007BF559 /* AppDelegate.swift */; }; 0177EE9D217DE4C0007BF559 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0177EE9C217DE4C0007BF559 /* ViewController.swift */; }; 0177EEA0217DE4C0007BF559 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0177EE9E217DE4C0007BF559 /* Main.storyboard */; }; 0177EEA2217DE4C9007BF559 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0177EEA1217DE4C9007BF559 /* Assets.xcassets */; }; 0177EEA5217DE4C9007BF559 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0177EEA3217DE4C9007BF559 /* LaunchScreen.storyboard */; }; - 01E55267224CD0390099B5B3 /* PayKun.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01E55265224CD02E0099B5B3 /* PayKun.framework */; }; - 01E55268224CD0390099B5B3 /* PayKun.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 01E55265224CD02E0099B5B3 /* PayKun.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 01E5526B224CD2E90099B5B3 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 01E55269224CD2E80099B5B3 /* LICENSE */; }; 01E5526C224CD2E90099B5B3 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 01E5526A224CD2E80099B5B3 /* README.md */; }; /* End PBXBuildFile section */ @@ -25,7 +25,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 01E55268224CD0390099B5B3 /* PayKun.framework in Embed Frameworks */, + 01153CA6226747F1004A6C43 /* PayKun.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -33,6 +33,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 01153CA3226747EA004A6C43 /* PayKun.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = PayKun.framework; sourceTree = ""; }; 0177EE97217DE4C0007BF559 /* PaykunSampleApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PaykunSampleApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 0177EE9A217DE4C0007BF559 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 0177EE9C217DE4C0007BF559 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; @@ -40,7 +41,6 @@ 0177EEA1217DE4C9007BF559 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 0177EEA4217DE4C9007BF559 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 0177EEA6217DE4C9007BF559 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 01E55265224CD02E0099B5B3 /* PayKun.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = PayKun.framework; sourceTree = ""; }; 01E55269224CD2E80099B5B3 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = SOURCE_ROOT; }; 01E5526A224CD2E80099B5B3 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ @@ -50,7 +50,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 01E55267224CD0390099B5B3 /* PayKun.framework in Frameworks */, + 01153CA5226747F1004A6C43 /* PayKun.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -76,9 +76,9 @@ 0177EE99217DE4C0007BF559 /* PaykunSampleApp */ = { isa = PBXGroup; children = ( + 01153CA3226747EA004A6C43 /* PayKun.framework */, 01E55269224CD2E80099B5B3 /* LICENSE */, 01E5526A224CD2E80099B5B3 /* README.md */, - 01E55265224CD02E0099B5B3 /* PayKun.framework */, 0177EE9A217DE4C0007BF559 /* AppDelegate.swift */, 0177EE9C217DE4C0007BF559 /* ViewController.swift */, 0177EE9E217DE4C0007BF559 /* Main.storyboard */, diff --git a/PaykunSampleApp/Info.plist b/PaykunSampleApp/Info.plist index 78930ea..afae292 100644 --- a/PaykunSampleApp/Info.plist +++ b/PaykunSampleApp/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 1.2 CFBundleVersion 1 LSRequiresIPhoneOS diff --git a/PaykunSampleApp/PayKun.framework/Headers/PaykunCheckout.h b/PaykunSampleApp/PayKun.framework/Headers/PaykunCheckout.h index 8ca38eb..1a617b0 100644 --- a/PaykunSampleApp/PayKun.framework/Headers/PaykunCheckout.h +++ b/PaykunSampleApp/PayKun.framework/Headers/PaykunCheckout.h @@ -5,14 +5,26 @@ #pragma mark - PaykunCheckout Delegate @protocol PaykunCheckoutDelegate @required + +// payment success method -(void)onPaymentFailed:(NSDictionary * _Nonnull)responce; + +// payment fail method -(void)onPaymentSucceed:(NSDictionary * _Nonnull)responce; + @end @interface PaykunCheckout : NSObject #pragma mark - UI Method + +// initialization method -(_Nonnull instancetype)initWithKey:(NSString * _Nonnull)key merchantId:(NSString * _Nonnull)merchantid isLive:(BOOL)status andDelegate:(id _Nonnull)delegate; --(void)CheckoutWithCustomerName:(NSString * _Nonnull)customername customerEmail:(NSString * _Nonnull)customeremail customerMobile:(NSString * _Nonnull)customermobile productName:(NSString * _Nonnull)productname orderNo:(NSString * _Nonnull)orderno amount:(NSString * _Nonnull)amount viewController:(UIViewController * _Nonnull)sampleview; + +// open checkout method +-(void)checkoutWithCustomerName:(NSString * _Nonnull)customername customerEmail:(NSString * _Nonnull)customeremail customerMobile:(NSString * _Nonnull)customermobile productName:(NSString * _Nonnull)productname orderNo:(NSString * _Nonnull)orderno amount:(NSString * _Nonnull)amount viewController:(UIViewController * _Nonnull)sampleview; + +// get transaction detail method +-(void)getTransactionByPaymentId:(NSString * _Nonnull)paymentId block:(void (^_Nonnull)(NSDictionary * _Nonnull responce))handler; @end diff --git a/PaykunSampleApp/PayKun.framework/Info.plist b/PaykunSampleApp/PayKun.framework/Info.plist index cfd6eb4..865b302 100644 Binary files a/PaykunSampleApp/PayKun.framework/Info.plist and b/PaykunSampleApp/PayKun.framework/Info.plist differ diff --git a/PaykunSampleApp/PayKun.framework/PayKun b/PaykunSampleApp/PayKun.framework/PayKun index 9da87b6..557b3cc 100755 Binary files a/PaykunSampleApp/PayKun.framework/PayKun and b/PaykunSampleApp/PayKun.framework/PayKun differ diff --git a/PaykunSampleApp/ViewController.swift b/PaykunSampleApp/ViewController.swift index 6797891..d2c3708 100644 --- a/PaykunSampleApp/ViewController.swift +++ b/PaykunSampleApp/ViewController.swift @@ -9,7 +9,8 @@ class ViewController: UIViewController,PaykunCheckoutDelegate { override func viewDidLoad() { super.viewDidLoad() - objPaykun = PaykunCheckout.init(key: "297E1CBBD172DA76325163469CB8D1EA", merchantId: "357851063624213", isLive: false, andDelegate: self) + // initialization method + objPaykun = PaykunCheckout.init(key:"YourApiKey", merchantId:"YourMerchantId", isLive:true, andDelegate: self) } // MARK: IBAction Method @@ -20,7 +21,8 @@ class ViewController: UIViewController,PaykunCheckoutDelegate { orderId = orderId + ("\(arc4random_uniform(10))") } - objPaykun.checkout(withCustomerName: "Paul", customerEmail: "example@mail.com", customerMobile: "", productName: "Stationery", orderNo: orderId, amount: "10", viewController: self) + // open checkout method + objPaykun.checkout(withCustomerName:"Paul", customerEmail:"example@mail.com", customerMobile:"", productName:"Stationery", orderNo:orderId, amount: "10", viewController:self) } // MARK: PaykunCheckoutDelegate @@ -30,6 +32,11 @@ class ViewController: UIViewController,PaykunCheckoutDelegate { let alert = UIAlertController(title: "Oops", message: "fail with req_id:" + requestId, preferredStyle: .alert) alert.addAction(UIAlertAction(title: "Okay", style: UIAlertAction.Style.default, handler: nil)) self.present(alert, animated: true, completion: nil) + + // get transaction detail + objPaykun.getTransactionByPaymentId(requestId, block: { responce in + print("responce: \(responce)") + }) } func onPaymentSucceed(_ responce: [AnyHashable : Any]) { @@ -38,6 +45,11 @@ class ViewController: UIViewController,PaykunCheckoutDelegate { let alert = UIAlertController(title: "Success", message: "success with req_id:" + requestId, preferredStyle: .alert) alert.addAction(UIAlertAction(title: "Okay", style: UIAlertAction.Style.default, handler: nil)) self.present(alert, animated: true, completion: nil) + + // get transaction detail + objPaykun.getTransactionByPaymentId(requestId, block: { responce in + print("responce: \(responce)") + }) } } diff --git a/README.md b/README.md index e6f0bcf..6ba1ac8 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,23 @@ The iOS SDK library lets you seamlessly integrate the entire payment ecosystem i ## Features | Doc -### Step 1: Importing the Library +### Step 1: Get Access Token (For Device) + +• Device access token is bounded with the application package name; hence one Access Token per Application will be granted. + +• You can generate/regenerate Access token and API KEY by logging into your PayKun Admin panel. + +• Go to: Settings => Security => Device API KEY Here you will find generate button, if you have not generated any Device Access Token before. + +• You must provide the package name of your application to generate the access token. + +• If you have ever generated any Access Token, you will see Package Name with Creation date of it. You won’t be able to retrieve any old Access Token (Due to security concerns), that’s why we have provided regenerate option. + +``` +Note: Once you regenerate API KEY, your old API KEY will immediately stop working. So be double sure and cautious before regenerating API KEY. +``` + +### Step 2: Importing the Library Follow the instruction given below to import the SDK library to your Swift or Objective-C project : @@ -15,8 +31,7 @@ Follow the instruction given below to import the SDK library to your Swift or Ob 5. Click Add. 6. Navigate to Target settings > General and add the Paykun.framework in both Embeded Binaries and Linked Frameworks and Libraries. - -### Step 2: Initialize the Paykun SDK +### Step 3: Initialize the Paykun SDK To initialize the Paykun SDK, you will need the following: @@ -24,36 +39,39 @@ To initialize the Paykun SDK, you will need the following: • Merchant Id +• isLive (true for live environment and false for test environment) + ``` import Paykun class ViewController: UIViewController, PaykunCheckoutDelegate { -var objPaykun: PaykunCheckout! + var objPaykun: PaykunCheckout! -override func viewDidLoad() { - super.viewDidLoad() - objPaykun = PaykunCheckout.init(key: paykunTestKey, merchantId: merchantId, isLive: true,andDelegate: self) + override func viewDidLoad() { + super.viewDidLoad() + objPaykun = PaykunCheckout.init(key:"YourApiKey", merchantId:"YourMerchantId", isLive:true, andDelegate:self) + } } ``` -### Step 3: Pass Payment Parameter and Display Checkout Form +### Step 4: Pass Payment Parameter and Display Checkout Form Add the following code to your ViewController or where ever you want to initialize payments: ``` func showPaymentCheckout(){ - objPaykun.checkout(withCustomerName: “name”, customerEmail: “email”, customerMobile: “mobile”, productName: “product”, orderNo: “order”, amount: “amount”, viewController: self); + objPaykun.checkout(withCustomerName:“name”, customerEmail:“email”, customerMobile:“mobile”, productName:“product”, orderNo:“order”, amount:“amount”, viewController:self); } ``` -### Step 4: Handle Success and Fail Event +### Step 5: Handle Success and Fail Event Success ``` func onPaymentSucceed(_ responce: [AnyHashable : Any]) { let msg = responce!["req_id"] as! String - let alert = UIAlertView(title: “Success”, message: "fail with req_id:"+msg, delegate: nil, cancelButtonTitle: "Okay") + let alert = UIAlertView(title:“Success”, message:"fail with req_id:"+msg, delegate:nil, cancelButtonTitle:"Okay") alert.show() } ``` @@ -62,14 +80,19 @@ Fail ``` func onPaymentFailed(_ responce: [AnyHashable : Any]) { let msg = responce!["req_id"] as! String - let alert = UIAlertView(title: “Error”, message: "fail with req_id:"+msg, delegate: nil, cancelButtonTitle: "Okay") + let alert = UIAlertView(title:“Error”, message:"fail with req_id:"+msg, delegate:nil, cancelButtonTitle:"Okay") alert.show() } ``` +### Get Transaction Details -### For further help, see our [Documentation](https://paykun.com/docs) or [Contact Us](https://paykun.com/contact) - +``` +objPaykun.getTransactionByPaymentId("1234", block: { responce in + print("responce: \(responce)") +}) +``` +### For further help, see our [Documentation](https://paykun.com/docs) or [Contact Us](https://paykun.com/contact)