Skip to content

Commit 1c69cd1

Browse files
authored
Merge pull request #7 from paytrail/make-items-optional
Make items optional
2 parents 62ef773 + c21e2a0 commit 1c69cd1

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

paytrail-ios-sdk.podspec

Lines changed: 1 addition & 1 deletion
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-beta5"
4+
spec.version = "1.0.0-beta6"
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.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public struct PaymentRequestBody : Codable {
2929
public let language : Language
3030

3131
/// Array of items. Always required for Shop-in-Shop payments. Required if VAT calculations are wanted in settlement reports.
32-
public let items : [Item]
32+
public let items : [Item]?
3333

3434
/// Customer information, see Customer
3535
public let customer : Customer
@@ -69,7 +69,7 @@ public struct PaymentRequestBody : Codable {
6969
amount: Int,
7070
currency: Currency,
7171
language: Language,
72-
items: [Item],
72+
items: [Item]? = nil,
7373
customer: Customer,
7474
redirectUrls: CallbackUrls,
7575
callbackUrls: CallbackUrls? = nil,

paytrail-ios-sdkTests/CreatePaymentApiTestSuite.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ final class CreatePaymentApiTestSuite: XCTestCase {
1414
// var merchantSIS: PaytrailMerchant! // Shop-in-shops merchant
1515
var payload: PaymentRequestBody!
1616
var payloadInvalid: PaymentRequestBody!
17+
var payloadNoItems: PaymentRequestBody!
1718
var payloadSIS: PaymentRequestBody!
1819
var providerImageUrl: String!
1920
var providerImageUrlInvalid: String!
@@ -37,6 +38,15 @@ final class CreatePaymentApiTestSuite: XCTestCase {
3738
redirectUrls: CallbackUrls(success: "google.com", cancel: "google.com"),
3839
callbackUrls: nil)
3940

41+
payloadNoItems = PaymentRequestBody(stamp: UUID().uuidString,
42+
reference: "3759170",
43+
amount: 3050,
44+
currency: .eur,
45+
language: .fi,
46+
customer: Customer(email: "test.customer@example.com"),
47+
redirectUrls: CallbackUrls(success: "google.com", cancel: "google.com"),
48+
callbackUrls: nil)
49+
4050
payloadSIS = PaymentRequestBody(stamp: UUID().uuidString,
4151
reference: "3759170",
4252
amount: 3050,
@@ -87,6 +97,17 @@ final class CreatePaymentApiTestSuite: XCTestCase {
8797
}
8898
}
8999

100+
/// Test Success 200 - Payment create success with normal merchant credentials without items
101+
func testCreateNoItemsPaymentSuccess() async {
102+
let result = await createPaymentsAsync(merchant.merchantId, secret: merchant.secret, payload: payloadNoItems)
103+
switch result {
104+
case .success(let success):
105+
XCTAssert(success.transactionId != nil && success.providers != nil)
106+
case .failure(let failure):
107+
XCTFail("Create payment failed: \(failure.localizedDescription)")
108+
}
109+
}
110+
90111
/// Test Success 200 - Payment create with Shop-in-Shops merchant credentials
91112
func testCreatePaymentSisSuccess() async {
92113
let result = await createPaymentsAsync("695861", secret: "MONISAIPPUAKAUPPIAS", payload: payloadSIS)

0 commit comments

Comments
 (0)