Skip to content

Commit

Permalink
fix(webhooks): send stripe compatible webhooks for stripe compatible …
Browse files Browse the repository at this point in the history
…merchants (#1986)
  • Loading branch information
Abhicodes-crypto authored Aug 23, 2023
1 parent 6986772 commit 36631ad
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 57 deletions.
9 changes: 8 additions & 1 deletion crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct MerchantAccountCreate {

/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]
pub metadata: Option<pii::SecretSerdeValue>,
pub metadata: Option<MerchantAccountMetadata>,

/// API key that will be used for server side API access
#[schema(example = "AH3423bkjbkjdsfbkj")]
Expand All @@ -96,6 +96,13 @@ pub struct MerchantAccountCreate {
pub organization_id: Option<String>,
}

#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]
pub struct MerchantAccountMetadata {
pub compatible_connector: Option<api_enums::Connector>,

#[serde(flatten)]
pub data: Option<pii::SecretSerdeValue>,
}
#[derive(Clone, Debug, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct MerchantAccountUpdate {
Expand Down
20 changes: 10 additions & 10 deletions crates/router/src/compatibility/stripe/customers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub async fn customer_create(

let flow = Flow::CustomersCreate;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -48,7 +48,7 @@ pub async fn customer_create(
customers::create_customer(&*state.store, auth.merchant_account, auth.key_store, req)
},
&auth::ApiKeyAuth,
)
))
.await
}

Expand All @@ -64,7 +64,7 @@ pub async fn customer_retrieve(

let flow = Flow::CustomersRetrieve;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -82,7 +82,7 @@ pub async fn customer_retrieve(
customers::retrieve_customer(&*state.store, auth.merchant_account, auth.key_store, req)
},
&auth::ApiKeyAuth,
)
))
.await
}

Expand All @@ -107,7 +107,7 @@ pub async fn customer_update(

let flow = Flow::CustomersUpdate;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -125,7 +125,7 @@ pub async fn customer_update(
customers::update_customer(&*state.store, auth.merchant_account, req, auth.key_store)
},
&auth::ApiKeyAuth,
)
))
.await
}

Expand All @@ -141,7 +141,7 @@ pub async fn customer_delete(

let flow = Flow::CustomersDelete;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -159,7 +159,7 @@ pub async fn customer_delete(
customers::delete_customer(state, auth.merchant_account, req, auth.key_store)
},
&auth::ApiKeyAuth,
)
))
.await
}

Expand All @@ -174,7 +174,7 @@ pub async fn list_customer_payment_method_api(
let customer_id = path.into_inner();
let flow = Flow::CustomerPaymentMethodsList;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -198,6 +198,6 @@ pub async fn list_customer_payment_method_api(
)
},
&auth::ApiKeyAuth,
)
))
.await
}
32 changes: 16 additions & 16 deletions crates/router/src/compatibility/stripe/payment_intents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub async fn payment_intents_create(

let flow = Flow::PaymentsCreate;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -61,7 +61,7 @@ pub async fn payment_intents_create(
)
},
&auth::ApiKeyAuth,
)
))
.await
}

Expand Down Expand Up @@ -91,7 +91,7 @@ pub async fn payment_intents_retrieve(

let flow = Flow::PaymentsRetrieve;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -117,7 +117,7 @@ pub async fn payment_intents_retrieve(
)
},
&*auth_type,
)
))
.await
}

Expand Down Expand Up @@ -152,7 +152,7 @@ pub async fn payment_intents_retrieve_with_gateway_creds(

let flow = Flow::PaymentsRetrieve;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -178,7 +178,7 @@ pub async fn payment_intents_retrieve_with_gateway_creds(
)
},
&*auth_type,
)
))
.await
}

Expand Down Expand Up @@ -214,7 +214,7 @@ pub async fn payment_intents_update(

let flow = Flow::PaymentsUpdate;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -240,7 +240,7 @@ pub async fn payment_intents_update(
)
},
&*auth_type,
)
))
.await
}

Expand Down Expand Up @@ -278,7 +278,7 @@ pub async fn payment_intents_confirm(

let flow = Flow::PaymentsConfirm;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -304,7 +304,7 @@ pub async fn payment_intents_confirm(
)
},
&*auth_type,
)
))
.await
}

Expand Down Expand Up @@ -332,7 +332,7 @@ pub async fn payment_intents_capture(

let flow = Flow::PaymentsCapture;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -358,7 +358,7 @@ pub async fn payment_intents_capture(
)
},
&auth::ApiKeyAuth,
)
))
.await
}

Expand Down Expand Up @@ -390,7 +390,7 @@ pub async fn payment_intents_cancel(

let flow = Flow::PaymentsCancel;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -416,7 +416,7 @@ pub async fn payment_intents_cancel(
)
},
&*auth_type,
)
))
.await
}

Expand All @@ -434,7 +434,7 @@ pub async fn payment_intent_list(

let flow = Flow::PaymentsList;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -450,6 +450,6 @@ pub async fn payment_intent_list(
payload,
|state, auth, req| payments::list_payments(&*state.store, auth.merchant_account, req),
&auth::ApiKeyAuth,
)
))
.await
}
16 changes: 8 additions & 8 deletions crates/router/src/compatibility/stripe/refunds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub async fn refund_create(

let flow = Flow::RefundsCreate;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -49,7 +49,7 @@ pub async fn refund_create(
refunds::refund_create_core(state, auth.merchant_account, auth.key_store, req)
},
&auth::ApiKeyAuth,
)
))
.await
}

Expand All @@ -70,7 +70,7 @@ pub async fn refund_retrieve_with_gateway_creds(

let flow = Flow::RefundsRetrieve;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -94,7 +94,7 @@ pub async fn refund_retrieve_with_gateway_creds(
)
},
&auth::ApiKeyAuth,
)
))
.await
}

Expand All @@ -112,7 +112,7 @@ pub async fn refund_retrieve(

let flow = Flow::RefundsRetrieve;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -136,7 +136,7 @@ pub async fn refund_retrieve(
)
},
&auth::ApiKeyAuth,
)
))
.await
}

Expand All @@ -152,7 +152,7 @@ pub async fn refund_update(
let create_refund_update_req: refund_types::RefundUpdateRequest = payload.into();
let flow = Flow::RefundsUpdate;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -170,6 +170,6 @@ pub async fn refund_update(
refunds::refund_update_core(&*state.store, auth.merchant_account, &refund_id, req)
},
&auth::ApiKeyAuth,
)
))
.await
}
16 changes: 8 additions & 8 deletions crates/router/src/compatibility/stripe/setup_intents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub async fn setup_intents_create(

let flow = Flow::PaymentsCreate;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -65,7 +65,7 @@ pub async fn setup_intents_create(
)
},
&auth::ApiKeyAuth,
)
))
.await
}

Expand Down Expand Up @@ -95,7 +95,7 @@ pub async fn setup_intents_retrieve(

let flow = Flow::PaymentsRetrieve;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -121,7 +121,7 @@ pub async fn setup_intents_retrieve(
)
},
&*auth_type,
)
))
.await
}

Expand Down Expand Up @@ -158,7 +158,7 @@ pub async fn setup_intents_update(

let flow = Flow::PaymentsUpdate;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -184,7 +184,7 @@ pub async fn setup_intents_update(
)
},
&*auth_type,
)
))
.await
}

Expand Down Expand Up @@ -222,7 +222,7 @@ pub async fn setup_intents_confirm(

let flow = Flow::PaymentsConfirm;

wrap::compatibility_api_wrap::<
Box::pin(wrap::compatibility_api_wrap::<
_,
_,
_,
Expand All @@ -248,6 +248,6 @@ pub async fn setup_intents_confirm(
)
},
&*auth_type,
)
))
.await
}
Loading

0 comments on commit 36631ad

Please sign in to comment.