feat(compatibility): add refund retrieve endpoint which accepts gateway creds (#958)

This commit is contained in:
shubhanshu-mani
2023-04-25 01:04:44 +05:30
committed by GitHub
parent 40898c0ac9
commit bcbf4c882c
3 changed files with 43 additions and 1 deletions

View File

@ -40,6 +40,7 @@ impl Refunds {
.service(refund_create)
.service(refund_retrieve)
.service(refund_update)
.service(refund_retrieve_with_gateway_creds)
}
}

View File

@ -49,6 +49,47 @@ pub async fn refund_create(
.await
}
#[instrument(skip_all)]
#[post("/sync")]
pub async fn refund_retrieve_with_gateway_creds(
state: web::Data<routes::AppState>,
qs_config: web::Data<serde_qs::Config>,
req: HttpRequest,
form_payload: web::Bytes,
) -> HttpResponse {
let refund_request = match qs_config
.deserialize_bytes(&form_payload)
.map_err(|err| report!(errors::StripeErrorCode::from(err)))
{
Ok(payload) => payload,
Err(err) => return api::log_and_return_error_response(err),
};
wrap::compatibility_api_wrap::<
_,
_,
_,
_,
_,
_,
types::StripeRefundResponse,
errors::StripeErrorCode,
>(
state.get_ref(),
&req,
refund_request,
|state, merchant_account, refund_request| {
refunds::refund_response_wrapper(
state,
merchant_account,
refund_request,
refunds::refund_retrieve_core,
)
},
&auth::ApiKeyAuth,
)
.await
}
#[instrument(skip_all)]
#[get("/{refund_id}")]
pub async fn refund_retrieve(