Skip to content

Commit

Permalink
Usage instructions updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
hugohernandez authored Mar 6, 2019
1 parent 4ae63bb commit 64da985
Showing 1 changed file with 58 additions and 17 deletions.
75 changes: 58 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ Please refer to the following documentation sections for field documentation:
## Installation

- Download the latest released version (https://github.com/open-pay/openpay-swift-ios/releases/download/v.2.0.2/SDK-v2.0.2.zip).
- Add openpay framework (Openpay.framework) to General -> Embeded Binaries.
- Add openpay framework (Openpay.framework)
- Go to General -> Embedded Binaries
- Click "Add items"
- In the popup, click "Add Other..." option
- Select the file "Openpay.framework"
- Check the option "Copy items if needed"
- Add webkit framework to General -> Linked Framework and Libraries.
- Search for "WebKit.framework", select it and click "add"
- Select the file "Openpay.framework" and click "Open"
- Check the option "Copy items if needed" and click "Finish"
- Add webkit framework
- Go to General -> Linked Framework and Libraries
- Click "Add items"
- Search for "WebKit.framework", select it and click "Add"

## Usage

Expand All @@ -39,9 +43,14 @@ For create an instance Openpay needs:
- Public API Key

```swift
static let MERCHANT_ID = "merchantId"
static let API_KEY = "apiKey"

var openpay : Openpay!

openpay = Openpay(withMerchantId: "Your Merchant ID", andApiKey: "Your Private Key", isProductionMode: false, isDebug: false)
func myFunction() {
openpay = Openpay(withMerchantId: MERCHANT_ID, andApiKey: API_KEY, isProductionMode: false, isDebug: false)
}
```

#### Production Mode
Expand All @@ -51,7 +60,9 @@ Use isProductionMode = true
```swift
var openpay : Openpay!

openpay = Openpay(withMerchantId: "Your Merchant ID", andApiKey: "Your Private Key", isProductionMode: true, isDebug: false)
func myFunction() {
openpay = Openpay(withMerchantId: MERCHANT_ID, andApiKey: API_KEY, isProductionMode: true, isDebug: false)
}
```

#### Create a SessionID
Expand All @@ -64,9 +75,18 @@ The following parameters are required:
```swift
var openpay : Openpay!

openpay = Openpay(withMerchantId: "Your Merchant ID", andApiKey: "Your Private Key", isProductionMode: true, isDebug: false)
func myFunction() {
openpay = Openpay(withMerchantId: MERCHANT_ID, andApiKey: API_KEY, isProductionMode: false, isDebug: false)
openpay.createDeviceSessionId(successFunction: successSessionID, failureFunction: failSessionID)
}

func successSessionID(sessionID: String) {
print("SessionID: \(sessionID)")
}

openpay.createDeviceSessionId(successFunction: successSessionID, failureFunction: failSessionID)
func failSessionID(error: NSError) {
print("\(error.code) - \(error.localizedDescription)")
}
```

#### Display Card Form
Expand All @@ -81,7 +101,18 @@ For display the form you need to pass the following parameters:
```swift
var openpay : Openpay!

openpay.loadCardForm(in: self, successFunction: successCard, failureFunction: failCard, formTitle: "Openpay")
func myFunction() {
openpay = Openpay(withMerchantId: MERCHANT_ID, andApiKey: API_KEY, isProductionMode: false, isDebug: false)
openpay.loadCardForm(in: self, successFunction: successCard, failureFunction: failCard, formTitle: "Openpay")
}

func successCard() {

}

func failCard(error: NSError) {
print("\(error.code) - \(error.localizedDescription)")
}
```

#### Create a token
Expand All @@ -93,14 +124,24 @@ For more information about how to create a token, please refer to [Create a toke
```swift
var openpay : Openpay!

openpay = Openpay(withMerchantId: "Your Merchant ID", andApiKey: "Your Private Key", isProductionMode: true, isDebug: false)

openpay.loadCardForm(in: self, successFunction: successCard, failureFunction: failCard, formTitle: "Openpay")
func myFunction() {
openpay = Openpay(withMerchantId: MERCHANT_ID, andApiKey: API_KEY, isProductionMode: false, isDebug: false)
openpay.loadCardForm(in: self, successFunction: successCard, failureFunction: failCard, formTitle: "Openpay")
}

openpay.createTokenWithCard(address: nil, successFunction: successToken, failureFunction: failToken)
func successCard() {
openpay.createTokenWithCard(address: nil, successFunction: successToken, failureFunction: failToken)
}

```
func failCard(error: NSError) {
print("\(error.code) - \(error.localizedDescription)")
}

##### Response
func successToken(token: OPToken) {
print("TokenID: \(token.id)")
}

If the request is correct, return an instance of OPToken.
func failToken(error: NSError) {
print("\(error.code) - \(error.localizedDescription)")
}
```

0 comments on commit 64da985

Please sign in to comment.