diff --git a/Sources/JuspayKit/Orders/OrderRoutes.swift b/Sources/JuspayKit/Orders/OrderRoutes.swift index 3b1efaf..a899ad1 100644 --- a/Sources/JuspayKit/Orders/OrderRoutes.swift +++ b/Sources/JuspayKit/Orders/OrderRoutes.swift @@ -13,7 +13,7 @@ public protocol OrderRoutes: JuspayAPIRoute { /// - Returns: An `Order` object representing the retrieved order. /// /// - Throws: An error if the order retrieval fails or if there's a network issue. - func retrieve(orderId: String) async throws -> Order + func retrieve(orderId: String, customerId: String) async throws -> Order /// Creates a new order in the Juspay system. /// @@ -50,13 +50,9 @@ public struct JuspayOrderRoutes: OrderRoutes { /// - Returns: An `Order` object representing the retrieved order. /// /// - Throws: An error if the order retrieval fails or if there's a network issue. - public func retrieve(orderId: String) async throws -> Order { + public func retrieve(orderId: String, customerId: String) async throws -> Order { var _headers = headers - let currentDate = Date() - let dateFormatter = DateFormatter() - dateFormatter.dateFormat = "yyyy-MM-dd" - let formattedDate = dateFormatter.string(from: currentDate) - _headers.add(name: "version", value: formattedDate) + _headers.add(name: "x-routing-id", value: customerId) return try await apiHandler.send(method: .GET, path: "orders/\(orderId)", headers: _headers) } diff --git a/Tests/JuspayKitTests/JuspayKitTests.swift b/Tests/JuspayKitTests/JuspayKitTests.swift index c980af6..e3d652d 100644 --- a/Tests/JuspayKitTests/JuspayKitTests.swift +++ b/Tests/JuspayKitTests/JuspayKitTests.swift @@ -48,9 +48,15 @@ struct JuspayKitTests { #expect(session != nil) } + @Test("List all payment methods") + func listPaymentMethods() async throws { + let paymentMethods = try await juspayClient.paymentMethods.list() + #expect(paymentMethods != nil) + } + @Test("Retrieve an order") func retrieveOrder() async throws { - let order = try await juspayClient.orders.retrieve(orderId: "OiVWluhiNXAQtR10BQaK") + let order = try await juspayClient.orders.retrieve(orderId: "OBug0anmAxDG2ncPhBsA", customerId: "4C2AD8F11484CE") #expect(order != nil) }