Skip to content

Commit

Permalink
Performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
vishubheda committed Apr 17, 2019
1 parent 2d6926f commit fb1b2d1
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 24 deletions.
12 changes: 6 additions & 6 deletions PaykunSampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -25,22 +25,22 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
01E55268224CD0390099B5B3 /* PayKun.framework in Embed Frameworks */,
01153CA6226747F1004A6C43 /* PayKun.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
01153CA3226747EA004A6C43 /* PayKun.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = PayKun.framework; sourceTree = "<group>"; };
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 = "<group>"; };
0177EE9C217DE4C0007BF559 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
0177EE9F217DE4C0007BF559 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
0177EEA1217DE4C9007BF559 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
0177EEA4217DE4C9007BF559 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
0177EEA6217DE4C9007BF559 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
01E55265224CD02E0099B5B3 /* PayKun.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = PayKun.framework; sourceTree = "<group>"; };
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 */
Expand All @@ -50,7 +50,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
01E55267224CD0390099B5B3 /* PayKun.framework in Frameworks */,
01153CA5226747F1004A6C43 /* PayKun.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -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 */,
Expand Down
2 changes: 1 addition & 1 deletion PaykunSampleApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.2</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
Expand Down
14 changes: 13 additions & 1 deletion PaykunSampleApp/PayKun.framework/Headers/PaykunCheckout.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,26 @@
#pragma mark - PaykunCheckout Delegate
@protocol PaykunCheckoutDelegate <NSObject>
@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 <PaykunCheckoutDelegate> _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
Binary file modified PaykunSampleApp/PayKun.framework/Info.plist
Binary file not shown.
Binary file modified PaykunSampleApp/PayKun.framework/PayKun
Binary file not shown.
16 changes: 14 additions & 2 deletions PaykunSampleApp/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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]) {
Expand All @@ -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)")
})
}
}

51 changes: 37 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 :

Expand All @@ -15,45 +31,47 @@ 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:

• Device API key

• 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()
}
```
Expand All @@ -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)

0 comments on commit fb1b2d1

Please sign in to comment.