@@ -14,6 +14,10 @@ protocol DojoSDKProtocol {
1414 debugConfig: DojoSDKDebugConfig ? ,
1515 fromViewController: UIViewController ,
1616 completion: ( ( Int ) -> Void ) ? )
17+ static func executeVirtualTerminalPayment( token: String ,
18+ payload: DojoCardPaymentPayload ,
19+ debugConfig: DojoSDKDebugConfig ? ,
20+ completion: ( ( Int ) -> Void ) ? )
1721 static func executeSavedCardPayment( token: String ,
1822 payload: DojoSavedCardPaymentPayload ,
1923 debugConfig: DojoSDKDebugConfig ? ,
@@ -73,6 +77,22 @@ protocol DojoSDKProtocol {
7377 completion: completion)
7478 }
7579
80+ /// Execute virtual terminal payment
81+ /// - Parameters:
82+ /// - token: Payment secret obtained from a paymentIIntent object.
83+ /// - payload: Payment configuration and data.
84+ /// - debugConfig: optional debug config
85+ /// - completion: Result of the payment.
86+ @objc public static func executeVirtualTerminalPayment( token: String ,
87+ payload: DojoCardPaymentPayload ,
88+ debugConfig: DojoSDKDebugConfig ? ,
89+ completion: ( ( Int ) -> Void ) ? ) {
90+ internalExecuteVirtualTerminalPayment ( token: token,
91+ payload: payload,
92+ debugConfig: debugConfig,
93+ completion: completion)
94+ }
95+
7696 /// Execute ApplePay payment
7797 /// - Parameters:
7898 /// - paymentIntent: Payment intent [reference](https://docs.dojo.tech/api#tag/Payment-intents)
@@ -196,4 +216,21 @@ private extension DojoSDK {
196216 }
197217 }
198218 }
219+
220+ private static func internalExecuteVirtualTerminalPayment( token: String ,
221+ payload: DojoCardPaymentPayloadProtocol ,
222+ debugConfig: DojoSDKDebugConfig ? = nil ,
223+ completion: ( ( Int ) -> Void ) ? ) {
224+ let networkService = NetworkService ( timeout: 25 )
225+ networkService. performCardPayment ( token: token, payload: payload, debugConfig: debugConfig) { cardPaymentResult in
226+ switch cardPaymentResult {
227+ case . threeDSRequired( _, _) :
228+ sendCompletionOnMainThread ( result: DojoSDKResponseCode . sdkInternalError. rawValue, completion: completion)
229+ case . result( let resultCode) :
230+ sendCompletionOnMainThread ( result: resultCode, completion: completion)
231+ default :
232+ sendCompletionOnMainThread ( result: DojoSDKResponseCode . sdkInternalError. rawValue, completion: completion)
233+ }
234+ }
235+ }
199236}
0 commit comments