Skip to content

Commit

Permalink
Merge pull request #3 from paytrail/add-decimal-vat-support
Browse files Browse the repository at this point in the history
Add decimal VAT support
  • Loading branch information
kotivuori authored Oct 21, 2024
2 parents fc50135 + e5ba74b commit 39086ab
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ minimumVersion = "1.0.0-beta1"

## Get Started

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``:
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``:

```
class AppDelegate: NSObject, UIApplicationDelegate {
Expand All @@ -60,7 +60,7 @@ class AppDelegate: NSObject, UIApplicationDelegate {
}
```

Or in the *main app* in a SwiftUI app before any API is called:
Or in the *main app* in a SwiftUI app before any API is called:
```
@main
struct PaytrailSdkExamplesApp: App {
Expand All @@ -70,7 +70,7 @@ struct PaytrailSdkExamplesApp: App {
.preferredColorScheme(.light)
.onAppear {
PaytrailMerchant.create(merchantId: "YOUR_MERCHANT_ID", secret: "YOUR_MERCHANT_SECRET")
TLogger.globalLevel = .debug // Enable SDK debug logging
PTLogger.globalLevel = .debug // Enable SDK debug logging
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions paytrail-ios-sdk.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|

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

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

end
end
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

/// PaymentRequestBody
///
/// 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.
/// 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.
///
public struct PaymentRequestBody : Codable {

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

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

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

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) {
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) {
self.unitPrice = unitPrice
self.units = units
self.vatPercentage = vatPercentage
Expand Down
4 changes: 2 additions & 2 deletions paytrail-ios-sdkTests/CardTokenApiTestSuite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ final class CardTokenApiTestSuite: XCTestCase {
override func setUpWithError() throws {
PaytrailMerchant.create(merchantId: "375917", secret: "SAIPPUAKAUPPIAS")
merchant = PaytrailMerchant.shared
tokenizedId = "96f32ab1-8c1f-42f1-9c11-cce40cb648ac"
tokenizedIdThreeDS = "17b8c4a0-9a2d-4bdd-8eb3-f2deacb96292"
tokenizedId = "9181d033-84f8-4962-beb5-91bbf92cf863"
tokenizedIdThreeDS = "65a3a59e-439a-4ac5-a1b1-c07c3776426d"
transactionType = .cit
authorizationType = .charge
committedTransactionId = "526b728c-1a66-11ee-bdc7-f3592b2cbca7"
Expand Down
8 changes: 4 additions & 4 deletions paytrail-ios-sdkTests/CreatePaymentApiTestSuite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ final class CreatePaymentApiTestSuite: XCTestCase {
// merchantSIS = PaytrailMerchant(merchantId: "695861", secret: "MONISAIPPUAKAUPPIAS")
payload = PaymentRequestBody(stamp: UUID().uuidString,
reference: "3759170",
amount: 1525,
amount: 3050,
currency: .eur,
language: .fi,
items: [Item(unitPrice: 1525, units: 1, vatPercentage: 24, productCode: "#1234", stamp: "2018-09-12")],
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)],
customer: Customer(email: "[email protected]"),
redirectUrls: CallbackUrls(success: "google.com", cancel: "google.com"),
callbackUrls: nil)

payloadSIS = PaymentRequestBody(stamp: UUID().uuidString,
reference: "3759170",
amount: 1525,
amount: 3050,
currency: .eur,
language: .fi,
items: [Item(unitPrice: 1525, units: 1, vatPercentage: 24, productCode: "#1234", merchant: "695874", stamp: UUID().uuidString, reference: "3759170")],
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")],
customer: Customer(email: "[email protected]"),
redirectUrls: CallbackUrls(success: "google.com", cancel: "google.com"),
callbackUrls: nil)
Expand Down

0 comments on commit 39086ab

Please sign in to comment.