@@ -992,23 +992,21 @@ impl api::IncomingWebhook for Payme {
992
992
let id = match resource. notify_type {
993
993
transformers:: NotifyType :: SaleComplete
994
994
| transformers:: NotifyType :: SaleAuthorized
995
- | transformers:: NotifyType :: SaleFailure => {
996
- Ok ( api:: webhooks:: ObjectReferenceId :: PaymentId (
995
+ | transformers:: NotifyType :: SaleFailure
996
+ | transformers:: NotifyType :: SaleChargeback
997
+ | transformers:: NotifyType :: SaleChargebackRefund => {
998
+ api:: webhooks:: ObjectReferenceId :: PaymentId (
997
999
api_models:: payments:: PaymentIdType :: ConnectorTransactionId (
998
1000
resource. payme_sale_id ,
999
1001
) ,
1000
- ) )
1002
+ )
1001
1003
}
1002
- transformers:: NotifyType :: Refund => Ok ( api:: webhooks:: ObjectReferenceId :: RefundId (
1004
+ transformers:: NotifyType :: Refund => api:: webhooks:: ObjectReferenceId :: RefundId (
1003
1005
api_models:: webhooks:: RefundIdType :: ConnectorRefundId (
1004
1006
resource. payme_transaction_id ,
1005
1007
) ,
1006
- ) ) ,
1007
- transformers:: NotifyType :: SaleChargeback
1008
- | transformers:: NotifyType :: SaleChargebackRefund => {
1009
- Err ( errors:: ConnectorError :: WebhookEventTypeNotFound )
1010
- }
1011
- } ?;
1008
+ ) ,
1009
+ } ;
1012
1010
Ok ( id)
1013
1011
}
1014
1012
@@ -1046,11 +1044,34 @@ impl api::IncomingWebhook for Payme {
1046
1044
. change_context ( errors:: ConnectorError :: WebhookBodyDecodingFailed )
1047
1045
}
1048
1046
transformers:: NotifyType :: SaleChargeback
1049
- | transformers:: NotifyType :: SaleChargebackRefund => {
1050
- Err ( errors :: ConnectorError :: WebhookEventTypeNotFound ) . into_report ( )
1051
- }
1047
+ | transformers:: NotifyType :: SaleChargebackRefund => serde_json :: to_value ( resource )
1048
+ . into_report ( )
1049
+ . change_context ( errors :: ConnectorError :: WebhookBodyDecodingFailed ) ,
1052
1050
} ?;
1053
1051
1054
1052
Ok ( res_json)
1055
1053
}
1054
+
1055
+ fn get_dispute_details (
1056
+ & self ,
1057
+ request : & api:: IncomingWebhookRequestDetails < ' _ > ,
1058
+ ) -> CustomResult < api:: disputes:: DisputePayload , errors:: ConnectorError > {
1059
+ let webhook_object =
1060
+ serde_urlencoded:: from_bytes :: < payme:: WebhookEventDataResource > ( request. body )
1061
+ . into_report ( )
1062
+ . change_context ( errors:: ConnectorError :: WebhookBodyDecodingFailed ) ?;
1063
+
1064
+ Ok ( api:: disputes:: DisputePayload {
1065
+ amount : webhook_object. price . to_string ( ) ,
1066
+ currency : webhook_object. currency . to_string ( ) ,
1067
+ dispute_stage : api_models:: enums:: DisputeStage :: Dispute ,
1068
+ connector_dispute_id : webhook_object. payme_transaction_id ,
1069
+ connector_reason : None ,
1070
+ connector_reason_code : None ,
1071
+ challenge_required_by : None ,
1072
+ connector_status : webhook_object. sale_status . to_string ( ) ,
1073
+ created_at : None ,
1074
+ updated_at : None ,
1075
+ } )
1076
+ }
1056
1077
}
0 commit comments