FEAT(klarna): Klarna Kustom Checkout Integration (#6839)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
sweta-kumari-sharma
2024-12-19 13:11:44 +05:30
committed by GitHub
parent 839e69df24
commit c525c9f4c9
29 changed files with 594 additions and 266 deletions

View File

@ -741,6 +741,10 @@ pub struct PaymentsRequest {
// Makes the field mandatory in PaymentsCreateRequest
pub amount: Option<Amount>,
/// Total tax amount applicable to the order
#[schema(value_type = Option<i64>, example = 6540)]
pub order_tax_amount: Option<MinorUnit>,
/// The three letter ISO currency code in uppercase. Eg: 'USD' to charge US Dollars
#[schema(example = "USD", value_type = Option<Currency>)]
#[mandatory_in(PaymentsCreateRequest = Currency)]
@ -1308,6 +1312,9 @@ pub struct PaymentAttemptResponse {
/// The payment attempt amount. Amount for the payment in lowest denomination of the currency. (i.e) in cents for USD denomination, in paisa for INR denomination etc.,
#[schema(value_type = i64, example = 6540)]
pub amount: MinorUnit,
/// The payment attempt tax_amount.
#[schema(value_type = Option<i64>, example = 6540)]
pub order_tax_amount: Option<MinorUnit>,
/// The currency of the amount of the payment attempt
#[schema(value_type = Option<Currency>, example = "USD")]
pub currency: Option<enums::Currency>,
@ -1858,6 +1865,7 @@ pub enum PayLaterData {
/// The token for the sdk workflow
token: String,
},
KlarnaCheckout {},
/// For Affirm redirect as PayLater Option
AffirmRedirect {},
/// For AfterpayClearpay redirect as PayLater Option
@ -1915,6 +1923,7 @@ impl GetAddressFromPaymentMethodData for PayLaterData {
| Self::WalleyRedirect {}
| Self::AlmaRedirect {}
| Self::KlarnaSdk { .. }
| Self::KlarnaCheckout {}
| Self::AffirmRedirect {}
| Self::AtomeRedirect {} => None,
}
@ -2376,6 +2385,7 @@ impl GetPaymentMethodType for PayLaterData {
match self {
Self::KlarnaRedirect { .. } => api_enums::PaymentMethodType::Klarna,
Self::KlarnaSdk { .. } => api_enums::PaymentMethodType::Klarna,
Self::KlarnaCheckout {} => api_enums::PaymentMethodType::Klarna,
Self::AffirmRedirect {} => api_enums::PaymentMethodType::Affirm,
Self::AfterpayClearpayRedirect { .. } => api_enums::PaymentMethodType::AfterpayClearpay,
Self::PayBrightRedirect {} => api_enums::PaymentMethodType::PayBright,
@ -5471,7 +5481,7 @@ pub struct PaymentsRetrieveRequest {
pub expand_attempts: Option<bool>,
}
#[derive(Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
#[derive(Debug, Default, PartialEq, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
pub struct OrderDetailsWithAmount {
/// Name of the product that is being purchased
#[schema(max_length = 255, example = "shirt")]
@ -5480,7 +5490,13 @@ pub struct OrderDetailsWithAmount {
#[schema(example = 1)]
pub quantity: u16,
/// the amount per quantity of product
#[schema(value_type = i64)]
pub amount: MinorUnit,
/// tax rate applicable to the product
pub tax_rate: Option<f64>,
/// total tax amount applicable to the product
#[schema(value_type = Option<i64>)]
pub total_tax_amount: Option<MinorUnit>,
// Does the order includes shipping
pub requires_shipping: Option<bool>,
/// The image URL of the product
@ -5501,32 +5517,6 @@ pub struct OrderDetailsWithAmount {
impl masking::SerializableSecret for OrderDetailsWithAmount {}
#[derive(Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
pub struct OrderDetails {
/// Name of the product that is being purchased
#[schema(max_length = 255, example = "shirt")]
pub product_name: String,
/// The quantity of the product to be purchased
#[schema(example = 1)]
pub quantity: u16,
// Does the order include shipping
pub requires_shipping: Option<bool>,
/// The image URL of the product
pub product_img_link: Option<String>,
/// ID of the product that is being purchased
pub product_id: Option<String>,
/// Category of the product that is being purchased
pub category: Option<String>,
/// Sub category of the product that is being purchased
pub sub_category: Option<String>,
/// Brand of the product that is being purchased
pub brand: Option<String>,
/// Type of the product that is being purchased
pub product_type: Option<ProductType>,
/// The tax code for the product
pub product_tax_code: Option<String>,
}
#[derive(Default, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
pub struct RedirectResponse {
#[schema(value_type = Option<String>)]