feat: delete customer data in compliance with GDPR regulations (#64)

This commit is contained in:
Manoj Ghorela
2022-12-13 19:39:32 +05:30
committed by GitHub
parent 3655c8de82
commit ae8869318b
12 changed files with 246 additions and 35 deletions

View File

@ -111,9 +111,7 @@ pub async fn customer_delete(
&state,
&req,
payload,
|state, merchant_account, req| {
customers::delete_customer(&*state.store, merchant_account, req)
},
customers::delete_customer,
api::MerchantAuthentication::ApiKey,
)
.await

View File

@ -104,7 +104,7 @@ impl From<api::CustomerDeleteResponse> for CustomerDeleteResponse {
fn from(cust: api::CustomerDeleteResponse) -> Self {
Self {
id: cust.customer_id,
deleted: cust.deleted,
deleted: cust.customer_deleted,
}
}
}

View File

@ -55,6 +55,12 @@ pub(crate) enum ErrorCode {
#[error(error_type = StripeErrorType::ApiError, code = "internal_server_error", message = "Server is down")]
DuplicateRefundRequest,
#[error(error_type = StripeErrorType::InvalidRequestError, code = "active_mandate", message = "Customer has active mandate")]
MandateActive,
#[error(error_type = StripeErrorType::InvalidRequestError, code = "customer_redacted", message = "Customer has redacted")]
CustomerRedacted,
#[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "No such refund")]
RefundNotFound,
@ -340,6 +346,8 @@ impl From<ApiErrorResponse> for ErrorCode {
ApiErrorResponse::RefundFailed { data } => ErrorCode::RefundFailed, // Nothing at stripe to map
ApiErrorResponse::InternalServerError => ErrorCode::InternalServerError, // not a stripe code
ApiErrorResponse::MandateActive => ErrorCode::MandateActive, //not a stripe code
ApiErrorResponse::CustomerRedacted => ErrorCode::CustomerRedacted, //not a stripe code
ApiErrorResponse::DuplicateRefundRequest => ErrorCode::DuplicateRefundRequest,
ApiErrorResponse::RefundNotFound => ErrorCode::RefundNotFound,
ApiErrorResponse::CustomerNotFound => ErrorCode::CustomerNotFound,
@ -433,9 +441,10 @@ impl actix_web::ResponseError for ErrorCode {
| ErrorCode::ResourceIdNotFound
| ErrorCode::PaymentIntentMandateInvalid { .. }
| ErrorCode::PaymentIntentUnexpectedState { .. } => StatusCode::BAD_REQUEST,
ErrorCode::RefundFailed | ErrorCode::InternalServerError => {
StatusCode::INTERNAL_SERVER_ERROR
}
ErrorCode::RefundFailed
| ErrorCode::InternalServerError
| ErrorCode::MandateActive
| ErrorCode::CustomerRedacted => StatusCode::INTERNAL_SERVER_ERROR,
ErrorCode::ReturnUrlUnavailable => StatusCode::SERVICE_UNAVAILABLE,
}
}