@@ -133,7 +133,8 @@ pub struct CardInformation {
133
133
pub card_number : CardNumber ,
134
134
pub expiry_month : Secret < String > ,
135
135
pub expiry_year : Secret < String > ,
136
- pub cvv : Secret < String > ,
136
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
137
+ pub cvv : Option < Secret < String > > ,
137
138
pub cardholder_name : Secret < String > ,
138
139
pub cardholder_email : pii:: Email ,
139
140
pub cardholder_phone_number : Secret < String > ,
@@ -201,6 +202,16 @@ fn map_payment_response_to_attempt_status(
201
202
}
202
203
}
203
204
205
+ #[ derive( Debug , Clone , Deserialize , Serialize ) ]
206
+ pub struct XenditCaptureResponse {
207
+ pub id : String ,
208
+ pub status : PaymentStatus ,
209
+ pub actions : Option < Vec < Action > > ,
210
+ pub payment_method : PaymentMethodInfo ,
211
+ pub failure_code : Option < String > ,
212
+ pub reference_id : Secret < String > ,
213
+ }
214
+
204
215
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
205
216
#[ serde( rename_all = "UPPERCASE" ) ]
206
217
pub enum MethodType {
@@ -242,7 +253,11 @@ impl TryFrom<XenditRouterData<&PaymentsAuthorizeRouterData>> for XenditPaymentsR
242
253
card_number : card_data. card_number . clone ( ) ,
243
254
expiry_month : card_data. card_exp_month . clone ( ) ,
244
255
expiry_year : card_data. get_expiry_year_4_digit ( ) ,
245
- cvv : card_data. card_cvc . clone ( ) ,
256
+ cvv : if card_data. card_cvc . clone ( ) . expose ( ) . is_empty ( ) {
257
+ None
258
+ } else {
259
+ Some ( card_data. card_cvc . clone ( ) )
260
+ } ,
246
261
cardholder_name : card_data
247
262
. get_cardholder_name ( )
248
263
. or ( item. router_data . get_billing_full_name ( ) ) ?,
@@ -410,20 +425,26 @@ impl<F>
410
425
}
411
426
412
427
impl < F >
413
- TryFrom < ResponseRouterData < F , XenditPaymentResponse , PaymentsCaptureData , PaymentsResponseData > >
428
+ TryFrom < ResponseRouterData < F , XenditCaptureResponse , PaymentsCaptureData , PaymentsResponseData > >
414
429
for RouterData < F , PaymentsCaptureData , PaymentsResponseData >
415
430
{
416
431
type Error = error_stack:: Report < errors:: ConnectorError > ;
417
432
418
433
fn try_from (
419
434
item : ResponseRouterData <
420
435
F ,
421
- XenditPaymentResponse ,
436
+ XenditCaptureResponse ,
422
437
PaymentsCaptureData ,
423
438
PaymentsResponseData ,
424
439
> ,
425
440
) -> Result < Self , Self :: Error > {
426
- let status = map_payment_response_to_attempt_status ( item. response . clone ( ) , true ) ;
441
+ let status = match item. response . status {
442
+ PaymentStatus :: Failed => enums:: AttemptStatus :: Failure ,
443
+ PaymentStatus :: Succeeded | PaymentStatus :: Verified => enums:: AttemptStatus :: Charged ,
444
+ PaymentStatus :: Pending => enums:: AttemptStatus :: Pending ,
445
+ PaymentStatus :: RequiresAction => enums:: AttemptStatus :: AuthenticationPending ,
446
+ PaymentStatus :: AwaitingCapture => enums:: AttemptStatus :: Authorized ,
447
+ } ;
427
448
let response = if status == enums:: AttemptStatus :: Failure {
428
449
Err ( ErrorResponse {
429
450
code : item
0 commit comments