Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): [Paypal] Add session_token flow for Paypal sdk #4697

Merged
merged 24 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ae37436
refactor: modify complete authorize
swangi-kumari May 17, 2024
0aa1fe3
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 17, 2024
6f7329b
Merge branch 'main' into complete-authorize
swangi-kumari May 18, 2024
b473b0d
refactor: clippy
swangi-kumari May 18, 2024
4719a94
feat: add session token from mca_metadata for paypal sdk
SamraatBansal May 19, 2024
f2a0fba
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 19, 2024
def51f6
chore: address clippy warnings
SamraatBansal May 19, 2024
b50bf14
chore: Merge branch 'paypal-sdk-session' of https://github.com/juspay…
SamraatBansal May 19, 2024
0dcb269
add next action in session call and shipping in dynamic fields
SamraatBansal May 21, 2024
a82fdcb
chore: Merge branch 'main' into paypal-sdk-session
SamraatBansal May 21, 2024
2297ebf
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 21, 2024
ce6843d
handle conflicts
SamraatBansal May 21, 2024
f8df606
Merge branch 'paypal-sdk-session' of https://github.com/juspay/hypers…
SamraatBansal May 21, 2024
1ff186a
add invoke_sdk_client as next_action in confirm response
SamraatBansal May 22, 2024
5f3b8d9
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 22, 2024
cb70f9a
chore: refactor paypal sdk flow
SamraatBansal May 23, 2024
29130de
Merge branch 'paypal-sdk-session' of https://github.com/juspay/hypers…
SamraatBansal May 23, 2024
b90ce54
handle connector meta based onpayment experience in psync
SamraatBansal May 23, 2024
75d9cfa
Merge branch 'main' into paypal-sdk-session
SamraatBansal May 26, 2024
214d5ce
chore: address cargo errors and refactor api contract
SamraatBansal May 26, 2024
1522985
chore: add open api spec
SamraatBansal May 26, 2024
f670bd0
add comments and logs
SamraatBansal May 27, 2024
a7b8b67
chore: handle open api spec
SamraatBansal May 27, 2024
f67f5ec
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2939,13 +2939,17 @@ pub enum NextActionType {
#[serde(tag = "type", rename_all = "snake_case")]
pub enum NextActionData {
/// Contains the url for redirection flow
RedirectToUrl { redirect_to_url: String },
RedirectToUrl {
redirect_to_url: String,
},
/// Informs the next steps for bank transfer and also contains the charges details (ex: amount received, amount charged etc)
DisplayBankTransferInformation {
bank_transfer_steps_and_charges_details: BankTransferNextStepsData,
},
/// Contains third party sdk session token response
ThirdPartySdkSessionToken { session_token: Option<SessionToken> },
ThirdPartySdkSessionToken {
session_token: Option<SessionToken>,
},
/// Contains url for Qr code image, this qr code has to be shown in sdk
QrCodeInformation {
#[schema(value_type = String)]
Expand All @@ -2967,7 +2971,12 @@ pub enum NextActionData {
display_to_timestamp: Option<i128>,
},
/// Contains the information regarding three_ds_method_data submission, three_ds authentication, and authorization flows
ThreeDsInvoke { three_ds_data: ThreeDsData },
ThreeDsInvoke {
three_ds_data: ThreeDsData,
},
InvokeSdkClient {
next_action_data: SdkNextActionData,
},
}

#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]
Expand Down Expand Up @@ -3030,6 +3039,12 @@ pub enum QrCodeInformation {
},
}

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub struct SdkNextActionData {
pub next_action: NextActionCall,
}

#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct BankTransferNextStepsData {
/// The instructions for performing a bank transfer
Expand Down Expand Up @@ -4030,6 +4045,17 @@ pub struct GpaySessionTokenData {
pub data: GpayMetaData,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PaypalSdkMetaData {
pub client_id: String,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PaypalSdkSessionTokenData {
#[serde(rename = "paypal_sdk")]
pub data: PaypalSdkMetaData,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApplepaySessionRequest {
Expand Down Expand Up @@ -4207,8 +4233,12 @@ pub struct KlarnaSessionTokenResponse {
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
#[serde(rename_all = "lowercase")]
pub struct PaypalSessionTokenResponse {
/// Name of the connector
pub connector: String,
/// The session token for PayPal
pub session_token: String,
/// The next action for the sdk (ex: calling confirm or sync call)
pub sdk_next_action: SdkNextAction,
}

#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
Expand Down Expand Up @@ -4238,13 +4268,15 @@ pub struct SdkNextAction {
pub next_action: NextActionCall,
}

#[derive(Debug, Eq, PartialEq, serde::Serialize, Clone, ToSchema)]
#[derive(Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum NextActionCall {
/// The next action call is confirm
Confirm,
/// The next action call is sync
Sync,
/// The next action call is Complete Authorize
CompleteAuthorize,
}

#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
Expand Down
8 changes: 8 additions & 0 deletions crates/connector_configs/src/common_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ pub enum GooglePayData {
Zen(ZenGooglePay),
}

#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PaypalSdkData {
pub client_id: Option<String>,
}

#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, serde::Serialize, Clone)]
#[serde(untagged)]
Expand All @@ -79,6 +85,7 @@ pub struct ApiModelMetaData {
pub terminal_id: Option<String>,
pub merchant_id: Option<String>,
pub google_pay: Option<GoogleApiModelData>,
pub paypal_sdk: Option<PaypalSdkData>,
pub apple_pay: Option<ApplePayData>,
pub apple_pay_combined: Option<ApplePayData>,
pub endpoint_prefix: Option<String>,
Expand Down Expand Up @@ -180,6 +187,7 @@ pub struct DashboardMetaData {
pub terminal_id: Option<String>,
pub merchant_id: Option<String>,
pub google_pay: Option<GooglePayData>,
pub paypal_sdk: Option<PaypalSdkData>,
pub apple_pay: Option<ApplePayData>,
pub apple_pay_combined: Option<ApplePayData>,
pub endpoint_prefix: Option<String>,
Expand Down
3 changes: 2 additions & 1 deletion crates/connector_configs/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::Deserialize;
#[cfg(any(feature = "sandbox", feature = "development", feature = "production"))]
use toml;

use crate::common_config::{CardProvider, GooglePayData, Provider, ZenApplePay};
use crate::common_config::{CardProvider, GooglePayData, PaypalSdkData, Provider, ZenApplePay};

#[derive(Default, Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Classic {
Expand Down Expand Up @@ -79,6 +79,7 @@ pub struct ConfigMetadata {
pub account_name: Option<String>,
pub terminal_id: Option<String>,
pub google_pay: Option<GooglePayData>,
pub paypal_sdk: Option<PaypalSdkData>,
pub apple_pay: Option<ApplePayTomlConfig>,
pub merchant_id: Option<String>,
pub endpoint_prefix: Option<String>,
Expand Down
1 change: 1 addition & 0 deletions crates/connector_configs/src/response_modifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ impl From<ApiModelMetaData> for DashboardMetaData {
terminal_id: api_model.terminal_id,
merchant_id: api_model.merchant_id,
google_pay: get_google_pay_metadata_response(api_model.google_pay),
paypal_sdk: api_model.paypal_sdk,
apple_pay: api_model.apple_pay,
apple_pay_combined: api_model.apple_pay_combined,
endpoint_prefix: api_model.endpoint_prefix,
Expand Down
7 changes: 6 additions & 1 deletion crates/connector_configs/src/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ impl DashboardRequestPayload {
(Connector::Zen, GooglePay) | (Connector::Zen, ApplePay) => {
Some(api_models::enums::PaymentExperience::RedirectToUrl)
}
(Connector::Braintree, Paypal) | (Connector::Klarna, Klarna) => {
(Connector::Paypal, Paypal)
| (Connector::Braintree, Paypal)
| (Connector::Klarna, Klarna) => {
Some(api_models::enums::PaymentExperience::InvokeSdkClient)
}
(Connector::Globepay, AliPay)
Expand Down Expand Up @@ -194,6 +196,7 @@ impl DashboardRequestPayload {
three_ds_requestor_name: None,
three_ds_requestor_id: None,
pull_mechanism_for_external_3ds_enabled: None,
paypal_sdk: None,
};
let meta_data = match request.metadata {
Some(data) => data,
Expand All @@ -205,6 +208,7 @@ impl DashboardRequestPayload {
let merchant_id = meta_data.merchant_id.clone();
let terminal_id = meta_data.terminal_id.clone();
let endpoint_prefix = meta_data.endpoint_prefix.clone();
let paypal_sdk = meta_data.paypal_sdk;
let apple_pay = meta_data.apple_pay;
let apple_pay_combined = meta_data.apple_pay_combined;
let merchant_config_currency = meta_data.merchant_config_currency;
Expand All @@ -228,6 +232,7 @@ impl DashboardRequestPayload {
merchant_config_currency,
apple_pay_combined,
endpoint_prefix,
paypal_sdk,
mcc,
merchant_country_code,
merchant_name,
Expand Down
2 changes: 2 additions & 0 deletions crates/connector_configs/toml/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,8 @@ api_key="Client Secret"
key1="Client ID"
[paypal.connector_webhook_details]
merchant_secret="Source verification key"
[paypal.metadata.paypal_sdk]
client_id="Client ID"

[paypal_payout]
[[paypal.wallet]]
Expand Down
2 changes: 2 additions & 0 deletions crates/connector_configs/toml/production.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,8 @@ api_key="Client Secret"
key1="Client ID"
[paypal.connector_webhook_details]
merchant_secret="Source verification key"
[paypal.metadata.paypal_sdk]
client_id="Client ID"

[payu]
[[payu.credit]]
Expand Down
2 changes: 2 additions & 0 deletions crates/connector_configs/toml/sandbox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,8 @@ api_key="Client Secret"
key1="Client ID"
[paypal.connector_webhook_details]
merchant_secret="Source verification key"
[paypal.metadata.paypal_sdk]
client_id="Client ID"

[paypal_payout]
[[paypal.wallet]]
Expand Down
1 change: 1 addition & 0 deletions crates/openapi/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::ApplepaySessionTokenResponse,
api_models::payments::SdkNextAction,
api_models::payments::NextActionCall,
api_models::payments::SdkNextActionData,
api_models::payments::SamsungPayWalletData,
api_models::payments::WeChatPay,
api_models::payments::GpayTokenizationData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,9 @@ pub enum StripeNextAction {
display_from_timestamp: i128,
display_to_timestamp: Option<i128>,
},
InvokeSdkClient {
next_action_data: payments::SdkNextActionData,
},
}

pub(crate) fn into_stripe_next_action(
Expand Down Expand Up @@ -871,6 +874,9 @@ pub(crate) fn into_stripe_next_action(
url: None,
},
},
payments::NextActionData::InvokeSdkClient { next_action_data } => {
StripeNextAction::InvokeSdkClient { next_action_data }
}
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ pub enum StripeNextAction {
display_from_timestamp: i128,
display_to_timestamp: Option<i128>,
},
InvokeSdkClient {
next_action_data: payments::SdkNextActionData,
},
}

pub(crate) fn into_stripe_next_action(
Expand Down Expand Up @@ -437,6 +440,9 @@ pub(crate) fn into_stripe_next_action(
url: None,
},
},
payments::NextActionData::InvokeSdkClient { next_action_data } => {
StripeNextAction::InvokeSdkClient { next_action_data }
}
})
}

Expand Down
Loading
Loading