You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+57-3
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,9 @@ The QuickPay SDK wraps the [QuickPay API](https://learn.quickpay.net/tech-talk/a
5
5
6
6
## Installation
7
7
8
-
You can install the QuickPay SDK either by downloading it directly from our GitHub repo or by adding it as a Swift Package. If you want to use Swift Packages simply point to the git repo and check out the master branch.
8
+
You can install the QuickPay SDK either by downloading it directly from our GitHub repo or by adding it as a Swift Package.
9
+
10
+
If you want to use Swift Packages simply point to the git repo https://github.com/QuickPay/ios-sdk and check out the master branch.
9
11
10
12
11
13
### API key and permissions
@@ -114,7 +116,7 @@ QuickPay SDK supports MobilePay natively so you can create a great app experienc
114
116
It is recommended that you check if the users have the MobilePay App installed and only show the payment option if it is available. The QuickPay class can help you with this.
115
117
116
118
```swift
117
-
QuickPay.isMobilePayAvailable()
119
+
QuickPay.isMobilePayAvailableOnDevice()
118
120
```
119
121
120
122
@@ -131,7 +133,7 @@ You can read more about the URL schemes on [https://developers.apple.com](https:
131
133
132
134
First, you need to create a payment just like with the payment window, but after that, the flow is different since we do not have the payment window to handle a lot of tasks for us.
133
135
134
-
When you have created your payment you need to start a MobilePay payment session. Create a `MobilePayParameters` object and specify the custom URL scheme that you created earlier. You can also specify the language of MobilePay and add a URL to a logo you want it to be displayed. Add this information to a `QPCreatePaymenSessionParameters` along with the amount of money you want to authorize. Finally, put everything together in a `QPCreatePaymenSessionRequest` and send the request.
136
+
When you have created your payment you need to start a MobilePay payment session. Create a `MobilePayParameters` object and specify the custom URL scheme that you created earlier. You can also specify the language of MobilePay and add a URL to a logo you want it to be displayed. Add this information to a `QPCreatePaymentSessionParameters` along with the amount of money you want to authorize. Finally, put everything together in a `QPCreatePaymentSessionRequest` and send the request.
135
137
136
138
```swift
137
139
let mobilePayParameters =MobilePayParameters(returnUrl: "quickpayexampleshop://", language: "dk", shopLogoUrl: "https://SomeUrl/SomeImage.png")
In the completion handler, we need to check the status of the payment. This is done in the same way as with the payment window. Create a `QPGetPaymentRequest` with the payment id and check if the updated payment is accepted.
160
162
161
163
164
+
### Vipps
165
+
166
+
QuickPay SDK supports Vipps natively so you can create a great app experience. To query the Vipps App you need to make some changes to your project settings and implement the payment as shown later in this guide.
167
+
168
+
It is recommended that you check if the users have the Vipps App installed and only show the payment option if it is available. The QuickPay class can help you with this.
169
+
170
+
```swift
171
+
QuickPay.isVippsAvailableOnDevice()
172
+
```
173
+
174
+
175
+
#### URL Schemes for Vipps
176
+
177
+
To query the MobilePay App you need to whitelist the `vipps` URL scheme to the `LSApplicationQueriesSchemes` array in your `Info.plist`. With this done your application can now query the Vipps App with the needed information for Vipps to handle the authorization of a payment.
178
+
179
+
You also need to specify a custom URL scheme for the Vipps App to query back to when it is done doing its job. This is done in the `URL types` array in your `Info.plist`.
180
+
181
+
You can read more about the URL schemes on [https://developers.apple.com](https://developer.apple.com/documentation/uikit/core_app/allowing_apps_and_websites_to_link_to_your_content/defining_a_custom_url_scheme_for_your_app)
182
+
183
+
184
+
#### Payment flow for Vipps
185
+
186
+
First, you need to create a payment just like with the payment window, but after that, the flow is different since we do not have the payment window to handle a lot of tasks for us.
187
+
188
+
When you have created your payment you need to start a Vipps payment session. Create a `VippsParameters` object and specify the custom URL scheme that you created earlier. Add this information to a `QPCreatePaymentSessionParameters` along with the amount of money you want to authorize and remember to set the currency to "NOK". Finally, put everything together in a `QPCreatePaymentSessionRequest` and send the request.
189
+
190
+
```swift
191
+
let vippsParams =VippsParameters(returnUrl: "quickpayexampleshop://")
192
+
let sessionParameters =QPCreatePaymentSessionParameters(amount: Int(self.totalBasketValue() *100), vipps: vippsParams)
193
+
194
+
let request =QPCreatePaymenSessionRequest(id: payment.id, parameters: sessionParameters)
195
+
196
+
request.sendRequest(success: { (payment) in
197
+
// Handle the payment
198
+
}, failure: { (data, response, error) in
199
+
// Handle the failure
200
+
})
201
+
```
202
+
203
+
With the payment containing a session id, we can now query Vipps to authorize the payment.
204
+
205
+
```swift
206
+
QuickPay.authorizeWithVipps(payment: payment, completion: { (payment) in {
207
+
// Handle the payment
208
+
}, failure: {
209
+
// Handle the failure
210
+
}
211
+
```
212
+
213
+
In the completion handler, we need to check the status of the payment. This is done in the same way as with the payment window. Create a `QPGetPaymentRequest` with the payment id and check if the updated payment is accepted.
214
+
215
+
162
216
### Apple Pay
163
217
164
218
In order to take advantage of Apple Pay, first, you need to do some initial setup to your project and generate a signing certificate. When that is done you also need to implement a bit of code to handle the native Apple Pay flow.
0 commit comments