digitaluapi

<back to all web services

InitialisePaymentRequest

import Foundation
import ServiceStack

public class InitialisePaymentRequest : Codable
{
    public var paymentType:PaymentTypeEnum
    public var uuid:String
    public var referenceNumber:String
    public var amount:Double
    public var currency:String
    public var itemName:String
    public var itemDescription:String
    public var billingDate:Date
    public var frequency:FrequencyEnum
    public var cycles:Int

    required public init(){}
}

public enum PaymentTypeEnum : Int, Codable
{
    case OneTime = 1
    case Recurring = 2
}

public enum FrequencyEnum : Int, Codable
{
    case Daily = 1
    case Weekly = 2
    case Monthly = 3
    case Quarterly = 4
    case Biannually = 5
    case Annually = 6
}

public class InitialisePaymentResponse : ResponseBase
{
    public var transactionId:String
    public var signature:String
    public var url:String

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case transactionId
        case signature
        case url
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        transactionId = try container.decodeIfPresent(String.self, forKey: .transactionId)
        signature = try container.decodeIfPresent(String.self, forKey: .signature)
        url = try container.decodeIfPresent(String.self, forKey: .url)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if transactionId != nil { try container.encode(transactionId, forKey: .transactionId) }
        if signature != nil { try container.encode(signature, forKey: .signature) }
        if url != nil { try container.encode(url, forKey: .url) }
    }
}

public class ResponseBase : Codable
{
    public var status:Bool
    public var message:String
    public var errors:[String:[String]]

    required public init(){}
}


Swift InitialisePaymentRequest DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /jsv/reply/InitialisePaymentRequest HTTP/1.1 
Host: duengageapi.uat.scadsoftware.com 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	PaymentType: OneTime,
	Uuid: 00000000000000000000000000000000,
	ReferenceNumber: String,
	Amount: 0,
	Currency: String,
	ItemName: String,
	ItemDescription: String,
	BillingDate: 0001-01-01,
	Frequency: Daily,
	Cycles: 0
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	TransactionId: String,
	Signature: String,
	Url: String,
	Status: False,
	Message: String,
	Errors: 
	{
		String: 
		[
			String
		]
	}
}