@@ -20,6 +20,12 @@ protocol CanTokenize {
20
20
// @param onBehalfOf (Optional) Business id for xenPlaform use cases
21
21
// @param completion callback function when tokenization is completed
22
22
static func createToken( fromViewController: UIViewController , retokenizationRequest: XenditRetokenizationRequest , onBehalfOf: String ? , completion: @escaping ( XenditCCToken ? , XenditError ? ) -> Void )
23
+
24
+ // Store CVN method
25
+ // @param storeCVNRequest: Token ID and billing details
26
+ // @param onBehalfOf (Optional) Business id for xenPlaform use cases
27
+ // @param completion callback function when tokenization is completed
28
+ static func storeCVN( fromViewController: UIViewController , storeCVNRequest: XenditStoreCVNRequest , onBehalfOf: String ? , completion: @escaping ( XenditCCToken ? , XenditError ? ) -> Void )
23
29
}
24
30
25
31
protocol CanAuthenticate {
@@ -70,6 +76,7 @@ public class XDTCards: CanTokenize, CanAuthenticate {
70
76
}
71
77
}
72
78
79
+ @available ( * , deprecated, message: " Use storeCVN(UIViewController, XenditStoreCVNRequest, String, Callback) instead " )
73
80
public static func createToken( fromViewController: UIViewController , retokenizationRequest: XenditRetokenizationRequest , onBehalfOf: String ? , completion: @escaping ( XenditCCToken ? , XenditError ? ) -> Void ) {
74
81
let logPrefix = " createToken: "
75
82
@@ -91,6 +98,27 @@ public class XDTCards: CanTokenize, CanAuthenticate {
91
98
}
92
99
}
93
100
101
+ public static func storeCVN( fromViewController: UIViewController , storeCVNRequest: XenditStoreCVNRequest , onBehalfOf: String ? , completion: @escaping ( XenditCCToken ? , XenditError ? ) -> Void ) {
102
+ let logPrefix = " storeCVN: "
103
+
104
+ if let error = validateRetokenizationRequest ( retokenizationRequest: storeCVNRequest) {
105
+ Log . shared. verbose ( " \( logPrefix) \( error) " )
106
+ completion ( nil , error)
107
+ }
108
+
109
+ var extraHeaders : [ String : String ] = [ : ]
110
+ if onBehalfOf != " " {
111
+ extraHeaders [ " for-user-id " ] = onBehalfOf
112
+ }
113
+
114
+ let requestBody = storeCVNRequest. toJsonObject ( )
115
+
116
+ XDTApiClient . createTokenRequest ( publishableKey: publishableKey!, bodyJson: requestBody, extraHeader: extraHeaders) { ( authenticatedToken, error) in
117
+
118
+ handleCreditCardTokenization ( fromViewController: fromViewController, authenticatedToken: authenticatedToken, amount: 0 , currency: nil , onBehalfOf: onBehalfOf, cardCvn: storeCVNRequest. cardCvn, error: error, completion: completion)
119
+ }
120
+ }
121
+
94
122
public static func createAuthentication( fromViewController: UIViewController , tokenId: String , amount: NSNumber , onBehalfOf: String ? , customer: XenditCustomer ? , completion: @escaping ( XenditAuthentication ? , XenditError ? ) -> Void ) {
95
123
96
124
createAuthentication ( fromViewController: fromViewController, tokenId: tokenId, amount: amount, currency: nil , onBehalfOf: onBehalfOf, customer: customer, completion: completion) ;
0 commit comments