Skip to content

Commit e5ba74b

Browse files
committed
Add decimal VAT support
1 parent fc50135 commit e5ba74b

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ minimumVersion = "1.0.0-beta1"
4747

4848
## Get Started
4949

50-
Before getting started with the SDK's APIs, a shared ``PaytrailMerchant`` should be created in the beginning when app launches in the, for example, ``AppDelegate``:
50+
Before getting started with the SDK's APIs, a shared ``PaytrailMerchant`` should be created in the beginning when app launches in the, for example, ``AppDelegate``:
5151

5252
```
5353
class AppDelegate: NSObject, UIApplicationDelegate {
@@ -60,7 +60,7 @@ class AppDelegate: NSObject, UIApplicationDelegate {
6060
}
6161
```
6262

63-
Or in the *main app* in a SwiftUI app before any API is called:
63+
Or in the *main app* in a SwiftUI app before any API is called:
6464
```
6565
@main
6666
struct PaytrailSdkExamplesApp: App {
@@ -70,7 +70,7 @@ struct PaytrailSdkExamplesApp: App {
7070
.preferredColorScheme(.light)
7171
.onAppear {
7272
PaytrailMerchant.create(merchantId: "YOUR_MERCHANT_ID", secret: "YOUR_MERCHANT_SECRET")
73-
TLogger.globalLevel = .debug // Enable SDK debug logging
73+
PTLogger.globalLevel = .debug // Enable SDK debug logging
7474
}
7575
}
7676
}

paytrail-ios-sdk.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |spec|
22

33
spec.name = "paytrail-ios-sdk"
4-
spec.version = "1.0.0-beta3"
4+
spec.version = "1.0.0-beta4"
55
spec.summary = "Paytrail Mobile SDK for iOS"
66
spec.description = <<-DESC
77
Paytrail iOS SDK providing the major payment features for easy mobile payments.
@@ -19,4 +19,4 @@ Pod::Spec.new do |spec|
1919

2020
spec.source_files = "paytrail-ios-sdk", "paytrail-ios-sdk/**/*.{h,m,swift}"
2121

22-
end
22+
end

paytrail-ios-sdk/Networking/Models/CreatePayment/PaymentRequestBody.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99

1010
/// PaymentRequestBody
1111
///
12-
/// PaymentRequestBody data model for APIs 'createPayment(of:secret:payload:completion:)' and 'createTokenPayment(of:secret:payload:transactionType:authorizationType:completion:)'. The latter API requires a car token.
12+
/// PaymentRequestBody data model for APIs 'createPayment(of:secret:payload:completion:)' and 'createTokenPayment(of:secret:payload:transactionType:authorizationType:completion:)'. The latter API requires a card token.
1313
///
1414
public struct PaymentRequestBody : Codable {
1515

@@ -147,8 +147,8 @@ public struct Item: Codable, Equatable {
147147
/// Quantity, how many items ordered. Negative values are not supported.
148148
public let units: Int
149149

150-
/// VAT percentage
151-
public let vatPercentage: Int
150+
/// VAT percentage. Values between 0 and 100 are allowed with one decimal place.
151+
public let vatPercentage: Decimal
152152

153153
/// Merchant product code. May appear on invoices of certain payment methods. Maximum of 100 characters
154154
public let productCode: String
@@ -177,7 +177,7 @@ public struct Item: Codable, Equatable {
177177
/// Shop-in-Shop commission. Do not use for normal payments.
178178
public let commission: Commission?
179179

180-
public init(unitPrice: Int, units: Int, vatPercentage: Int, productCode: String, deliveryDate: String? = nil, description: String? = nil, category: String? = nil, merchant: String? = nil, stamp: String? = nil, reference: String? = nil, orderId: String? = nil, commission: Commission? = nil) {
180+
public init(unitPrice: Int, units: Int, vatPercentage: Decimal, productCode: String, deliveryDate: String? = nil, description: String? = nil, category: String? = nil, merchant: String? = nil, stamp: String? = nil, reference: String? = nil, orderId: String? = nil, commission: Commission? = nil) {
181181
self.unitPrice = unitPrice
182182
self.units = units
183183
self.vatPercentage = vatPercentage

paytrail-ios-sdkTests/CardTokenApiTestSuite.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ final class CardTokenApiTestSuite: XCTestCase {
2222
override func setUpWithError() throws {
2323
PaytrailMerchant.create(merchantId: "375917", secret: "SAIPPUAKAUPPIAS")
2424
merchant = PaytrailMerchant.shared
25-
tokenizedId = "96f32ab1-8c1f-42f1-9c11-cce40cb648ac"
26-
tokenizedIdThreeDS = "17b8c4a0-9a2d-4bdd-8eb3-f2deacb96292"
25+
tokenizedId = "9181d033-84f8-4962-beb5-91bbf92cf863"
26+
tokenizedIdThreeDS = "65a3a59e-439a-4ac5-a1b1-c07c3776426d"
2727
transactionType = .cit
2828
authorizationType = .charge
2929
committedTransactionId = "526b728c-1a66-11ee-bdc7-f3592b2cbca7"

paytrail-ios-sdkTests/CreatePaymentApiTestSuite.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ final class CreatePaymentApiTestSuite: XCTestCase {
2929
// merchantSIS = PaytrailMerchant(merchantId: "695861", secret: "MONISAIPPUAKAUPPIAS")
3030
payload = PaymentRequestBody(stamp: UUID().uuidString,
3131
reference: "3759170",
32-
amount: 1525,
32+
amount: 3050,
3333
currency: .eur,
3434
language: .fi,
35-
items: [Item(unitPrice: 1525, units: 1, vatPercentage: 24, productCode: "#1234", stamp: "2018-09-12")],
35+
items: [Item(unitPrice: 1525, units: 1, vatPercentage: 14, productCode: "#1234", stamp: UUID().uuidString),Item(unitPrice: 1525, units: 1, vatPercentage: 25.5, productCode: "#1234", stamp: UUID().uuidString)],
3636
customer: Customer(email: "test.customer@example.com"),
3737
redirectUrls: CallbackUrls(success: "google.com", cancel: "google.com"),
3838
callbackUrls: nil)
3939

4040
payloadSIS = PaymentRequestBody(stamp: UUID().uuidString,
4141
reference: "3759170",
42-
amount: 1525,
42+
amount: 3050,
4343
currency: .eur,
4444
language: .fi,
45-
items: [Item(unitPrice: 1525, units: 1, vatPercentage: 24, productCode: "#1234", merchant: "695874", stamp: UUID().uuidString, reference: "3759170")],
45+
items: [Item(unitPrice: 1525, units: 1, vatPercentage: 14, productCode: "#1234", merchant: "695874", stamp: UUID().uuidString, reference: "1234"),Item(unitPrice: 1525, units: 1, vatPercentage: 25.5, productCode: "#1234", merchant: "695874", stamp: UUID().uuidString, reference: "1234")],
4646
customer: Customer(email: "test.customer@example.com"),
4747
redirectUrls: CallbackUrls(success: "google.com", cancel: "google.com"),
4848
callbackUrls: nil)

0 commit comments

Comments
 (0)