Introduction
PayPro Global Inc offers the best shopping experience through a complex payment processing system which delivers secure transactions, versatility (multiple options to satisfy all customer preferences), user friendly experience (localized content, payment methods and currencies) and the highest degree of transaction fulfillment.
PPGAppKit is PayPro Global's SDK which enables quick integration of our shopping experience in a Mac App.
This SDK is a thin layer over Webview which enables integration of PayProGlobal e-commerce solution in Mac App.
To get an idea of how it works, the SDK provides a Swift and Objective-C examples. All source code is released under the MIT license. It is open to contributions and its use is unrestricted.
PPGAppKit
PPGAppKit consists of two primary components PayProWebView and Configuration.
The PayProWebView provides functionality to load the e-commerce solution of PayPro Global. PayProWebView is initialized with Configuration object and embedded within the Mac App. This document provides details about how to construct a URL which is provided to Configuration object. Once order has been submitted and thank you page is loaded you get PayProGlobal Order Id, status and the invoice link through WebView's HTTP Response headers.
Requirements
-
Xcode 11.x
-
Swift 5.x
-
Objective-C 2.0
Installation
CocoaPods
# Podfile
use_frameworks!
target 'YOUR_TARGET_NAME' do
pod 'PPGAppKit'
end
Replace YOUR_TARGET_NAME and then, in the Podfile directory, type:
$ pod install
If you don't have CocoaPods installed, it can be install using following command:
$ sudo gem install cocoapods
Swift Package Manager
To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter its repository URL https://github.com/paypro-global/MacOsWebViewSDK.git
How-to use PPGAppKit in Swift
-
Read our URL Parameters guide to learn how about URL parameters.
-
Create
Configurationobject using the URL parameters explained in Step 1. -
Create
PayProGlobalinitialized withConfigurationobject. -
Observe
didFail/didStartPaymentViewLoad/didFinishPaymentViewLoadto track progress of URL Load. -
Observe
didCompletedOrder, it is called along with order info on order completion. -
Observe
urlCredentialmethod to handle Authentication Challenge. -
Access
paymentViewobject inPayProGlobaland add it as a sub view on any NSWindow.
Example located in Example/Swift folder show how to create PayProGlobal and use it in detail.
Use Swift Package or CocoaPods as explained in Installation Section.
If you have used SwiftPackage, Open PayProGlobalStore.xcodeproj, build and run.
If you have used CocoaPods, Open PayProGlobalStore.xcworkspace, build and run.
Example
private lazy var payproGlobal: PayProGlobal = {
let configuration = Configuration(url: "https://store.payproglobal.com/checkout?products[1][id]=59421&use-test-mode=true&secret-key=gEcP!-xp9M")
return PPGAppKit.create(configuration: configuration)
}()
private func load(){
let paymentView = payproGlobal.paymentView
payproGlobal.didFail = { (error) in
print("Did Fail \(error)")
}
payproGlobal.didStartPaymentViewLoad = {
print("didStartPaymentViewLoad ")
}
payproGlobal.didFinishPaymentViewLoad = {
print("didFinishPaymentViewLoad ")
}
payproGlobal.didCompletedOrder = { (orderInfo) in
print("did complete Order \(orderInfo)")
}
payproGlobal.urlCredential = { [weak self] (crediential) in
self?.showAuthenticationUI(with: crediential)
}
paymentView.translatesAutoresizingMaskIntoConstraints = false
container.addConstraints(paymentViewConstraints)
container.addSubview(paymentView)
}
How-to use PPGAppKit in Objective-C
-
Read our URL Parameters guide to learn how about URL parameters.
-
Create
Configurationobject using -
Create
PayProGlobalinitialized withConfigurationobject. Examples located in Example/Swift and Example/Objective-C are showing how to createPayProGlobaland use it in detail. -
Observe
didFail/didStartPaymentViewLoad/didFinishPaymentViewLoadto track progress of URL Load. -
Observe
didCompletedOrder, it is called along with order info on order completion. -
Observe
urlCredentialmethod to handle Authentication Challenge. -
Access
paymentViewobject inPayProGlobaland add it as a sub view on any NSWindow.
Example located in Example/Objectice-C folder show how to create PayProGlobal and use it in detail.
Run following command to create a XcodeWorkspace using CocoaPods:
$ cd [../Example/Objective-C]
$ pod install
If you don't have CocoaPods installed, it can be install using following command:
$ sudo gem install cocoapods
Open PayProGlobalStore.xcworkspace , build and run it.
Example
Configuration *configuration = [[Configuration alloc] initWithUrl:@"https://store.payproglobal.com/checkout?products[1][id]=59421&use-test-mode=true&secret-key=gEcP!-xp9M"];
self.payproGlobal = [PPGAppKit createWithConfiguration:configuration];
self.payproGlobal.didStartPaymentViewLoad = ^(){
NSLog(@"Did start");
};
self.payproGlobal.didFinishPaymentViewLoad = ^(){
NSLog(@"Did Finish");
};
self.payproGlobal.didCompletedOrder = ^(NSDictionary<NSString *,id> * orderInfo){
NSLog(@"did Complete Order %@",orderInfo);
};
self.payproGlobal.didFail = ^(NSError * error) {
NSLog(@"Did Fail");
};
__weak ViewController *weakSelf = self;
self.payproGlobal.urlCredential = ^(void (^ callback)(NSURLCredential * _Nullable)) {
[weakSelf showAlert:callback];
};
NSView *paymentView = [self.payproGlobal paymentView];
[paymentView setTranslatesAutoresizingMaskIntoConstraints:false];
[self.container addSubview:paymentView];
Sandbox Settings
If your app is sandboxed you should do following in Signing & Capabilities tab:
-
Enable Outgoing Connections (Client) to allow the framework to send data to PayPro Global.
-
Enable Printing to allow the framework to print invoice.
-
Framework supports Saving of invoice feature by providing Read/Write access to User Selected File.
