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
2 changes: 1 addition & 1 deletion PayMayaExample/PayMayaExample/Shop/ShopViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ShopViewModel: NSObject {
let amountDetails = AmountDetails(discount: 0, serviceCharge: 0, shippingFee: 0, tax: 0, subtotal: totalValue)
let totalAmount = CheckoutTotalAmount(value: totalValue, currency: "PHP", details: amountDetails)
let redirectUrl = RedirectURL(success: "https://www.merchantsite.com/success", failure: "https://www.merchantsite.com/failure", cancel: "https://www.merchantsite.com/cancel")!
return CheckoutInfo(totalAmount: totalAmount, buyer: buyer, items: cart, redirectUrl: redirectUrl, requestReferenceNumber: "1551191039")
return CheckoutInfo(authorizationType:AuthorizationType.normal ,totalAmount: totalAmount, buyer: buyer, items: cart, redirectUrl: redirectUrl, requestReferenceNumber: "1551191039")
}
}

Expand Down
4 changes: 4 additions & 0 deletions PayMayaSDK/PayMayaSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
5944D0A22634827700595597 /* AuthorizationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5944D0A12634827700595597 /* AuthorizationType.swift */; };
BF05FA9623E4590400D43D24 /* RedirectResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF05FA9523E4590400D43D24 /* RedirectResponse.swift */; };
BF0F00762405158100EB920E /* UIDevice+IsSmall.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF0F00752405158100EB920E /* UIDevice+IsSmall.swift */; };
BF29AB5023DB472D00212ADE /* RedirectURLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF29AB4F23DB472D00212ADE /* RedirectURLTests.swift */; };
Expand Down Expand Up @@ -128,6 +129,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
5944D0A12634827700595597 /* AuthorizationType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthorizationType.swift; sourceTree = "<group>"; };
BF05FA9523E4590400D43D24 /* RedirectResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedirectResponse.swift; sourceTree = "<group>"; };
BF0F00752405158100EB920E /* UIDevice+IsSmall.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIDevice+IsSmall.swift"; sourceTree = "<group>"; };
BF1205F523DF0F530097693A /* Networking.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Networking.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -539,6 +541,7 @@
BFA9093D23D9F122001A277F /* CheckoutTotalAmount.swift */,
BFA9093A23D9F122001A277F /* Contact.swift */,
BFA9093823D9F122001A277F /* ShippingAddress.swift */,
5944D0A12634827700595597 /* AuthorizationType.swift */,
);
path = Checkout;
sourceTree = "<group>";
Expand Down Expand Up @@ -733,6 +736,7 @@
EBA442D223F2E70000E85DAB /* LabeledTextFieldViewModel.swift in Sources */,
BFD5DACF23E996A8004E504A /* Data+Error.swift in Sources */,
BFA9095523DAE877001A277F /* PMWebViewController.swift in Sources */,
5944D0A22634827700595597 /* AuthorizationType.swift in Sources */,
BFA9094123D9F122001A277F /* ShippingAddress.swift in Sources */,
BFB7656A23F2DBFB000D1AC0 /* Data+JSON.swift in Sources */,
BFB7656923F2DBFB000D1AC0 /* URLSession+Networking.swift in Sources */,
Expand Down
26 changes: 26 additions & 0 deletions PayMayaSDK/PayMayaSDK/Models/Checkout/AuthorizationType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright (c) 2021 PayMaya Philippines, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
// associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation
public enum AuthorizationType : String, Encodable{

case normal = "NORMAL"
case final = "FINAL"
case preauthorization = "PREAUTHORIZATION"
}
8 changes: 7 additions & 1 deletion PayMayaSDK/PayMayaSDK/Models/Checkout/CheckoutInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import Foundation
/// Contains information about the buyer, the items inside the cart, transaction amount, status of payment and other details.
public struct CheckoutInfo: Encodable {

/// Authorization Type for capturing payment status
public let authorizationType: AuthorizationType?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add field-level documentation


/// Transaction amount details.
public let totalAmount: CheckoutTotalAmount

Expand All @@ -42,18 +45,21 @@ public struct CheckoutInfo: Encodable {

/// Contains information about the buyer, the items inside the cart, transaction amount, status of payment and other details.
/// - Parameters:
/// - authorizationType: Authorization Type for capturing payment status
/// - totalAmount: Transaction amount details.
/// - buyer: Customer profile information.
/// - items: List of bought items for the transaction.
/// - redirectUrl: List of redirect URLs depending on checkout completion status.
/// - requestReferenceNumber: Your unique identifier to a transaction for tracking purposes. By default it will be auto-generated.
/// - metadata: Merchant provided additional cart information. Optional.
public init(totalAmount: CheckoutTotalAmount,
public init(authorizationType: AuthorizationType? = nil,
totalAmount: CheckoutTotalAmount,
buyer: CheckoutBuyer? = nil,
items: [CheckoutItem],
redirectUrl: RedirectURL,
requestReferenceNumber: String = UUID().uuidString,
metadata: [String: String] = [:]) {
self.authorizationType = authorizationType
self.totalAmount = totalAmount
self.buyer = buyer
self.items = items
Expand Down
3 changes: 2 additions & 1 deletion PayMayaSDK/PayMayaSDKTests/Mocks/CheckoutMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ import PayMayaSDK

extension CheckoutInfo {
static var mock: CheckoutInfo {
let authType = AuthorizationType.normal
let amountDetails = AmountDetails(discount: 0, serviceCharge: 0, shippingFee: 0, tax: 0, subtotal: 100)
let totalAmount = CheckoutTotalAmount(value: 100, currency: "PHP", details: amountDetails)
let contact = Contact(phone: "+639181008888", email: "[email protected]")
let shippingAddress = ShippingAddress(firstName: "John", middleName: "Paul", lastName: "Doe", phone: "+639181008888", email: "[email protected]", line1: "6F Launchpad", line2: "Reliance Street", city: "Mandaluyong City", state: "Metro Manila", zipCode: "1552", countryCode: "PH", shippingType: "ST")
let billingAddress = BillingAddress(line1: "6F Launchpad", line2: "Reliance Street", city: "Mandaluyong City", state: "Metro Manila", zipCode: "1552", countryCode: "PH")
let buyer = CheckoutBuyer(firstName: "John", middleName: "Paul", lastName: "Doe", birthday: "1995-10-24", customerSince: "1995-10-24", sex: "M", contact: contact, shippingAddress: shippingAddress, billingAddress: billingAddress)
let checkoutItem = CheckoutItem(name: "Canvas Slip Ons", quantity: 1, code: "CVG-096732", description: "Shoes", amount: .init(value: 100, details: .init(discount: 0, serviceCharge: 0, shippingFee: 0, tax: 0, subtotal: 100)), totalAmount: .init(value: 100, details: .init(discount: 0, serviceCharge: 0, shippingFee: 0, tax: 0, subtotal: 100)))
return CheckoutInfo(totalAmount: totalAmount, buyer: buyer, items: [checkoutItem], redirectUrl: RedirectURL(success: "https://www.merchantsite.com/success", failure: "https://www.merchantsite.com/failure", cancel: "https://www.merchantsite.com/cancel")!, requestReferenceNumber: "1551191039")
return CheckoutInfo(authorizationType:authType,totalAmount: totalAmount, buyer: buyer, items: [checkoutItem], redirectUrl: RedirectURL(success: "https://www.merchantsite.com/success", failure: "https://www.merchantsite.com/failure", cancel: "https://www.merchantsite.com/cancel")!, requestReferenceNumber: "1551191039")
}
}