was missing cancelation request
This commit is contained in:
parent
4131590b48
commit
205ead022e
2 changed files with 25 additions and 7 deletions
|
@ -5,7 +5,7 @@ use axum::{
|
||||||
http::{HeaderMap, StatusCode},
|
http::{HeaderMap, StatusCode},
|
||||||
};
|
};
|
||||||
use saleor_app_sdk::{AuthData, AuthToken};
|
use saleor_app_sdk::{AuthData, AuthToken};
|
||||||
use tracing::{debug, error, info};
|
use tracing::{debug, info};
|
||||||
|
|
||||||
use crate::app::{AppError, AppState};
|
use crate::app::{AppError, AppState};
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,11 @@ use saleor_app_sdk::{
|
||||||
headers::SALEOR_API_URL_HEADER,
|
headers::SALEOR_API_URL_HEADER,
|
||||||
webhooks::{
|
webhooks::{
|
||||||
sync_response::{
|
sync_response::{
|
||||||
ChargeRequestedResult, PaymentGatewayInitializeSessionResponse, RefundRequestedResult,
|
CancelationRequestedResult, ChargeRequestedResult,
|
||||||
TransactionChargeRequestedResponse, TransactionInitializeSessionResponse,
|
PaymentGatewayInitializeSessionResponse, RefundRequestedResult,
|
||||||
TransactionProcessSessionResponse, TransactionRefundRequestedResponse,
|
TransactionCancelationRequestedResponse, TransactionChargeRequestedResponse,
|
||||||
TransactionSessionResult,
|
TransactionInitializeSessionResponse, TransactionProcessSessionResponse,
|
||||||
|
TransactionRefundRequestedResponse, TransactionSessionResult,
|
||||||
},
|
},
|
||||||
utils::{get_webhook_event_type, EitherWebhookType},
|
utils::{get_webhook_event_type, EitherWebhookType},
|
||||||
SyncWebhookEventType,
|
SyncWebhookEventType,
|
||||||
|
@ -24,8 +25,9 @@ use crate::{
|
||||||
app::{ActiveGateway, AppError, AppState, GatewayType},
|
app::{ActiveGateway, AppError, AppState, GatewayType},
|
||||||
queries::{
|
queries::{
|
||||||
event_transactions::{
|
event_transactions::{
|
||||||
TransactionChargeRequested2, TransactionFlowStrategyEnum,
|
TransactionCancelationRequested, TransactionChargeRequested2,
|
||||||
TransactionInitializeSession2, TransactionProcessSession2, TransactionRefundRequested2,
|
TransactionFlowStrategyEnum, TransactionInitializeSession2, TransactionProcessSession2,
|
||||||
|
TransactionRefundRequested2,
|
||||||
},
|
},
|
||||||
mutation_transaction_update::{
|
mutation_transaction_update::{
|
||||||
TransactionUpdate, TransactionUpdateInput, TransactionUpdateVariables,
|
TransactionUpdate, TransactionUpdateInput, TransactionUpdateVariables,
|
||||||
|
@ -50,6 +52,22 @@ pub async fn webhooks(
|
||||||
let event_type = get_webhook_event_type(&headers)?;
|
let event_type = get_webhook_event_type(&headers)?;
|
||||||
let res: Json<Value> = match event_type {
|
let res: Json<Value> = match event_type {
|
||||||
EitherWebhookType::Sync(a) => match a {
|
EitherWebhookType::Sync(a) => match a {
|
||||||
|
SyncWebhookEventType::TransactionCancelationRequested => {
|
||||||
|
let data = serde_json::from_str::<TransactionChargeRequested2>(&body)?;
|
||||||
|
Json::from(serde_json::to_value(
|
||||||
|
TransactionCancelationRequestedResponse {
|
||||||
|
time: None,
|
||||||
|
psp_reference: "".to_owned(),
|
||||||
|
external_url: None,
|
||||||
|
message: None,
|
||||||
|
amount: data
|
||||||
|
.action
|
||||||
|
.amount
|
||||||
|
.and_then(|a| Decimal::from_str(&a.0).ok()),
|
||||||
|
result: Some(CancelationRequestedResult::CancelSuccess),
|
||||||
|
},
|
||||||
|
)?)
|
||||||
|
}
|
||||||
SyncWebhookEventType::PaymentGatewayInitializeSession => Json::from(
|
SyncWebhookEventType::PaymentGatewayInitializeSession => Json::from(
|
||||||
serde_json::to_value(PaymentGatewayInitializeSessionResponse::<u8> { data: None })?,
|
serde_json::to_value(PaymentGatewayInitializeSessionResponse::<u8> { data: None })?,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue