Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Examples/moltin iOS Example/CartViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CartViewController: UIViewController {
let paymentMethod = ManuallyAuthorizePayment()
self.moltin.cart.pay(forOrderID: order.id, withPaymentMethod: paymentMethod) { (result) in
switch result {
case .success:
case .success(let _):
DispatchQueue.main.async {
self.showOrderStatus(withSuccess: true)
}
Expand All @@ -74,6 +74,7 @@ class CartViewController: UIViewController {
let title = success ? "Order paid!" : "Order error"
let message = success ? "Complete!" : error?.localizedDescription
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Close", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SDK/Models/Order.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ open class Order: Codable {
}

/// Denotes a successful order returned from the payment gateway
open class OrderSuccess: Codable {
open class OrderSuccess: Transaction {

}
39 changes: 39 additions & 0 deletions Sources/SDK/Models/Transaction.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Transaction.swift
// moltin iOS
//
// Created by Craig Tweedy on 01/02/2019.
//

import Foundation

/// Represents a `Transaction` in Moltin
open class Transaction: Codable {
/// This id of this order
public let id: String
/// The type of this object
public let type: String
/// The payment gateway reference
public let reference: String
/// The name of the payment gateway used
public let gateway: String
/// The amount for this transaction
public let amount: Int
/// The transaction currency
public let currency: String
/// The type of transaction (purchase, capture, authorize or refund)
public let transactionType: String
/// The status provided by the gateway for this transaction (complete or failed)
public let status: String

enum CodingKeys: String, CodingKey {
case id
case type
case reference
case gateway
case amount
case currency
case transactionType = "transaction-type"
case status
}
}
8 changes: 8 additions & 0 deletions moltin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
C3434C22203DDB1F00883C84 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3434C21203DDB1F00883C84 /* Config.swift */; };
C3434C23203DDB1F00883C84 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3434C21203DDB1F00883C84 /* Config.swift */; };
C3434C24203DDB1F00883C84 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3434C21203DDB1F00883C84 /* Config.swift */; };
C34D626E22047AF8009C7248 /* Transaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = C34D626D22047AF8009C7248 /* Transaction.swift */; };
C354B545206CE1EE00D26446 /* CategoryCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C336E605206C1DFD008C2005 /* CategoryCollectionViewCell.xib */; };
C354B54A206CE3FC00D26446 /* MasterSectionHeaderCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C354B546206CE37900D26446 /* MasterSectionHeaderCollectionReusableView.swift */; };
C354B54B206CE40200D26446 /* MasterSectionHeaderCollectionReusableView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C354B547206CE37900D26446 /* MasterSectionHeaderCollectionReusableView.xib */; };
Expand Down Expand Up @@ -152,6 +153,8 @@
C392EA52203DB823006CD1D0 /* moltin WatchKit Example.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = C392EA37203DB822006CD1D0 /* moltin WatchKit Example.app */; };
C392EA61203DB836006CD1D0 /* moltin_tvOS_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C392EA60203DB836006CD1D0 /* moltin_tvOS_Tests.swift */; };
C392EA63203DB836006CD1D0 /* moltin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C392E9DF203DB64E006CD1D0 /* moltin.framework */; };
C39C35FC22047FFF0044173C /* Transaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = C34D626D22047AF8009C7248 /* Transaction.swift */; };
C39C35FD220480000044173C /* Transaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = C34D626D22047AF8009C7248 /* Transaction.swift */; };
C3E739DA209113610070C361 /* CustomerRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3E739D9209113610070C361 /* CustomerRequest.swift */; };
C3F492B520B45C560081C5EC /* CategoriesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F492B420B45C560081C5EC /* CategoriesViewController.swift */; };
C3F492B720B611D10081C5EC /* ProductsCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F492B620B611D10081C5EC /* ProductsCollectionViewController.swift */; };
Expand Down Expand Up @@ -263,6 +266,7 @@
C3434C17203DDAD500883C84 /* Pagination.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Pagination.swift; sourceTree = "<group>"; };
C3434C1C203DDAFF00883C84 /* Error.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Error.swift; sourceTree = "<group>"; };
C3434C21203DDB1F00883C84 /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = "<group>"; };
C34D626D22047AF8009C7248 /* Transaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Transaction.swift; sourceTree = "<group>"; };
C354B546206CE37900D26446 /* MasterSectionHeaderCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterSectionHeaderCollectionReusableView.swift; sourceTree = "<group>"; };
C354B547206CE37900D26446 /* MasterSectionHeaderCollectionReusableView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MasterSectionHeaderCollectionReusableView.xib; sourceTree = "<group>"; };
C354B552206CEE9500D26446 /* ProductCategory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductCategory.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -538,6 +542,7 @@
C336E55F20614A9C008C2005 /* Prices.swift */,
C336E5CE2064057B008C2005 /* Relationship.swift */,
C354B576207389A500D26446 /* PaymentMethod.swift */,
C34D626D22047AF8009C7248 /* Transaction.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -1065,6 +1070,7 @@
C3715BFE203F59CA00287C1B /* File.swift in Sources */,
C3715C00203F59D000287C1B /* Flow.swift in Sources */,
C3434C18203DDAD500883C84 /* Pagination.swift in Sources */,
C34D626E22047AF8009C7248 /* Transaction.swift in Sources */,
C3FF2701206124D700CA226D /* DateFormatter.swift in Sources */,
C3715BF8203F544B00287C1B /* HTTPMock.swift in Sources */,
C336E565206155B2008C2005 /* FlowRequest.swift in Sources */,
Expand Down Expand Up @@ -1105,6 +1111,7 @@
C3F610E021F8A93200F42212 /* CustomerRequest.swift in Sources */,
C336E5A82062762D008C2005 /* DateFormatter.swift in Sources */,
C3715BF7203F544B00287C1B /* HTTPMock.swift in Sources */,
C39C35FC22047FFF0044173C /* Transaction.swift in Sources */,
C336E5B420627633008C2005 /* Address.swift in Sources */,
C336E5B320627633008C2005 /* Cart.swift in Sources */,
C336E5D22064062D008C2005 /* Relationship.swift in Sources */,
Expand Down Expand Up @@ -1145,6 +1152,7 @@
C3F610E121F8A93200F42212 /* CustomerRequest.swift in Sources */,
C336E5A52062762D008C2005 /* DateFormatter.swift in Sources */,
C3434C13203DDA1F00883C84 /* MoltinRequest.swift in Sources */,
C39C35FD220480000044173C /* Transaction.swift in Sources */,
C336E5AF20627632008C2005 /* Address.swift in Sources */,
C336E5AE20627632008C2005 /* Cart.swift in Sources */,
C336E5D12064062D008C2005 /* Relationship.swift in Sources */,
Expand Down