Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(router): Add payment link support (#2105)
Sahkal Poddar642085dc745f
diff --git a/Cargo.lock b/Cargo.lockindex b8290efee0..e843210faa 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -392,6 +392,7 @@ dependencies = ["router_derive","serde","serde_json",+ "serde_with","strum 0.24.1","thiserror","time 0.3.22",@@ -1202,6 +1203,16 @@ dependencies = ["alloc-stdlib",]+[[package]]+name = "bstr"+version = "1.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05"+dependencies = [+ "memchr",+ "serde",+]+[[package]]name = "bumpalo"version = "3.13.0"@@ -1358,6 +1369,28 @@ dependencies = ["winapi",]+[[package]]+name = "chrono-tz"+version = "0.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f1369bc6b9e9a7dfdae2055f6ec151fe9c554a9d23d357c0237cee2e25eaabb7"+dependencies = [+ "chrono",+ "chrono-tz-build",+ "phf",+]++[[package]]+name = "chrono-tz-build"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e2f5ebdc942f57ed96d560a6d1a459bae5851102a25d5bf89dc04ae453e31ecf"+dependencies = [+ "parse-zoneinfo",+ "phf",+ "phf_codegen",+]+[[package]]name = "clap"version = "4.3.4"@@ -1786,6 +1819,12 @@ dependencies = ["syn 1.0.109",]+[[package]]+name = "deunicode"+version = "0.4.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d95203a6a50906215a502507c0f879a0ce7ff205a6111e2db2a5ef8e4bb92e43"+[[package]]name = "diesel"version = "2.1.0"@@ -2407,6 +2446,30 @@ version = "0.3.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"+[[package]]+name = "globset"+version = "0.4.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d"+dependencies = [+ "aho-corasick",+ "bstr",+ "fnv",+ "log",+ "regex",+]++[[package]]+name = "globwalk"+version = "0.8.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc"+dependencies = [+ "bitflags 1.3.2",+ "ignore",+ "walkdir",+]+[[package]]name = "h2"version = "0.3.19"@@ -2541,6 +2604,15 @@ version = "1.0.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"+[[package]]+name = "humansize"+version = "2.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7"+dependencies = [+ "libm",+]+[[package]]name = "humantime"version = "1.3.0"@@ -2653,6 +2725,23 @@ dependencies = ["unicode-normalization",]+[[package]]+name = "ignore"+version = "0.4.20"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492"+dependencies = [+ "globset",+ "lazy_static",+ "log",+ "memchr",+ "regex",+ "same-file",+ "thread_local",+ "walkdir",+ "winapi-util",+]+[[package]]name = "image"version = "0.23.14"@@ -3450,6 +3539,15 @@ version = "1.0.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "944553dd59c802559559161f9816429058b869003836120e262e8caec061b7ae"+[[package]]+name = "parse-zoneinfo"+version = "0.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41"+dependencies = [+ "regex",+]+[[package]]name = "paste"version = "1.0.12"@@ -3521,6 +3619,44 @@ dependencies = ["sha2",]+[[package]]+name = "phf"+version = "0.11.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"+dependencies = [+ "phf_shared",+]++[[package]]+name = "phf_codegen"+version = "0.11.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a"+dependencies = [+ "phf_generator",+ "phf_shared",+]++[[package]]+name = "phf_generator"+version = "0.11.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0"+dependencies = [+ "phf_shared",+ "rand 0.8.5",+]++[[package]]+name = "phf_shared"+version = "0.11.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b"+dependencies = [+ "siphasher",+]+[[package]]name = "phonenumber"version = "0.3.3+8.13.9"@@ -4144,6 +4280,7 @@ dependencies = ["signal-hook-tokio","storage_impl","strum 0.24.1",+ "tera","test_utils","thirtyfour","thiserror",@@ -4720,6 +4857,12 @@ dependencies = ["time 0.3.22",]+[[package]]+name = "siphasher"+version = "0.3.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"+[[package]]name = "skeptic"version = "0.13.7"@@ -4744,6 +4887,15 @@ dependencies = ["autocfg",]+[[package]]+name = "slug"+version = "0.1.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373"+dependencies = [+ "deunicode",+]+[[package]]name = "smallvec"version = "1.10.0"@@ -4926,6 +5078,28 @@ dependencies = ["windows-sys 0.48.0",]+[[package]]+name = "tera"+version = "1.19.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "970dff17c11e884a4a09bc76e3a17ef71e01bb13447a11e85226e254fe6d10b8"+dependencies = [+ "chrono",+ "chrono-tz",+ "globwalk",+ "humansize",+ "lazy_static",+ "percent-encoding",+ "pest",+ "pest_derive",+ "rand 0.8.5",+ "regex",+ "serde",+ "serde_json",+ "slug",+ "unic-segment",+]+[[package]]name = "termcolor"version = "1.2.0"@@ -5477,6 +5651,56 @@ version = "0.1.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94"+[[package]]+name = "unic-char-property"+version = "0.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221"+dependencies = [+ "unic-char-range",+]++[[package]]+name = "unic-char-range"+version = "0.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc"++[[package]]+name = "unic-common"+version = "0.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc"++[[package]]+name = "unic-segment"+version = "0.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e4ed5d26be57f84f176157270c112ef57b86debac9cd21daaabbe56db0f88f23"+dependencies = [+ "unic-ucd-segment",+]++[[package]]+name = "unic-ucd-segment"+version = "0.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2079c122a62205b421f499da10f3ee0f7697f012f55b675e002483c73ea34700"+dependencies = [+ "unic-char-property",+ "unic-char-range",+ "unic-ucd-version",+]++[[package]]+name = "unic-ucd-version"+version = "0.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4"+dependencies = [+ "unic-common",+]+[[package]]name = "unicase"version = "2.6.0"diff --git a/config/config.example.toml b/config/config.example.tomlindex bee61f2f61..e97b73d87c 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -431,3 +431,7 @@ apple_pay_ppc = "APPLE_PAY_PAYMENT_PROCESSING_CERTIFICATE" #Paymentapple_pay_ppc_key = "APPLE_PAY_PAYMENT_PROCESSING_CERTIFICATE_KEY" #Private key generate by Elliptic-curve prime256v1 curveapple_pay_merchant_cert = "APPLE_PAY_MERCHNAT_CERTIFICATE" #Merchant Certificate provided by Apple Pay (https://developer.apple.com/) Certificates, Identifiers & Profiles > Apple Pay Merchant Identity Certificateapple_pay_merchant_cert_key = "APPLE_PAY_MERCHNAT_CERTIFICATE_KEY" #Private key generate by RSA:2048 algorithm+++[payment_link]+sdk_url = "http://localhost:9090/dist/HyperLoader.js"\ No newline at end of filediff --git a/config/development.toml b/config/development.tomlindex 64bdd45f1c..a29cc9ec5b 100644--- a/config/development.toml+++ b/config/development.toml@@ -441,6 +441,9 @@ apple_pay_ppc_key = "APPLE_PAY_PAYMENT_PROCESSING_CERTIFICATE_KEY"apple_pay_merchant_cert = "APPLE_PAY_MERCHNAT_CERTIFICATE"apple_pay_merchant_cert_key = "APPLE_PAY_MERCHNAT_CERTIFICATE_KEY"+[payment_link]+sdk_url = "http://localhost:9090/dist/HyperLoader.js"+[lock_settings]redis_lock_expiry_seconds = 180 # 3 * 60 secondsdelay_between_retries_in_milliseconds = 500\ No newline at end of filediff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 08646a4a0b..3888d6d1d2 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -294,6 +294,8 @@ pub struct PaymentsRequest {/// additional data that might be required by hyperswitchpub feature_metadata: Option<FeatureMetadata>,+ /// payment link object required for generating the payment_link+ pub payment_link_object: Option<PaymentLinkObject>,/// The business profile to use for this payment, if not passed the default business profile/// associated with the merchant account will be used.@@ -2079,6 +2081,7 @@ pub struct PaymentsResponse {#[schema(value_type = Option<String>, example = "993672945374576J")]pub reference_id: Option<String>,+ pub payment_link: Option<PaymentLinkResponse>,/// The business profile that is associated with this paymentpub profile_id: Option<String>,@@ -3066,3 +3069,44 @@ mod tests {)}}++#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]+pub struct PaymentLinkObject {+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ pub link_expiry: Option<PrimitiveDateTime>,+ pub merchant_custom_domain_name: Option<String>,+}++#[derive(Default, Debug, serde::Deserialize, Clone, ToSchema)]+pub struct RetrievePaymentLinkRequest {+ pub client_secret: Option<String>,+}++#[derive(Clone, Debug, serde::Serialize, PartialEq, ToSchema)]+pub struct PaymentLinkResponse {+ pub link: String,+ pub payment_link_id: String,+}++#[derive(Clone, Debug, serde::Serialize, ToSchema)]+pub struct RetrievePaymentLinkResponse {+ pub payment_link_id: String,+ pub payment_id: String,+ pub merchant_id: String,+ pub link_to_pay: String,+ pub amount: i64,+ #[schema(value_type = Option<Currency>, example = "USD")]+ pub currency: Option<api_enums::Currency>,+ #[serde(with = "common_utils::custom_serde::iso8601")]+ pub created_at: PrimitiveDateTime,+ #[serde(with = "common_utils::custom_serde::iso8601")]+ pub last_modified_at: PrimitiveDateTime,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ pub link_expiry: Option<PrimitiveDateTime>,+}++#[derive(Clone, Debug, serde::Deserialize, ToSchema)]+pub struct PaymentLinkInitiateRequest {+ pub merchant_id: String,+ pub payment_id: String,+}diff --git a/crates/data_models/src/payments/payment_intent.rs b/crates/data_models/src/payments/payment_intent.rsindex b3bf8af8c3..3d8f52d000 100644--- a/crates/data_models/src/payments/payment_intent.rs+++ b/crates/data_models/src/payments/payment_intent.rs@@ -104,6 +104,7 @@ pub struct PaymentIntent {// Denotes the action(approve or reject) taken by merchant in case of manual review.// Manual review can occur when the transaction is marked as risky by the frm_processor, payment processor or when there is underpayment/over payment incase of crypto paymentpub merchant_decision: Option<String>,+ pub payment_link_id: Option<String>,pub payment_confirm_source: Option<storage_enums::PaymentSource>,}@@ -143,6 +144,7 @@ pub struct PaymentIntentNew {pub attempt_count: i16,pub profile_id: Option<String>,pub merchant_decision: Option<String>,+ pub payment_link_id: Option<String>,pub payment_confirm_source: Option<storage_enums::PaymentSource>,}diff --git a/crates/diesel_models/src/lib.rs b/crates/diesel_models/src/lib.rsindex 474ac984e6..3de35d73f8 100644--- a/crates/diesel_models/src/lib.rs+++ b/crates/diesel_models/src/lib.rs@@ -25,6 +25,7 @@ pub mod merchant_connector_account;pub mod merchant_key_store;pub mod payment_attempt;pub mod payment_intent;+pub mod payment_link;pub mod payment_method;pub mod payout_attempt;pub mod payouts;diff --git a/crates/diesel_models/src/payment_intent.rs b/crates/diesel_models/src/payment_intent.rsindex 1212c9d524..1669cd7e77 100644--- a/crates/diesel_models/src/payment_intent.rs+++ b/crates/diesel_models/src/payment_intent.rs@@ -46,6 +46,7 @@ pub struct PaymentIntent {// Denotes the action(approve or reject) taken by merchant in case of manual review.// Manual review can occur when the transaction is marked as risky by the frm_processor, payment processor or when there is underpayment/over payment incase of crypto paymentpub merchant_decision: Option<String>,+ pub payment_link_id: Option<String>,pub payment_confirm_source: Option<storage_enums::PaymentSource>,}@@ -97,6 +98,7 @@ pub struct PaymentIntentNew {pub attempt_count: i16,pub profile_id: Option<String>,pub merchant_decision: Option<String>,+ pub payment_link_id: Option<String>,pub payment_confirm_source: Option<storage_enums::PaymentSource>,}diff --git a/crates/diesel_models/src/payment_link.rs b/crates/diesel_models/src/payment_link.rsnew file mode 100644index 0000000000..4b182a8155--- /dev/null+++ b/crates/diesel_models/src/payment_link.rs@@ -0,0 +1,50 @@+use diesel::{Identifiable, Insertable, Queryable};+use serde::{self, Deserialize, Serialize};+use time::PrimitiveDateTime;++use crate::{enums as storage_enums, schema::payment_link};++#[derive(Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Serialize, Deserialize)]+#[diesel(table_name = payment_link)]+#[diesel(primary_key(payment_link_id))]+pub struct PaymentLink {+ pub payment_link_id: String,+ pub payment_id: String,+ pub link_to_pay: String,+ pub merchant_id: String,+ pub amount: i64,+ pub currency: Option<storage_enums::Currency>,+ #[serde(with = "common_utils::custom_serde::iso8601")]+ pub created_at: PrimitiveDateTime,+ #[serde(with = "common_utils::custom_serde::iso8601")]+ pub last_modified_at: PrimitiveDateTime,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ pub fulfilment_time: Option<PrimitiveDateTime>,+}++#[derive(+ Clone,+ Debug,+ Default,+ Eq,+ PartialEq,+ Insertable,+ serde::Serialize,+ serde::Deserialize,+ router_derive::DebugAsDisplay,+)]+#[diesel(table_name = payment_link)]+pub struct PaymentLinkNew {+ pub payment_link_id: String,+ pub payment_id: String,+ pub link_to_pay: String,+ pub merchant_id: String,+ pub amount: i64,+ pub currency: Option<storage_enums::Currency>,+ #[serde(with = "common_utils::custom_serde::iso8601::option")]+ pub created_at: Option<PrimitiveDateTime>,+ #[serde(with = "common_utils::custom_serde::iso8601::option")]+ pub last_modified_at: Option<PrimitiveDateTime>,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ pub fulfilment_time: Option<PrimitiveDateTime>,+}diff --git a/crates/diesel_models/src/query.rs b/crates/diesel_models/src/query.rsindex bd280864cc..ef4ab9f32f 100644--- a/crates/diesel_models/src/query.rs+++ b/crates/diesel_models/src/query.rs@@ -18,6 +18,7 @@ pub mod merchant_connector_account;pub mod merchant_key_store;pub mod payment_attempt;pub mod payment_intent;+pub mod payment_link;pub mod payment_method;pub mod payout_attempt;pub mod payouts;diff --git a/crates/diesel_models/src/query/payment_link.rs b/crates/diesel_models/src/query/payment_link.rsnew file mode 100644index 0000000000..085257633c--- /dev/null+++ b/crates/diesel_models/src/query/payment_link.rs@@ -0,0 +1,29 @@+use diesel::{associations::HasTable, ExpressionMethods};+use router_env::{instrument, tracing};++use super::generics;+use crate::{+ payment_link::{PaymentLink, PaymentLinkNew},+ schema::payment_link::dsl,+ PgPooledConn, StorageResult,+};++impl PaymentLinkNew {+ #[instrument(skip(conn))]+ pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<PaymentLink> {+ generics::generic_insert(conn, self).await+ }+}++impl PaymentLink {+ pub async fn find_link_by_payment_link_id(+ conn: &PgPooledConn,+ payment_link_id: &str,+ ) -> StorageResult<Self> {+ generics::generic_find_one::<<Self as HasTable>::Table, _, _>(+ conn,+ dsl::payment_link_id.eq(payment_link_id.to_owned()),+ )+ .await+ }+}diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rsindex 0da819f2a7..93a204446a 100644--- a/crates/diesel_models/src/schema.rs+++ b/crates/diesel_models/src/schema.rs@@ -610,10 +610,33 @@ diesel::table! {profile_id -> Nullable<Varchar>,#[max_length = 64]merchant_decision -> Nullable<Varchar>,+ #[max_length = 255]+ payment_link_id -> Nullable<Varchar>,payment_confirm_source -> Nullable<PaymentSource>,}}+diesel::table! {+ use diesel::sql_types::*;+ use crate::enums::diesel_exports::*;++ payment_link (payment_link_id) {+ #[max_length = 255]+ payment_link_id -> Varchar,+ #[max_length = 64]+ payment_id -> Varchar,+ #[max_length = 255]+ link_to_pay -> Varchar,+ #[max_length = 64]+ merchant_id -> Varchar,+ amount -> Int8,+ currency -> Nullable<Currency>,+ created_at -> Timestamp,+ last_modified_at -> Timestamp,+ fulfilment_time -> Nullable<Timestamp>,+ }+}+diesel::table! {use diesel::sql_types::*;use crate::enums::diesel_exports::*;@@ -833,6 +856,7 @@ diesel::allow_tables_to_appear_in_same_query!(merchant_key_store,payment_attempt,payment_intent,+ payment_link,payment_methods,payout_attempt,payouts,diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.tomlindex f271c6e362..da207e9149 100644--- a/crates/router/Cargo.toml+++ b/crates/router/Cargo.toml@@ -81,6 +81,7 @@ strum = { version = "0.24.1", features = ["derive"] }thiserror = "1.0.40"time = { version = "0.3.21", features = ["serde", "serde-well-known", "std"] }tokio = { version = "1.28.2", features = ["macros", "rt-multi-thread"] }+tera = "1.19.1"url = { version = "2.4.0", features = ["serde"] }utoipa = { version = "3.3.0", features = ["preserve_order", "time"] }utoipa-swagger-ui = { version = "3.1.3", features = ["actix-web"] }diff --git a/crates/router/src/compatibility/stripe/errors.rs b/crates/router/src/compatibility/stripe/errors.rsindex d79533e73b..5d4d3082af 100644--- a/crates/router/src/compatibility/stripe/errors.rs+++ b/crates/router/src/compatibility/stripe/errors.rs@@ -232,6 +232,8 @@ pub enum StripeErrorCode {HyperswitchUnprocessableEntity { message: String },#[error(error_type = StripeErrorType::InvalidRequestError, code = "", message = "{message}")]CurrencyNotSupported { message: String },+ #[error(error_type = StripeErrorType::HyperswitchError, code = "", message = "Payment Link does not exist in our records")]+ PaymentLinkNotFound,#[error(error_type = StripeErrorType::HyperswitchError, code = "", message = "Resource Busy. Please try again later")]LockTimeout,// [#216]: https://github.com/juspay/hyperswitch/issues/216@@ -490,6 +492,7 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {errors::ApiErrorResponse::ClientSecretNotGiven| errors::ApiErrorResponse::ClientSecretExpired => Self::ClientSecretNotFound,errors::ApiErrorResponse::MerchantAccountNotFound => Self::MerchantAccountNotFound,+ errors::ApiErrorResponse::PaymentLinkNotFound => Self::PaymentLinkNotFound,errors::ApiErrorResponse::ResourceIdNotFound => Self::ResourceIdNotFound,errors::ApiErrorResponse::MerchantConnectorAccountNotFound { id } => {Self::MerchantConnectorAccountNotFound { id }@@ -652,6 +655,7 @@ impl actix_web::ResponseError for StripeErrorCode {| Self::PaymentMethodUnactivated => StatusCode::BAD_REQUEST,Self::RefundFailed| Self::PayoutFailed+ | Self::PaymentLinkNotFound| Self::InternalServerError| Self::MandateActive| Self::CustomerRedacteddiff --git a/crates/router/src/compatibility/wrap.rs b/crates/router/src/compatibility/wrap.rsindex edc56fcee7..f1892698ac 100644--- a/crates/router/src/compatibility/wrap.rs+++ b/crates/router/src/compatibility/wrap.rs@@ -132,6 +132,20 @@ where.respond_to(request).map_into_boxed_body()}++ Ok(api::ApplicationResponse::PaymenkLinkForm(payment_link_data)) => {+ match api::build_payment_link_html(*payment_link_data) {+ Ok(rendered_html) => api::http_response_html_data(rendered_html),+ Err(_) => api::http_response_err(+ r#"{+ "error": {+ "message": "Error while rendering payment link html page"+ }+ }"#,+ ),+ }+ }+Err(error) => api::log_and_return_error_response(error),};diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rsindex 9ee84e5bae..5dd58c5d5f 100644--- a/crates/router/src/configs/settings.rs+++ b/crates/router/src/configs/settings.rs@@ -100,6 +100,12 @@ pub struct Settings {pub applepay_merchant_configs: ApplepayMerchantConfigs,pub lock_settings: LockSettings,pub temp_locker_enable_config: TempLockerEnableConfig,+ pub payment_link: PaymentLink,+}++#[derive(Debug, Deserialize, Clone, Default)]+pub struct PaymentLink {+ pub sdk_url: String,}#[derive(Debug, Deserialize, Clone, Default)]diff --git a/crates/router/src/core.rs b/crates/router/src/core.rsindex 2e090a6436..a3bb3c7891 100644--- a/crates/router/src/core.rs+++ b/crates/router/src/core.rs@@ -10,6 +10,7 @@ pub mod errors;pub mod files;pub mod mandate;pub mod metrics;+pub mod payment_link;pub mod payment_methods;pub mod payments;#[cfg(feature = "payouts")]diff --git a/crates/router/src/core/errors/api_error_response.rs b/crates/router/src/core/errors/api_error_response.rsindex 6805bc2be1..e606771b37 100644--- a/crates/router/src/core/errors/api_error_response.rs+++ b/crates/router/src/core/errors/api_error_response.rs@@ -230,6 +230,8 @@ pub enum ApiErrorResponse {IncorrectPaymentMethodConfiguration,#[error(error_type = ErrorType::InvalidRequestError, code = "WE_05", message = "Unable to process the webhook body")]WebhookUnprocessableEntity,+ #[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Payment Link does not exist in our records")]+ PaymentLinkNotFound,#[error(error_type = ErrorType::InvalidRequestError, code = "WE_05", message = "Merchant Secret set my merchant for webhook source verification is invalid")]WebhookInvalidMerchantSecret,#[error(error_type = ErrorType::InvalidRequestError, code = "IR_19", message = "{message}")]diff --git a/crates/router/src/core/errors/transformers.rs b/crates/router/src/core/errors/transformers.rsindex 37725b7391..38d42596cd 100644--- a/crates/router/src/core/errors/transformers.rs+++ b/crates/router/src/core/errors/transformers.rs@@ -264,6 +264,9 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorResponSelf::ResourceBusy => {AER::Unprocessable(ApiError::new("WE", 5, "There was an issue processing the webhook body", None))}+ Self::PaymentLinkNotFound => {+ AER::NotFound(ApiError::new("HE", 2, "Payment Link does not exist in our records", None))+ }}}}diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rsnew file mode 100644index 0000000000..2f817beb53--- /dev/null+++ b/crates/router/src/core/payment_link.rs@@ -0,0 +1,172 @@+use common_utils::ext_traits::AsyncExt;+use error_stack::ResultExt;++use super::errors::{self, StorageErrorExt};+use crate::{+ core::payments::helpers,+ errors::RouterResponse,+ routes::AppState,+ services,+ types::{domain, storage::enums as storage_enums, transformers::ForeignFrom},+ utils::OptionExt,+};++pub async fn retrieve_payment_link(+ state: AppState,+ payment_link_id: String,+) -> RouterResponse<api_models::payments::RetrievePaymentLinkResponse> {+ let db = &*state.store;+ let payment_link_object = db+ .find_payment_link_by_payment_link_id(&payment_link_id)+ .await+ .to_not_found_response(errors::ApiErrorResponse::PaymentLinkNotFound)?;++ let response =+ api_models::payments::RetrievePaymentLinkResponse::foreign_from(payment_link_object);+ Ok(services::ApplicationResponse::Json(response))+}++pub async fn intiate_payment_link_flow(+ state: AppState,+ merchant_account: domain::MerchantAccount,+ merchant_id: String,+ payment_id: String,+) -> RouterResponse<services::PaymentLinkFormData> {+ let db = &*state.store;+ let payment_intent = db+ .find_payment_intent_by_payment_id_merchant_id(+ &payment_id,+ &merchant_id,+ merchant_account.storage_scheme,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;+ let fulfillment_time = payment_intent+ .payment_link_id+ .as_ref()+ .async_and_then(|pli| async move {+ db.find_payment_link_by_payment_link_id(pli)+ .await+ .ok()?+ .fulfilment_time+ .ok_or(errors::ApiErrorResponse::PaymentNotFound)+ .ok()+ })+ .await+ .get_required_value("fulfillment_time")+ .change_context(errors::ApiErrorResponse::PaymentNotFound)?;++ helpers::validate_payment_status_against_not_allowed_statuses(+ &payment_intent.status,+ &[+ storage_enums::IntentStatus::Cancelled,+ storage_enums::IntentStatus::Succeeded,+ storage_enums::IntentStatus::Processing,+ storage_enums::IntentStatus::RequiresCapture,+ storage_enums::IntentStatus::RequiresMerchantAction,+ ],+ "create payment link",+ )?;++ let expiry = fulfillment_time.assume_utc().unix_timestamp();++ let js_script = get_js_script(+ payment_intent.amount.to_string(),+ payment_intent.currency.unwrap_or_default().to_string(),+ merchant_account.publishable_key.unwrap_or_default(),+ payment_intent.client_secret.unwrap_or_default(),+ payment_intent.payment_id,+ expiry,+ );++ let payment_link_data = services::PaymentLinkFormData {+ js_script,+ sdk_url: state.conf.payment_link.sdk_url.clone(),+ };+ Ok(services::ApplicationResponse::PaymenkLinkForm(Box::new(+ payment_link_data,+ )))+}++/*+The get_js_script function is used to inject dynamic value to payment_link sdk, which is unique to every payment.+*/++fn get_js_script(+ amount: String,+ currency: String,+ pub_key: String,+ secret: String,+ payment_id: String,+ expiry: i64,+) -> String {+ format!(+ "window.__PAYMENT_DETAILS_STR = JSON.stringify({{+ client_secret: '{secret}',+ amount: '{amount}',+ currency: '{currency}',+ payment_id: '{payment_id}',+ expiry: {expiry},+ // TODO: Remove hardcoded values+ merchant_logo: 'https://upload.wikimedia.org/wikipedia/commons/8/83/Steam_icon_logo.svg',+ return_url: 'http://localhost:5500/public/index.html',+ currency_symbol: '$',+ merchant: 'Steam',+ max_items_visible_after_collapse: 3,+ order_details: [+ {{+ product_name:+ 'dskjghbdsiuh sagfvbsajd ugbfiusedg fiudshgiu sdhgvishd givuhdsifu gnb gidsug biuesbdg iubsedg bsduxbg jhdxbgv jdskfbgi sdfgibuh ew87t54378 ghdfjbv jfdhgvb dufhvbfidu hg5784ghdfbjnk f (taxes incl.)',+ quantity: 2,+ amount: 100,+ product_image:+ 'https://upload.wikimedia.org/wikipedia/commons/8/83/Steam_icon_logo.svg',+ }},+ {{+ product_name: \"F1 '23\",+ quantity: 4,+ amount: 500,+ product_image:+ 'https://upload.wikimedia.org/wikipedia/commons/8/83/Steam_icon_logo.svg',+ }},+ {{+ product_name: \"Motosport '24\",+ quantity: 4,+ amount: 500,+ product_image:+ 'https://upload.wikimedia.org/wikipedia/commons/8/83/Steam_icon_logo.svg',+ }},+ {{+ product_name: 'Trackmania',+ quantity: 4,+ amount: 500,+ product_image:+ 'https://upload.wikimedia.org/wikipedia/commons/8/83/Steam_icon_logo.svg',+ }},+ {{+ product_name: 'Ghost Recon',+ quantity: 4,+ amount: 500,+ product_image:+ 'https://upload.wikimedia.org/wikipedia/commons/8/83/Steam_icon_logo.svg',+ }},+ {{+ product_name: 'Cup of Tea',+ quantity: 4,+ amount: 500,+ product_image:+ 'https://upload.wikimedia.org/wikipedia/commons/8/83/Steam_icon_logo.svg',+ }},+ {{+ product_name: 'Tea cups',+ quantity: 4,+ amount: 500,+ product_image:+ 'https://upload.wikimedia.org/wikipedia/commons/8/83/Steam_icon_logo.svg',+ }},+ ]+ }});++ const hyper = Hyper(\"{pub_key}\");"+ )+}diff --git a/crates/router/src/core/payment_link/payment_link.html b/crates/router/src/core/payment_link/payment_link.htmlnew file mode 100644index 0000000000..4ce2ff1919--- /dev/null+++ b/crates/router/src/core/payment_link/payment_link.html@@ -0,0 +1,1310 @@+<!DOCTYPE html>+<html>+ <head>+ {{ hyperloader_sdk_link }}+ <style>+ :root {+ --primary-color: #26c5a0;+ --primary-accent-color: #f8e5a0;+ --secondary-color: #1c7ed9;+ }++ html,+ body {+ height: 100%;+ }++ body {+ display: flex;+ flex-flow: column;+ align-items: center;+ justify-content: flex-start;+ margin: 0;+ background-color: #fafafa;+ color: #292929;+ }++ .hidden {+ display: none !important;+ }++ .hyper-checkout {+ display: flex;+ background-color: #fafafa;+ height: 100%;+ width: 100%;+ max-width: 1900px;+ }++ .main {+ display: flex;+ flex-flow: column;+ justify-content: center;+ align-items: center;+ background-color: #fdfdfd;+ min-width: 500px;+ width: 50vw;+ }++ #hyper-checkout-details {+ font-family: "Montserrat";+ }++ .hyper-checkout-payment {+ border: 1px solid #e6e6e6;+ border-radius: 8px;+ min-width: 582px;+ }++ .hyper-checkout-payment-content-details {+ display: flex;+ flex-flow: row;+ margin: 20px;+ justify-content: space-between;+ }++ .hyper-checkout-payment-price {+ font-weight: 700;+ font-size: 40px;+ height: 64px;+ display: flex;+ align-items: center;+ }++ #hyper-checkout-payment-merchant-details {+ margin-top: 20px;+ }++ .hyper-checkout-payment-merchant-name {+ font-weight: 600;+ font-size: 18px;+ }++ .hyper-checkout-payment-ref {+ font-size: 13px;+ }++ .hyper-checkout-image-header {+ display: flex;+ justify-content: space-between;+ align-items: center;+ }++ #hyper-checkout-merchant-image,+ #hyper-checkout-cart-image {+ height: 64px;+ width: 64px;+ border: 1px solid #e6e6e6;+ border-radius: 4px;+ display: flex;+ align-items: center;+ justify-content: center;+ }++ #hyper-checkout-merchant-image > img {+ height: 48px;+ width: 48px;+ }++ #hyper-checkout-cart-image {+ display: none;+ cursor: pointer;+ height: 60px;+ width: 60px;+ border-radius: 100px;+ background-color: #f5f5f5;+ }++ #hyper-checkout-payment-footer {+ padding: 8px 20px;+ background-color: #f5f5f5;+ font-size: 13px;+ font-weight: 500;+ }++ #hyper-checkout-cart {+ display: flex;+ flex-flow: column;+ min-width: 582px;+ width: min-content;+ margin-top: 30px;+ max-height: 600px;+ }++ #hyper-checkout-cart-items {+ margin: 10px 0;+ max-height: 600px;+ overflow: scroll;+ padding-right: 20px;+ }++ .hyper-checkout-cart-header {+ font-size: 15px;+ display: flex;+ flex-flow: row;+ align-items: center;+ }++ .hyper-checkout-cart-header > span {+ margin-left: 5px;+ font-weight: 500;+ }++ .cart-close {+ display: none;+ }++ .hyper-checkout-cart-item {+ display: flex;+ flex-flow: row;+ margin: 20px 0;+ font-size: 15px;+ }++ .hyper-checkout-cart-product-image {+ height: 88px;+ width: 88px;+ }++ .hyper-checkout-card-item-name {+ font-weight: 500;+ overflow: hidden;+ text-overflow: ellipsis;+ -webkit-line-clamp: 2;+ display: -webkit-box;+ -webkit-box-orient: vertical;+ }++ .hyper-checkout-card-item-quantity {+ border: 1px solid #e6e6e6;+ border-radius: 3px;+ width: max-content;+ padding: 5px 12px;+ background-color: #fafafa;+ font-size: 13px;+ font-weight: 500;+ }++ .hyper-checkout-cart-product-details {+ display: flex;+ flex-flow: column;+ margin-left: 10px;+ justify-content: space-between;+ width: 100%;+ }++ .hyper-checkout-card-item-price {+ justify-self: flex-end;+ font-weight: 600;+ font-size: 16px;+ padding-left: 30px;+ text-align: end;+ }++ .hyper-checkout-cart-item-divider {+ height: 1px;+ background-color: #e6e6e6;+ }++ .hyper-checkout-cart-button {+ color: var(--primary-color);+ font-size: 15px;+ font-weight: 600;+ cursor: pointer;+ }++ .hyper-checkout-sdk {+ width: 50vw;+ min-width: 584px;+ z-index: 2;+ background-color: var(--primary-color);+ box-shadow: 0px 1px 10px #f2f2f2;+ display: flex;+ align-items: center;+ justify-content: center;+ }++ #payment-form-wrap {+ min-width: 584px;+ padding: 50px;+ }++ #hyper-checkout-sdk-header {+ padding: 10px 10px 10px 22px;+ display: flex;+ align-items: flex-start;+ justify-content: flex-start;+ border-bottom: 1px solid #f2f2f2;+ }++ .hyper-checkout-sdk-header-logo {+ height: 60px;+ width: 60px;+ background-color: white;+ border-radius: 2px;+ }++ .hyper-checkout-sdk-header-logo > img {+ height: 56px;+ width: 56px;+ margin: 2px;+ }++ .hyper-checkout-sdk-header-items {+ display: flex;+ flex-flow: column;+ color: white;+ font-size: 20px;+ font-weight: 700;+ }++ .hyper-checkout-sdk-items {+ margin-left: 10px;+ }++ .hyper-checkout-sdk-header-brand-name,+ .hyper-checkout-sdk-header-amount {+ font-size: 18px;+ font-weight: 600;+ display: flex;+ align-items: center;+ font-family: "Montserrat";+ justify-self: flex-start;+ }++ .hyper-checkout-sdk-header-amount {+ font-weight: 800;+ font-size: 25px;+ }++ .payNow {+ margin-top: 10px;+ }++ .checkoutButton {+ height: 48px;+ border-radius: 25px;+ width: 100%;+ border: transparent;+ background: var(--secondary-color);+ color: #ffffff;+ font-weight: 600;+ cursor: pointer;+ }++ .page-spinner,+ .page-spinner::before,+ .page-spinner::after,+ .spinner,+ .spinner:before,+ .spinner:after {+ border-radius: 50%;+ }++ .page-spinner,+ .spinner {+ color: #ffffff;+ font-size: 22px;+ text-indent: -99999px;+ margin: 0px auto;+ position: relative;+ width: 20px;+ height: 20px;+ box-shadow: inset 0 0 0 2px;+ -webkit-transform: translateZ(0);+ -ms-transform: translateZ(0);+ transform: translateZ(0);+ }++ .page-spinner::before,+ .page-spinner::after,+ .spinner:before,+ .spinner:after {+ position: absolute;+ content: "";+ }++ .page-spinner {+ color: var(--primary-color) !important;+ height: 50px !important;+ width: 50px !important;+ box-shadow: inset 0 0 0 4px !important;+ margin: auto !important;+ }++ #hyper-checkout-status {+ margin: 40px !important;+ }++ .hyper-checkout-status-header {+ display: flex;+ align-items: center;+ font-family: "Montserrat";+ font-size: 24px;+ font-weight: 600;+ }++ #status-img {+ height: 70px;+ }++ #status-date {+ font-size: 13px;+ font-weight: 500;+ color: #53655c;+ }++ #status-details {+ margin-left: 10px;+ justify-content: center;+ display: flex;+ flex-flow: column;+ }++ @keyframes loading {+ 0% {+ -webkit-transform: rotate(0deg);+ transform: rotate(0deg);+ }++ 100% {+ -webkit-transform: rotate(360deg);+ transform: rotate(360deg);+ }+ }++ .spinner:before {+ width: 10.4px;+ height: 20.4px;+ background: var(--primary-color);+ border-radius: 20.4px 0 0 20.4px;+ top: -0.2px;+ left: -0.2px;+ -webkit-transform-origin: 10.4px 10.2px;+ transform-origin: 10.4px 10.2px;+ -webkit-animation: loading 2s infinite ease 1.5s;+ animation: loading 2s infinite ease 1.5s;+ }++ #payment-message {+ font-size: 12px;+ font-weight: 500;+ padding: 2%;+ color: #ff0000;+ font-family: "Montserrat";+ }++ .spinner:after {+ width: 10.4px;+ height: 10.2px;+ background: var(--primary-color);+ border-radius: 0 10.2px 10.2px 0;+ top: -0.1px;+ left: 10.2px;+ -webkit-transform-origin: 0px 10.2px;+ transform-origin: 0px 10.2px;+ -webkit-animation: loading 2s infinite ease;+ animation: loading 2s infinite ease;+ }++ #payment-form {+ max-width: 560px;+ width: 100%;+ margin: 0 auto;+ text-align: center;+ }++ @media only screen and (max-width: 1200px) {+ .checkoutButton {+ width: 95%;+ background-color: var(--primary-color);+ }++ .hyper-checkout {+ flex-flow: column;+ margin: 0;+ }++ .main {+ width: auto;+ min-width: 300px;+ }++ .hyper-checkout-payment {+ min-width: 100px;+ width: 100vw;+ margin: 0;+ border: 0;+ border-radius: 0;+ background-color: var(--primary-color);+ display: flex;+ flex-flow: column;+ justify-self: flex-start;+ align-self: flex-start;+ }++ .hyper-checkout-payment-content-details {+ flex-flow: column;+ flex-direction: column-reverse;+ margin: 24px;+ }++ #hyper-checkout-merchant-image {+ background-color: white;+ }++ #hyper-checkout-cart-image {+ display: flex;+ }++ .hyper-checkout-payment-price {+ font-size: 48px;+ margin-top: 20px;+ }++ .hyper-checkout-payment-merchant-name {+ font-size: 18px;+ }++ #hyper-checkout-payment-footer {+ background-color: var(--primary-accent-color);+ border-radius: 50px;+ width: auto;+ align-self: center;+ margin: 0 24px 24px 24px;+ }++ #hyper-checkout-cart {+ position: absolute;+ top: 0;+ right: 0;+ z-index: 100;+ margin: 0;+ min-width: 300px;+ max-width: 600px;+ max-height: 100vh;+ width: 100vw;+ height: 100vh;+ background-color: #f5f5f5;+ box-shadow: 0px 10px 10px #aeaeae;+ }++ .hyper-checkout-cart-header {+ margin: 10px 0 0 10px;+ }++ .cart-close {+ margin: 0 10px 0 auto;+ display: inline;+ }++ #hyper-checkout-cart-items {+ margin: 20px;+ padding: 0;+ max-height: max-content;+ }++ .hyper-checkout-cart-button {+ margin: 10px;+ text-align: right;+ }++ #hyper-checkout-sdk {+ margin: 20px 0 0 0;+ background-color: transparent;+ min-width: 300px;+ width: 100vw;+ }++ #payment-form-wrap {+ min-width: 300px;+ padding: 10px;+ width: 100vw;+ }++ #hyper-checkout-status {+ padding: 15px;+ }++ #status-img {+ height: 60px;+ }++ #status-text {+ font-size: 19px;+ }++ #status-date {+ font-size: 12px;+ }++ .hyper-checkout-item-header {+ font-size: 11px;+ }++ .hyper-checkout-item-value {+ font-size: 17px;+ }+ }+ </style>+ <link+ rel="stylesheet"+ href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800"+ />+ </head>++ <body onload="showSDK()">+ <div class="page-spinner hidden" id="page-spinner"></div>+ <div class="hyper-checkout">+ <div class="main hidden" id="hyper-checkout-status">+ <div class="hyper-checkout-status-header">+ <img id="status-img" />+ <div id="status-details">+ <div id="status-text"></div>+ <div id="status-date"></div>+ </div>+ </div>+ <div id="hyper-checkout-status-items"></div>+ </div>+ <div class="main" id="hyper-checkout-details">+ <div class="hyper-checkout-payment">+ <div class="hyper-checkout-payment-content-details">+ <div id="hyper-checkout-payment-context">+ <div id="hyper-checkout-payment-merchant-details"></div>+ </div>+ <div class="hyper-checkout-image-header">+ <div id="hyper-checkout-merchant-image"></div>+ <div+ id="hyper-checkout-cart-image"+ onclick="viewCartInMobileView()"+ >+ <svg+ fill="#000000"+ version="1.1"+ id="Capa_1"+ xmlns="http://www.w3.org/2000/svg"+ xmlns:xlink="http://www.w3.org/1999/xlink"+ width="30px"+ height="30px"+ viewBox="0 0 902.86 902.86"+ xml:space="preserve"+ >+ <g>+ <g>+ <path+ d="M671.504,577.829l110.485-432.609H902.86v-68H729.174L703.128,179.2L0,178.697l74.753,399.129h596.751V577.829z+ M685.766,247.188l-67.077,262.64H131.199L81.928,246.756L685.766,247.188z"+ />+ <path+ d="M578.418,825.641c59.961,0,108.743-48.783,108.743-108.744s-48.782-108.742-108.743-108.742H168.717+ c-59.961,0-108.744,48.781-108.744,108.742s48.782,108.744,108.744,108.744c59.962,0,108.743-48.783,108.743-108.744+ c0-14.4-2.821-28.152-7.927-40.742h208.069c-5.107,12.59-7.928,26.342-7.928,40.742+ C469.675,776.858,518.457,825.641,578.418,825.641z M209.46,716.897c0,22.467-18.277,40.744-40.743,40.744+ c-22.466,0-40.744-18.277-40.744-40.744c0-22.465,18.277-40.742,40.744-40.742C191.183,676.155,209.46,694.432,209.46,716.897z+ M619.162,716.897c0,22.467-18.277,40.744-40.743,40.744s-40.743-18.277-40.743-40.744c0-22.465,18.277-40.742,40.743-40.742+ S619.162,694.432,619.162,716.897z"+ />+ </g>+ </g>+ </svg>+ </div>+ </div>+ </div>+ <div id="hyper-checkout-payment-footer"></div>+ </div>+ <div id="hyper-checkout-cart">+ <div class="hyper-checkout-cart-header">+ <svg+ width="16"+ height="16"+ viewBox="0 0 16 16"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ class="cart-icon"+ >+ <g clip-path="url(#clip0_11421_6708)">+ <mask+ id="mask0_11421_6708"+ style="mask-type: alpha"+ maskUnits="userSpaceOnUse"+ x="0"+ y="0"+ width="16"+ height="16"+ >+ <rect width="16" height="16" fill="#D9D9D9" />+ </mask>+ <g mask="url(#mask0_11421_6708)">+ <path+ d="M3.53716 14.3331C3.20469 14.3331 2.92071 14.2153 2.68525 13.9798C2.44977 13.7444 2.33203 13.4604 2.33203 13.1279V5.53823C2.33203 5.20575 2.44977 4.92178 2.68525 4.68631C2.92071 4.45083 3.20469 4.3331 3.53716 4.3331H4.9987C4.9987 3.50063 5.29058 2.79252 5.87433 2.20876C6.4581 1.62501 7.16621 1.33313 7.99868 1.33313C8.83115 1.33313 9.53927 1.62501 10.123 2.20876C10.7068 2.79252 10.9987 3.50063 10.9987 4.3331H12.4602C12.7927 4.3331 13.0766 4.45083 13.3121 4.68631C13.5476 4.92178 13.6653 5.20575 13.6653 5.53823V13.1279C13.6653 13.4604 13.5476 13.7444 13.3121 13.9798C13.0766 14.2153 12.7927 14.3331 12.4602 14.3331H3.53716ZM3.53716 13.3331H12.4602C12.5115 13.3331 12.5585 13.3117 12.6012 13.269C12.644 13.2262 12.6653 13.1792 12.6653 13.1279V5.53823C12.6653 5.48694 12.644 5.43992 12.6012 5.39718C12.5585 5.35445 12.5115 5.33308 12.4602 5.33308H3.53716C3.48588 5.33308 3.43886 5.35445 3.39611 5.39718C3.35338 5.43992 3.33201 5.48694 3.33201 5.53823V13.1279C3.33201 13.1792 3.35338 13.2262 3.39611 13.269C3.43886 13.3117 3.48588 13.3331 3.53716 13.3331ZM7.99868 8.99973C8.83115 8.99973 9.53927 8.70785 10.123 8.1241C10.7068 7.54033 10.9987 6.83221 10.9987 5.99975H9.99868C9.99868 6.5553 9.80424 7.02752 9.41535 7.41641C9.02646 7.8053 8.55424 7.99975 7.99868 7.99975C7.44313 7.99975 6.9709 7.8053 6.58202 7.41641C6.19313 7.02752 5.99868 6.5553 5.99868 5.99975H4.9987C4.9987 6.83221 5.29058 7.54033 5.87433 8.1241C6.4581 8.70785 7.16621 8.99973 7.99868 8.99973ZM5.99868 4.3331H9.99868C9.99868 3.77754 9.80424 3.30532 9.41535 2.91643C9.02646 2.52754 8.55424 2.3331 7.99868 2.3331C7.44313 2.3331 6.9709 2.52754 6.58202 2.91643C6.19313 3.30532 5.99868 3.77754 5.99868 4.3331Z"+ fill="#333333"+ />+ </g>+ </g>+ <defs>+ <clipPath id="clip0_11421_6708">+ <rect width="16" height="16" fill="white" />+ </clipPath>+ </defs>+ </svg>+ <span>Your Cart</span>+ <svg+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 50 50"+ width="25px"+ height="25px"+ class="cart-close"+ onclick="hideCartInMobileView()"+ >+ <path+ d="M 9.15625 6.3125 L 6.3125 9.15625 L 22.15625 25 L 6.21875 40.96875 L 9.03125 43.78125 L 25 27.84375 L 40.9375 43.78125 L 43.78125 40.9375 L 27.84375 25 L 43.6875 9.15625 L 40.84375 6.3125 L 25 22.15625 Z"+ />+ </svg>+ </div>+ <div id="hyper-checkout-cart-items"></div>+ </div>+ </div>+ <div class="hyper-checkout-sdk" id="hyper-checkout-sdk">+ <div id="payment-form-wrap">+ <form id="payment-form" onsubmit="handleSubmit(); return false;">+ <div id="unified-checkout">+ <div+ id="orca-element-unified-checkout"+ style="height: auto"+ class="payment base"+ >+ <div id="orca-fullscreen-iframeRef-unified-checkout"></div>+ <iframe+ id="orca-payment-element-iframeRef-unified-checkout"+ name="orca-payment-element-iframeRef-unified-checkout"+ src="http://localhost:9050/?componentName=payment"+ allow="payment *"+ style="+ border: 0px none;+ transition: height 0.35s ease 0s, opacity 0.4s ease 0.1s;+ height: 338px;+ "+ width="100%"+ ></iframe>+ </div>+ </div>+ <button id="submit" class="checkoutButton payNow">+ <div class="spinner hidden" id="spinner"></div>+ <span id="button-text">Pay now</span>+ </button>+ <div id="payment-message" class="hidden"></div>+ </form>+ </div>+ </div>+ </div>+ <div id="hyper-footer" class="hidden">+ <svg class="fill-current" height="18px" width="130px" transform="">+ <path+ opacity="0.4"+ d="M0.791016 11.7578H1.64062V9.16992H1.71875C2.00684 9.73145 2.63672 10.0928 3.35938 10.0928C4.69727 10.0928 5.56641 9.02344 5.56641 7.37305V7.36328C5.56641 5.72266 4.69238 4.64355 3.35938 4.64355C2.62695 4.64355 2.04102 4.99023 1.71875 5.57617H1.64062V4.73633H0.791016V11.7578ZM3.16406 9.34082C2.20703 9.34082 1.62109 8.58887 1.62109 7.37305V7.36328C1.62109 6.14746 2.20703 5.39551 3.16406 5.39551C4.12598 5.39551 4.69727 6.1377 4.69727 7.36328V7.37305C4.69727 8.59863 4.12598 9.34082 3.16406 9.34082ZM8.85762 10.0928C10.3566 10.0928 11.2844 9.05762 11.2844 7.37305V7.36328C11.2844 5.67383 10.3566 4.64355 8.85762 4.64355C7.35859 4.64355 6.43086 5.67383 6.43086 7.36328V7.37305C6.43086 9.05762 7.35859 10.0928 8.85762 10.0928ZM8.85762 9.34082C7.86152 9.34082 7.3 8.61328 7.3 7.37305V7.36328C7.3 6.11816 7.86152 5.39551 8.85762 5.39551C9.85371 5.39551 10.4152 6.11816 10.4152 7.36328V7.37305C10.4152 8.61328 9.85371 9.34082 8.85762 9.34082ZM13.223 10H14.0727L15.2445 5.92773H15.3227L16.4994 10H17.3539L18.8285 4.73633H17.9838L16.9486 8.94531H16.8705L15.6938 4.73633H14.8881L13.7113 8.94531H13.6332L12.598 4.73633H11.7484L13.223 10ZM21.7047 10.0928C22.9449 10.0928 23.6969 9.38965 23.8775 8.67676L23.8873 8.6377H23.0377L23.0182 8.68164C22.8766 8.99902 22.4371 9.33594 21.7242 9.33594C20.7867 9.33594 20.1861 8.70117 20.1617 7.6123H23.9508V7.28027C23.9508 5.70801 23.0816 4.64355 21.651 4.64355C20.2203 4.64355 19.2926 5.75684 19.2926 7.38281V7.3877C19.2926 9.03809 20.2008 10.0928 21.7047 10.0928ZM21.6461 5.40039C22.4225 5.40039 22.9986 5.89355 23.0865 6.93359H20.1764C20.2691 5.93262 20.8648 5.40039 21.6461 5.40039ZM25.0691 10H25.9188V6.73828C25.9188 5.9668 26.4949 5.4541 27.3055 5.4541C27.491 5.4541 27.6521 5.47363 27.8279 5.50293V4.67773C27.7449 4.66309 27.5643 4.64355 27.4031 4.64355C26.6902 4.64355 26.1971 4.96582 25.9969 5.51758H25.9188V4.73633H25.0691V10ZM30.6797 10.0928C31.9199 10.0928 32.6719 9.38965 32.8525 8.67676L32.8623 8.6377H32.0127L31.9932 8.68164C31.8516 8.99902 31.4121 9.33594 30.6992 9.33594C29.7617 9.33594 29.1611 8.70117 29.1367 7.6123H32.9258V7.28027C32.9258 5.70801 32.0566 4.64355 30.626 4.64355C29.1953 4.64355 28.2676 5.75684 28.2676 7.38281V7.3877C28.2676 9.03809 29.1758 10.0928 30.6797 10.0928ZM30.6211 5.40039C31.3975 5.40039 31.9736 5.89355 32.0615 6.93359H29.1514C29.2441 5.93262 29.8398 5.40039 30.6211 5.40039ZM35.9875 10.0928C36.7199 10.0928 37.3059 9.74609 37.6281 9.16016H37.7062V10H38.5559V2.64648H37.7062V5.56641H37.6281C37.34 5.00488 36.7102 4.64355 35.9875 4.64355C34.6496 4.64355 33.7805 5.71289 33.7805 7.36328V7.37305C33.7805 9.01367 34.6545 10.0928 35.9875 10.0928ZM36.1828 9.34082C35.2209 9.34082 34.6496 8.59863 34.6496 7.37305V7.36328C34.6496 6.1377 35.2209 5.39551 36.1828 5.39551C37.1398 5.39551 37.7258 6.14746 37.7258 7.36328V7.37305C37.7258 8.58887 37.1398 9.34082 36.1828 9.34082ZM45.2164 10.0928C46.5494 10.0928 47.4234 9.01367 47.4234 7.37305V7.36328C47.4234 5.71289 46.5543 4.64355 45.2164 4.64355C44.4938 4.64355 43.8639 5.00488 43.5758 5.56641H43.4977V2.64648H42.648V10H43.4977V9.16016H43.5758C43.898 9.74609 44.484 10.0928 45.2164 10.0928ZM45.0211 9.34082C44.0641 9.34082 43.4781 8.58887 43.4781 7.37305V7.36328C43.4781 6.14746 44.0641 5.39551 45.0211 5.39551C45.983 5.39551 46.5543 6.1377 46.5543 7.36328V7.37305C46.5543 8.59863 45.983 9.34082 45.0211 9.34082ZM48.7957 11.8457C49.7283 11.8457 50.1629 11.5039 50.5975 10.3223L52.6531 4.73633H51.7596L50.3191 9.06738H50.241L48.7957 4.73633H47.8875L49.8357 10.0049L49.7381 10.3174C49.5477 10.9229 49.2547 11.1426 48.7713 11.1426C48.6541 11.1426 48.5223 11.1377 48.4197 11.1182V11.8164C48.5369 11.8359 48.6834 11.8457 48.7957 11.8457Z"+ fill="currentColor"+ ></path>+ <g opacity="0.6">+ <path+ d="M78.42 6.9958C78.42 9.15638 77.085 10.4444 75.2379 10.4444C74.2164 10.4444 73.3269 10.0276 72.9206 9.33816V12.9166H71.4929V3.65235H72.8018L72.9193 4.66772C73.3256 3.97825 74.189 3.5225 75.2366 3.5225C77.017 3.5225 78.4186 4.75861 78.4186 6.9971L78.42 6.9958ZM76.94 6.9958C76.94 5.62985 76.1288 4.78328 74.9492 4.78328C73.8232 4.77029 72.9598 5.62855 72.9598 7.00878C72.9598 8.38901 73.8246 9.18235 74.9492 9.18235C76.0739 9.18235 76.94 8.36304 76.94 6.9958Z"+ fill="currentColor"+ ></path>+ <path+ d="M86.0132 7.3736H80.8809C80.9071 8.62268 81.7313 9.2732 82.7789 9.2732C83.564 9.2732 84.2197 8.90834 84.494 8.17992H85.9479C85.5939 9.53288 84.3895 10.4444 82.7528 10.4444C80.749 10.4444 79.4271 9.06545 79.4271 6.96978C79.4271 4.87412 80.749 3.50818 82.7397 3.50818C84.7305 3.50818 86.0132 4.83517 86.0132 6.83994V7.3736ZM80.894 6.38419H84.5594C84.481 5.226 83.709 4.6404 82.7397 4.6404C81.7705 4.6404 80.9985 5.226 80.894 6.38419Z"+ fill="currentColor"+ ></path>+ <path+ d="M88.5407 3.65204C87.8745 3.65204 87.335 4.18829 87.335 4.85048V10.3156H88.7758V5.22703C88.7758 5.06213 88.9104 4.92709 89.0776 4.92709H91.2773V3.65204H88.5407Z"+ fill="currentColor"+ ></path>+ -+ <path+ d="M69.1899 3.63908L67.3442 9.17039L65.3535 3.65207H63.8082L66.3606 10.2247C66.439 10.4325 66.4782 10.6026 66.4782 10.7713C66.4782 10.8635 66.469 10.9479 66.4533 11.0258L66.4494 11.0401C66.4403 11.0817 66.4298 11.1206 66.4168 11.1583L66.3201 11.5102C66.2966 11.5971 66.2169 11.6569 66.1268 11.6569H64.0956V12.9189H65.5755C66.5709 12.9189 67.3952 12.6852 67.8667 11.3829L70.6817 3.65207L69.1886 3.63908H69.1899Z"+ fill="currentColor"+ ></path>+ <path+ d="M57 10.3144H58.4264V6.72299C58.4264 5.60375 59.0417 4.82339 60.1807 4.82339C61.1761 4.81041 61.7913 5.396 61.7913 6.68404V10.3144H63.2191V6.46201C63.2191 4.18457 61.8188 3.50809 60.5478 3.50809C59.5785 3.50809 58.8196 3.88593 58.4264 4.51047V0.919022H57V10.3144Z"+ fill="currentColor"+ ></path>+ <path+ d="M93.1623 8.29808C93.1753 8.98755 93.8167 9.39136 94.6945 9.39136C95.5723 9.39136 96.0948 9.06545 96.0948 8.47986C96.0948 7.97218 95.8336 7.69951 95.0733 7.58135L93.7253 7.34763C92.4164 7.1269 91.9057 6.44912 91.9057 5.49997C91.9057 4.30282 93.097 3.52246 94.6161 3.52246C96.2529 3.52246 97.4442 4.30282 97.4572 5.63111H96.0439C96.0308 4.95463 95.4417 4.57679 94.6174 4.57679C93.7932 4.57679 93.3347 4.90269 93.3347 5.44933C93.3347 5.93105 93.6756 6.15178 94.4215 6.28162L95.7434 6.51534C96.987 6.73607 97.563 7.34763 97.563 8.35002C97.563 9.72895 96.2803 10.4457 94.722 10.4457C92.9546 10.4457 91.7633 9.60041 91.7372 8.29808H93.1649H93.1623Z"+ fill="currentColor"+ ></path>+ <path+ d="M100.808 8.75352L102.327 3.652H103.82L105.313 8.75352L106.583 3.652H108.089L106.191 10.3155H104.58L103.061 5.23997L101.529 10.3155H99.9052L97.9941 3.652H99.5002L100.809 8.75352H100.808Z"+ fill="currentColor"+ ></path>+ <path+ d="M108.926 0.918945H110.511V2.40305H108.926V0.918945ZM109.005 3.65214H110.431V10.3157H109.005V3.65214Z"+ fill="currentColor"+ ></path>+ <path+ d="M119.504 4.7452C118.391 4.7452 117.632 5.55152 117.632 6.9707C117.632 8.46779 118.417 9.19621 119.465 9.19621C120.302 9.19621 120.919 8.72748 121.193 7.84325H122.712C122.371 9.45719 121.141 10.4466 119.491 10.4466C117.502 10.4466 116.165 9.06767 116.165 6.972C116.165 4.87634 117.5 3.51039 119.504 3.51039C121.141 3.51039 122.358 4.43487 122.712 6.04752H121.167C120.932 5.21523 120.289 4.7465 119.504 4.7465V4.7452Z"+ fill="currentColor"+ ></path>+ <path+ d="M113.959 9.05208C113.875 9.05208 113.809 8.98456 113.809 8.90276V4.91399H115.367V3.65191H113.809V1.86787H112.382V3.02607C112.382 3.44287 112.252 3.65062 111.833 3.65062H111.256V4.91269H112.382V8.50414C112.382 9.66234 113.024 10.3128 114.189 10.3128H115.354V9.05078H113.96L113.959 9.05208Z"+ fill="currentColor"+ ></path>+ <path+ d="M127.329 3.50801C126.359 3.50801 125.601 3.88585 125.207 4.5104V0.918945H123.781V10.3144H125.207V6.72292C125.207 5.60367 125.823 4.82332 126.962 4.82332C127.957 4.81033 128.572 5.39592 128.572 6.68397V10.3144H130V6.46193C130 4.18449 128.6 3.50801 127.329 3.50801Z"+ fill="currentColor"+ ></path>+ </g>+ </svg>+ </div>+ </body>++ <script>+ {{ payment_details_js_script }}++ window.state = {+ prevHeight: window.innerHeight,+ prevWidth: window.innerWidth,+ isMobileView: window.innerWidth <= 1200,+ }++ var widgets = null;++ window.__PAYMENT_DETAILS = {};+ try {+ window.__PAYMENT_DETAILS = JSON.parse(window.__PAYMENT_DETAILS_STR);+ } catch (error) {+ console.error("Failed to parse payment details");+ }++ async function initialize() {+ const paymentDetails = window.__PAYMENT_DETAILS;+ var client_secret = paymentDetails.client_secret;+ const appearance = {+ variables: {+ colorPrimary: "rgb(0, 109, 249)",+ fontFamily: "Work Sans, sans-serif",+ fontSizeBase: "16px",+ colorText: "rgb(51, 65, 85)",+ colorTextSecondary: "#334155B3",+ colorPrimaryText: "rgb(51, 65, 85)",+ colorTextPlaceholder: "#33415550",+ borderColor: "#33415550",+ colorBackground: "rgb(255, 255, 255)",+ },+ };++ widgets = hyper.widgets({+ appearance,+ clientSecret: client_secret,+ });++ const unifiedCheckoutOptions = {+ layout: "tabs",+ wallets: {+ walletReturnUrl: paymentDetails.return_url,+ style: {+ theme: "dark",+ type: "default",+ height: 55,+ },+ },+ };++ const unifiedCheckout = widgets.create("payment", unifiedCheckoutOptions);+ unifiedCheckout.mount("#unified-checkout");+ }+ initialize();++ async function handleSubmit(e) {+ setLoading(true);+ const paymentDetails = window.__PAYMENT_DETAILS;+ const { error, data, status } = await hyper.confirmPayment({+ widgets,+ confirmParams: {+ // Make sure to change this to your payment completion page+ return_url: paymentDetails.return_url,+ },+ });+ // This point will only be reached if there is an immediate error occurring while confirming the payment. Otherwise, your customer will be redirected to your `return_url`.+ // For some payment flows such as Sofort, iDEAL, your customer will be redirected to an intermediate page to complete authorization of the payment, and then redirected to the `return_url`.++ if (error) {+ if (error.type === "validation_error") {+ showMessage(error.message);+ } else {+ showMessage("An unexpected error occurred.");+ }+ } else {+ const { paymentIntent } = await hyper.retrievePaymentIntent(+ paymentDetails.client_secret+ );+ if (paymentIntent && paymentIntent.status) {+ hide("#hyper-checkout-sdk");+ hide("#hyper-checkout-details");+ show("#hyper-checkout-status");+ show("#hyper-footer");+ showStatus(paymentIntent);+ }+ }++ setLoading(false);+ }++ // Fetches the payment status after payment submission+ async function checkStatus() {+ const clientSecret = new URLSearchParams(window.location.search).get(+ "payment_intent_client_secret"+ );+ const res = {+ showSdk: true,+ };++ if (!clientSecret) {+ return res;+ }++ const { paymentIntent } = await hyper.retrievePaymentIntent(clientSecret);++ if (!paymentIntent || !paymentIntent.status) {+ return res;+ }++ showStatus(paymentIntent);+ res.showSdk = false;++ return res;+ }++ function setPageLoading(showLoader) {+ if (showLoader) {+ show(".page-spinner");+ } else {+ hide(".page-spinner");+ }+ }++ function setLoading(showLoader) {+ if (showLoader) {+ show(".spinner");+ hide("#button-text");+ } else {+ hide(".spinner");+ show("#button-text");+ }+ }++ function show(id) {+ removeClass(id, "hidden");+ }+ function hide(id) {+ addClass(id, "hidden");+ }++ function showMessage(msg) {+ show("#payment-message");+ addText("#payment-message", msg);+ }+ function showStatus(paymentDetails) {+ const status = paymentDetails.status;+ let statusDetails = {+ imageSource: "",+ message: "",+ status: status,+ amountText: "",+ items: [],+ };++ switch (status) {+ case "succeeded":+ statusDetails.imageSource =+ "http://www.clipartbest.com/cliparts/4ib/oRa/4iboRa7RT.png";+ statusDetails.message = "Payment successful";+ statusDetails.status = "Succeeded";+ statusDetails.amountText = new Date(+ paymentDetails.created+ ).toTimeString();++ // Payment details+ var amountNode = createItem(+ "AMOUNT PAID",+ paymentDetails.currency + " " + paymentDetails.amount+ );+ var paymentId = createItem("PAYMENT ID", paymentDetails.payment_id);+ // @ts-ignore+ statusDetails.items.push(amountNode, paymentId);+ break;++ case "processing":+ statusDetails.imageSource =+ "http://www.clipartbest.com/cliparts/4ib/oRa/4iboRa7RT.png";+ statusDetails.message = "Payment in progress";+ statusDetails.status = "Processing";+ // Payment details+ var amountNode = createItem(+ "AMOUNT PAID",+ paymentDetails.currency + " " + paymentDetails.amount+ );+ var paymentId = createItem("PAYMENT ID", paymentDetails.payment_id);+ // @ts-ignore+ statusDetails.items.push(amountNode, paymentId);+ break;++ case "failed":+ statusDetails.imageSource = "";+ statusDetails.message = "Payment failed";+ statusDetails.status = "Failed";+ // Payment details+ var amountNode = createItem(+ "AMOUNT PAID",+ paymentDetails.currency + " " + paymentDetails.amount+ );+ var paymentId = createItem("PAYMENT ID", paymentDetails.payment_id);+ // @ts-ignore+ statusDetails.items.push(amountNode, paymentId);+ break;++ case "cancelled":+ statusDetails.imageSource = "";+ statusDetails.message = "Payment cancelled";+ statusDetails.status = "Cancelled";+ // Payment details+ var amountNode = createItem(+ "AMOUNT PAID",+ paymentDetails.currency + " " + paymentDetails.amount+ );+ var paymentId = createItem("PAYMENT ID", paymentDetails.payment_id);+ // @ts-ignore+ statusDetails.items.push(amountNode, paymentId);+ break;++ case "requires_merchant_action":+ statusDetails.imageSource = "";+ statusDetails.message = "Payment under review";+ statusDetails.status = "Under review";+ // Payment details+ var amountNode = createItem(+ "AMOUNT PAID",+ paymentDetails.currency + " " + paymentDetails.amount+ );+ var paymentId = createItem("PAYMENT ID", paymentDetails.payment_id);+ var paymentId = createItem(+ "MESSAGE",+ "Your payment is under review by the merchant."+ );+ // @ts-ignore+ statusDetails.items.push(amountNode, paymentId);+ break;++ default:+ statusDetails.imageSource =+ "http://www.clipartbest.com/cliparts/4ib/oRa/4iboRa7RT.png";+ statusDetails.message = "Something went wrong";+ statusDetails.status = "Something went wrong";+ // Error details+ if (typeof paymentDetails.error === "object") {+ var errorCodeNode = createItem(+ "ERROR CODE",+ paymentDetails.error.code+ );+ var errorMessageNode = createItem(+ "ERROR MESSAGE",+ paymentDetails.error.message+ );+ // @ts-ignore+ statusDetails.items.push(errorMessageNode, errorCodeNode);+ }+ break;+ }++ // Append status+ var statusTextNode = document.getElementById("status-text");+ if (statusTextNode !== null) {+ statusTextNode.innerText = statusDetails.message;+ }++ // Append image+ var statusImageNode = document.getElementById("status-img");+ if (statusImageNode !== null) {+ statusImageNode.src = statusDetails.imageSource;+ }++ // Append status details+ var statusDateNode = document.getElementById("status-date");+ if (statusDateNode !== null) {+ statusDateNode.innerText = statusDetails.amountText;+ }++ // Append items+ var statusItemNode = document.getElementById(+ "hyper-checkout-status-items"+ );+ if (statusItemNode !== null) {+ statusDetails.items.map((item) => statusItemNode?.append(item));+ }+ }++ function createItem(heading, value) {+ var itemNode = document.createElement("div");+ itemNode.className = "hyper-checkout-item";+ var headerNode = document.createElement("div");+ headerNode.className = "hyper-checkout-item-header";+ headerNode.innerText = heading;+ var valueNode = document.createElement("div");+ valueNode.className = "hyper-checkout-item-value";+ valueNode.innerText = value;+ itemNode.append(headerNode);+ itemNode.append(valueNode);+ return itemNode;+ }++ function addText(id, msg) {+ var element = document.querySelector(id);+ element.innerText = msg;+ }++ function addClass(id, className) {+ var element = document.querySelector(id);+ element.classList.add(className);+ }++ function removeClass(id, className) {+ var element = document.querySelector(id);+ element.classList.remove(className);+ }++ function renderPaymentDetails() {+ const paymentDetails = window.__PAYMENT_DETAILS;++ // Create price node+ var priceNode = document.createElement("div");+ priceNode.className = "hyper-checkout-payment-price";+ priceNode.innerText =+ paymentDetails.currency_symbol + paymentDetails.amount;++ // Create merchant name's node+ var merchantNameNode = document.createElement("div");+ merchantNameNode.className = "hyper-checkout-payment-merchant-name";+ merchantNameNode.innerText = "Requested by " + paymentDetails.merchant;++ // Create payment ID node+ var paymentIdNode = document.createElement("div");+ paymentIdNode.className = "hyper-checkout-payment-ref";+ paymentIdNode.innerText = "Ref Id: " + paymentDetails.payment_id;++ // Create merchant logo's node+ var merchantLogoNode = document.createElement("img");+ merchantLogoNode.src = paymentDetails.merchant_logo;++ // Create expiry node+ var paymentExpiryNode = document.createElement("div");+ paymentExpiryNode.className = "hyper-checkout-payment-footer-expiry";+ paymentExpiryNode.innerText =+ "Link expires on: " + new Date(paymentDetails.expiry).toTimeString();++ // Append information to DOM+ var paymentContextNode = document.getElementById(+ "hyper-checkout-payment-context"+ );+ paymentContextNode.prepend(priceNode);+ var paymentMerchantDetails = document.getElementById(+ "hyper-checkout-payment-merchant-details"+ );+ paymentMerchantDetails.append(merchantNameNode);+ paymentMerchantDetails.append(paymentIdNode);+ var merchantImageNode = document.getElementById(+ "hyper-checkout-merchant-image"+ );+ merchantImageNode.prepend(merchantLogoNode);+ var footerNode = document.getElementById("hyper-checkout-payment-footer");+ footerNode.append(paymentExpiryNode);+ }++ function renderCart() {+ const paymentDetails = window.__PAYMENT_DETAILS;+ const orderDetails = paymentDetails.order_details;+ var cartNode = document.getElementById("hyper-checkout-cart");+ var cartItemsNode = document.getElementById("hyper-checkout-cart-items");++ const MAX_ITEMS_VISIBLE_AFTER_COLLAPSE =+ paymentDetails.max_items_visible_after_collapse;++ // Cart items+ if (Array.isArray(orderDetails)) {+ orderDetails.map((item, index) => {+ // Wrappers+ var itemWrapperNode = document.createElement("div");+ itemWrapperNode.className = `${+ index >= MAX_ITEMS_VISIBLE_AFTER_COLLAPSE ? "hidden " : ""+ }hyper-checkout-cart-item`;+ var nameAndQuantityWrapperNode = document.createElement("div");+ nameAndQuantityWrapperNode.className =+ "hyper-checkout-cart-product-details";++ // Image+ var productImageNode = document.createElement("img");+ productImageNode.className = "hyper-checkout-cart-product-image";+ productImageNode.src = item.product_image;+ // Product title+ var productNameNode = document.createElement("div");+ productNameNode.className = "hyper-checkout-card-item-name";+ productNameNode.innerText = item.product_name;+ // Product quantity+ var quantityNode = document.createElement("div");+ quantityNode.className = "hyper-checkout-card-item-quantity";+ quantityNode.innerText = "Qty: " + item.quantity;+ // Product price+ var priceNode = document.createElement("div");+ priceNode.className = "hyper-checkout-card-item-price";+ priceNode.innerText = paymentDetails.currency_symbol + item.amount;+ // Divider node+ var dividerNode = document.createElement("div");+ dividerNode.className = `${+ index !== 0 && index < MAX_ITEMS_VISIBLE_AFTER_COLLAPSE+ ? ""+ : "hidden "+ }hyper-checkout-cart-item-divider`;+ // Append items+ nameAndQuantityWrapperNode.append(productNameNode, quantityNode);+ itemWrapperNode.append(+ productImageNode,+ nameAndQuantityWrapperNode,+ priceNode+ );+ cartItemsNode.append(dividerNode, itemWrapperNode);+ });+ }++ // Expand / collapse button+ const totalItems = orderDetails.length;+ if (totalItems > MAX_ITEMS_VISIBLE_AFTER_COLLAPSE) {+ var expandButtonNode = document.createElement("div");+ expandButtonNode.className = "hyper-checkout-cart-button";+ expandButtonNode.onclick = handleCartView;+ var buttonImageNode = document.createElement("img");+ var buttonTextNode = document.createElement("span");+ buttonTextNode.id = "hyper-checkout-cart-button-text";+ const hiddenItemsCount =+ orderDetails.length - MAX_ITEMS_VISIBLE_AFTER_COLLAPSE;+ buttonTextNode.innerText = `Show More (${hiddenItemsCount})`;+ expandButtonNode.append(buttonTextNode, buttonImageNode);+ cartNode.append(expandButtonNode);+ }+ }++ function handleCartView() {+ const paymentDetails = window.__PAYMENT_DETAILS;+ const orderDetails = paymentDetails.order_details;+ const MAX_ITEMS_VISIBLE_AFTER_COLLAPSE =+ paymentDetails.max_items_visible_after_collapse;+ var itemsHTMLCollection = document.getElementsByClassName(+ "hyper-checkout-cart-item"+ );+ var dividerHTMLCollection = document.getElementsByClassName(+ "hyper-checkout-cart-item-divider"+ );+ var cartItems = [].slice.call(itemsHTMLCollection);+ var dividerItems = [].slice.call(dividerHTMLCollection);+ var isHidden = false;+ cartItems.map((item) => {+ isHidden = item.classList.contains("hidden");+ });++ cartItems.map((item, index) => {+ if (index >= MAX_ITEMS_VISIBLE_AFTER_COLLAPSE) {+ item.className = `${+ isHidden ? "" : "hidden "+ }hyper-checkout-cart-item`;+ }+ });+ dividerItems.map((divider, index) => {+ if (index >= MAX_ITEMS_VISIBLE_AFTER_COLLAPSE) {+ divider.className = `${+ isHidden ? "" : "hidden "+ }hyper-checkout-cart-item-divider`;+ }+ });++ var cartButtonTextNode = document.getElementById(+ "hyper-checkout-cart-button-text"+ );+ const hiddenItemsCount =+ orderDetails.length - MAX_ITEMS_VISIBLE_AFTER_COLLAPSE;+ cartButtonTextNode.innerText = isHidden+ ? "Show Less"+ : `Show More (${hiddenItemsCount})`;+ }++ function hideCartInMobileView() {+ window.history.back();+ hide("#hyper-checkout-cart");+ }++ function viewCartInMobileView() {+ show("#hyper-checkout-cart");+ window.history.pushState("view-cart", "");+ }++ function renderSDKHeader() {+ const paymentDetails = window.__PAYMENT_DETAILS;++ // SDK headers' items+ var sdkHeaderItemNode = document.createElement("div");+ sdkHeaderItemNode.className = "hyper-checkout-sdk-items";+ var sdkHeaderMerchantNameNode = document.createElement("div");+ sdkHeaderMerchantNameNode.className =+ "hyper-checkout-sdk-header-brand-name";+ sdkHeaderMerchantNameNode.innerText = paymentDetails.merchant;+ var sdkHeaderAmountNode = document.createElement("div");+ sdkHeaderAmountNode.className = "hyper-checkout-sdk-header-amount";+ sdkHeaderAmountNode.innerText =+ paymentDetails.currency + " " + paymentDetails.amount;+ sdkHeaderItemNode.append(sdkHeaderMerchantNameNode);+ sdkHeaderItemNode.append(sdkHeaderAmountNode);++ // Append to SDK header's node+ var sdkHeaderNode = document.getElementById("hyper-checkout-sdk-header");+ if (sdkHeaderNode !== null) {+ sdkHeaderNode.append(sdkHeaderLogoNode);+ sdkHeaderNode.append(sdkHeaderItemNode);+ }+ }++ function showSDK(e) {+ if (window.state.isMobileView) {+ hide("#hyper-checkout-cart");+ } else {+ show("#hyper-checkout-cart");+ }+ setPageLoading(true);+ checkStatus()+ .then((res) => {+ if (res.showSdk) {+ renderPaymentDetails();+ renderCart();+ renderSDKHeader();+ show("#hyper-checkout-sdk");+ show("#hyper-checkout-details");+ } else {+ show("#hyper-checkout-status");+ show("#hyper-footer");+ }+ })+ .catch((err) => {})+ .finally(() => {+ setPageLoading(false);+ });+ }++ window.addEventListener("resize", (event) => {+ const currentHeight = window.innerHeight;+ const currentWidth = window.innerWidth;++ if (currentWidth <= 1200 && window.state.prevWidth > 1200) {+ hide("#hyper-checkout-cart");+ } else if (currentWidth > 1200 && window.state.prevWidth <= 1200) {+ show("#hyper-checkout-cart");+ }++ window.state.prevHeight = currentHeight;+ window.state.prevWidth = currentWidth;+ window.state.isMobileView = currentWidth <= 1200;+ });+ </script>+</html>diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 14b97fec42..39c709687d 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -1486,6 +1486,7 @@ wherepub redirect_response: Option<api_models::payments::RedirectResponse>,pub surcharge_details: Option<SurchargeDetailsResponse>,pub frm_message: Option<FraudCheck>,+ pub payment_link_data: Option<api_models::payments::PaymentLinkResponse>,}#[derive(Debug, Default, Clone)]diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex a4cb7b2b9e..c513ed02ae 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -2194,6 +2194,26 @@ pub fn authenticate_client_secret(}}+pub async fn get_merchant_fullfillment_time(+ payment_link_id: Option<String>,+ intent_fulfillment_time: Option<i64>,+ db: &dyn StorageInterface,+) -> RouterResult<Option<i64>> {+ if let Some(payment_link_id) = payment_link_id {+ let payment_link_db = db+ .find_payment_link_by_payment_link_id(&payment_link_id)+ .await+ .to_not_found_response(errors::ApiErrorResponse::PaymentLinkNotFound)?;++ let curr_time = common_utils::date_time::now();+ Ok(payment_link_db+ .fulfilment_time+ .map(|merchant_expiry_time| (merchant_expiry_time - curr_time).whole_seconds()))+ } else {+ Ok(intent_fulfillment_time)+ }+}+pub(crate) fn validate_payment_status_against_not_allowed_statuses(intent_status: &storage_enums::IntentStatus,not_allowed_statuses: &[storage_enums::IntentStatus],@@ -2252,11 +2272,14 @@ pub async fn verify_payment_intent_time_and_client_secret(.await.change_context(errors::ApiErrorResponse::PaymentNotFound)?;- authenticate_client_secret(- Some(&cs),- &payment_intent,+ let intent_fulfillment_time = get_merchant_fullfillment_time(+ payment_intent.payment_link_id.clone(),merchant_account.intent_fulfillment_time,- )?;+ db,+ )+ .await?;++ authenticate_client_secret(Some(&cs), &payment_intent, intent_fulfillment_time)?;Ok(payment_intent)}).await@@ -2377,6 +2400,7 @@ mod tests {connector_metadata: None,feature_metadata: None,attempt_count: 1,+ payment_link_id: None,profile_id: None,merchant_decision: None,payment_confirm_source: None,@@ -2386,7 +2410,7 @@ mod tests {assert!(authenticate_client_secret(req_cs.as_ref(),&payment_intent,- merchant_fulfillment_time+ merchant_fulfillment_time,).is_ok()); // Check if the result is an Ok variant}@@ -2424,6 +2448,7 @@ mod tests {connector_metadata: None,feature_metadata: None,attempt_count: 1,+ payment_link_id: None,profile_id: None,merchant_decision: None,payment_confirm_source: None,@@ -2433,7 +2458,7 @@ mod tests {assert!(authenticate_client_secret(req_cs.as_ref(),&payment_intent,- merchant_fulfillment_time+ merchant_fulfillment_time,).is_err())}@@ -2471,6 +2496,7 @@ mod tests {connector_metadata: None,feature_metadata: None,attempt_count: 1,+ payment_link_id: None,profile_id: None,merchant_decision: None,payment_confirm_source: None,@@ -2480,7 +2506,7 @@ mod tests {assert!(authenticate_client_secret(req_cs.as_ref(),&payment_intent,- merchant_fulfillment_time+ merchant_fulfillment_time,).is_err())}@@ -3380,3 +3406,24 @@ impl ApplePayData {Ok(decrypted)}}++pub fn validate_payment_link_request(+ payment_link_object: &api_models::payments::PaymentLinkObject,+ confirm: Option<bool>,+) -> Result<(), errors::ApiErrorResponse> {+ if let Some(cnf) = confirm {+ if !cnf {+ let current_time = Some(common_utils::date_time::now());+ if current_time > payment_link_object.link_expiry {+ return Err(errors::ApiErrorResponse::InvalidRequestData {+ message: "link_expiry time cannot be less than current time".to_string(),+ });+ }+ } else {+ return Err(errors::ApiErrorResponse::InvalidRequestData {+ message: "cannot confirm a payment while creating a payment link".to_string(),+ });+ }+ }+ Ok(())+}diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rsindex edb6478efe..95995c46bf 100644--- a/crates/router/src/core/payments/operations/payment_approve.rs+++ b/crates/router/src/core/payments/operations/payment_approve.rs@@ -253,6 +253,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>redirect_response,surcharge_details: None,frm_message: frm_response.ok(),+ payment_link_data: None,},Some(CustomerDetails {customer_id: request.customer_id.clone(),diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rsindex d92d86e792..cd221c0be7 100644--- a/crates/router/src/core/payments/operations/payment_cancel.rs+++ b/crates/router/src/core/payments/operations/payment_cancel.rs@@ -173,6 +173,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>redirect_response: None,surcharge_details: None,frm_message: None,+ payment_link_data: None,},None,))diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rsindex eb88265bfc..0d5dd5c774 100644--- a/crates/router/src/core/payments/operations/payment_capture.rs+++ b/crates/router/src/core/payments/operations/payment_capture.rs@@ -231,6 +231,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>redirect_response: None,surcharge_details: None,frm_message: None,+ payment_link_data: None,},None,))diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rsindex 0296529022..25143df386 100644--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs@@ -248,6 +248,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>redirect_response,surcharge_details: None,frm_message: None,+ payment_link_data: None,},Some(CustomerDetails {customer_id: request.customer_id.clone(),diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex a40de370b3..86304cbf17 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -88,10 +88,17 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>"confirm",)?;+ let intent_fulfillment_time = helpers::get_merchant_fullfillment_time(+ payment_intent.payment_link_id.clone(),+ merchant_account.intent_fulfillment_time,+ db,+ )+ .await?;+helpers::authenticate_client_secret(request.client_secret.as_ref(),&payment_intent,- merchant_account.intent_fulfillment_time,+ intent_fulfillment_time,)?;let customer_details = helpers::get_customer_details_from_request(request);@@ -361,6 +368,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>redirect_response: None,surcharge_details: None,frm_message: None,+ payment_link_data: None,},Some(customer_details),))diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 0be9241818..aec9a13f03 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -70,6 +70,21 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>.get_payment_intent_id().change_context(errors::ApiErrorResponse::PaymentNotFound)?;+ let payment_link_data = if let Some(payment_link_object) = &request.payment_link_object {+ create_payment_link(+ request,+ payment_link_object.clone(),+ merchant_id.clone(),+ payment_id.clone(),+ db,+ state,+ amount,+ )+ .await?+ } else {+ None+ };+helpers::validate_business_details(request.business_country,request.business_label.as_ref(),@@ -147,6 +162,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>money,request,shipping_address.clone().map(|x| x.address_id),+ payment_link_data.clone(),billing_address.clone().map(|x| x.address_id),attempt_id,state,@@ -239,7 +255,6 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>request.confirm,self,);-let creds_identifier = request.merchant_connector_details.as_ref()@@ -296,6 +311,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>redirect_response: None,surcharge_details: None,frm_message: None,+ payment_link_data,},Some(customer_details),))@@ -431,6 +447,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;let customer_id = payment_data.payment_intent.customer_id.clone();+payment_data.payment_intent = db.update_payment_intent(payment_data.payment_intent,@@ -447,7 +464,6 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;// payment_data.mandate_id = response.and_then(|router_data| router_data.request.mandate_id);-Ok((payments::is_confirm(self, payment_data.confirm),payment_data,@@ -469,6 +485,10 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve> ValidateRequest<F, api::Paymen)> {helpers::validate_customer_details_in_request(request)?;+ if let Some(payment_link_object) = &request.payment_link_object {+ helpers::validate_payment_link_request(payment_link_object, request.confirm)?;+ }+let given_payment_id = match &request.payment_id {Some(id_type) => Some(id_type@@ -615,6 +635,7 @@ impl PaymentCreate {money: (api::Amount, enums::Currency),request: &api::PaymentsRequest,shipping_address_id: Option<String>,+ payment_link_data: Option<api_models::payments::PaymentLinkResponse>,billing_address_id: Option<String>,active_attempt_id: String,state: &AppState,@@ -657,6 +678,8 @@ impl PaymentCreate {.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Error converting feature_metadata to Value")?;+ let payment_link_id = payment_link_data.map(|pl_data| pl_data.payment_link_id);+Ok(storage::PaymentIntentNew {payment_id: payment_id.to_string(),merchant_id: merchant_account.merchant_id.to_string(),@@ -689,6 +712,7 @@ impl PaymentCreate {attempt_count: 1,profile_id: Some(profile_id),merchant_decision: None,+ payment_link_id,payment_confirm_source: None,})}@@ -744,3 +768,50 @@ pub fn payments_create_request_validation(let amount = req.amount.get_required_value("amount")?;Ok((amount, currency))}++async fn create_payment_link(+ request: &api::PaymentsRequest,+ payment_link_object: api_models::payments::PaymentLinkObject,+ merchant_id: String,+ payment_id: String,+ db: &dyn StorageInterface,+ state: &AppState,+ amount: api::Amount,+) -> RouterResult<Option<api_models::payments::PaymentLinkResponse>> {+ let created_at @ last_modified_at = Some(common_utils::date_time::now());+ let domain = if let Some(domain_name) = payment_link_object.merchant_custom_domain_name {+ format!("https://{domain_name}")+ } else {+ state.conf.server.base_url.clone()+ };++ let payment_link_id = utils::generate_id(consts::ID_LENGTH, "plink");+ let payment_link = format!(+ "{}/payment_link/{}/{}",+ domain,+ merchant_id.clone(),+ payment_id.clone()+ );+ let payment_link_req = storage::PaymentLinkNew {+ payment_link_id: payment_link_id.clone(),+ payment_id: payment_id.clone(),+ merchant_id: merchant_id.clone(),+ link_to_pay: payment_link.clone(),+ amount: amount.into(),+ currency: request.currency,+ created_at,+ last_modified_at,+ fulfilment_time: payment_link_object.link_expiry,+ };+ let payment_link_db = db+ .insert_payment_link(payment_link_req)+ .await+ .to_duplicate_response(errors::ApiErrorResponse::GenericDuplicateError {+ message: "payment link already exists!".to_string(),+ })?;++ Ok(Some(api_models::payments::PaymentLinkResponse {+ link: payment_link_db.link_to_pay,+ payment_link_id: payment_link_db.payment_link_id,+ }))+}diff --git a/crates/router/src/core/payments/operations/payment_method_validate.rs b/crates/router/src/core/payments/operations/payment_method_validate.rsindex 1b33f2dddb..77e0a7dce2 100644--- a/crates/router/src/core/payments/operations/payment_method_validate.rs+++ b/crates/router/src/core/payments/operations/payment_method_validate.rs@@ -197,6 +197,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>redirect_response: None,surcharge_details: None,frm_message: None,+ payment_link_data: None,},Some(payments::CustomerDetails {customer_id: request.customer_id.clone(),diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rsindex 2e9bd3eb9e..938ce92af2 100644--- a/crates/router/src/core/payments/operations/payment_reject.rs+++ b/crates/router/src/core/payments/operations/payment_reject.rs@@ -159,6 +159,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>redirect_response: None,surcharge_details: None,frm_message: frm_response.ok(),+ payment_link_data: None,},None,))diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rsindex cc91482440..1decf13b37 100644--- a/crates/router/src/core/payments/operations/payment_session.rs+++ b/crates/router/src/core/payments/operations/payment_session.rs@@ -70,11 +70,19 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>"create a session token for",)?;+ let intent_fulfillment_time = helpers::get_merchant_fullfillment_time(+ payment_intent.payment_link_id.clone(),+ merchant_account.intent_fulfillment_time,+ db,+ )+ .await?;+helpers::authenticate_client_secret(Some(&request.client_secret),&payment_intent,- merchant_account.intent_fulfillment_time,+ intent_fulfillment_time,)?;+let mut payment_attempt = db.find_payment_attempt_by_payment_id_merchant_id_attempt_id(payment_intent.payment_id.as_str(),@@ -193,6 +201,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>redirect_response: None,surcharge_details: None,frm_message: None,+ payment_link_data: None,},Some(customer_details),))diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rsindex 4979b7902c..c3462079cb 100644--- a/crates/router/src/core/payments/operations/payment_start.rs+++ b/crates/router/src/core/payments/operations/payment_start.rs@@ -70,10 +70,17 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>"update",)?;+ let intent_fulfillment_time = helpers::get_merchant_fullfillment_time(+ payment_intent.payment_link_id.clone(),+ merchant_account.intent_fulfillment_time,+ db,+ )+ .await?;+helpers::authenticate_client_secret(payment_intent.client_secret.as_ref(),&payment_intent,- merchant_account.intent_fulfillment_time,+ intent_fulfillment_time,)?;payment_attempt = db.find_payment_attempt_by_payment_id_merchant_id_attempt_id(@@ -168,6 +175,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>redirect_response: None,surcharge_details: None,frm_message: None,+ payment_link_data: None,},Some(customer_details),))diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rsindex c2762a9666..ed642d3c46 100644--- a/crates/router/src/core/payments/operations/payment_status.rs+++ b/crates/router/src/core/payments/operations/payment_status.rs@@ -235,11 +235,18 @@ async fn get_tracker_for_sync<).await?;+ let intent_fulfillment_time = helpers::get_merchant_fullfillment_time(+ payment_intent.payment_link_id.clone(),+ merchant_account.intent_fulfillment_time,+ db,+ )+ .await?;helpers::authenticate_client_secret(request.client_secret.as_ref(),&payment_intent,- merchant_account.intent_fulfillment_time,+ intent_fulfillment_time,)?;+let payment_id_str = payment_attempt.payment_id.clone();let mut connector_response = db@@ -402,6 +409,7 @@ async fn get_tracker_for_sync<ephemeral_key: None,multiple_capture_data,redirect_response: None,+ payment_link_data: None,surcharge_details: None,frm_message: frm_response.ok(),},diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rsindex 1c7b432c32..12c065c53e 100644--- a/crates/router/src/core/payments/operations/payment_update.rs+++ b/crates/router/src/core/payments/operations/payment_update.rs@@ -82,10 +82,17 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>"update",)?;+ let intent_fulfillment_time = helpers::get_merchant_fullfillment_time(+ payment_intent.payment_link_id.clone(),+ merchant_account.intent_fulfillment_time,+ db,+ )+ .await?;+helpers::authenticate_client_secret(request.client_secret.as_ref(),&payment_intent,- merchant_account.intent_fulfillment_time,+ intent_fulfillment_time,)?;let (token,@@ -347,6 +354,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>redirect_response: None,surcharge_details: None,frm_message: None,+ payment_link_data: None,},Some(customer_details),))diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex f93b2e9ff4..ac15401a33 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -353,6 +353,7 @@ where{let payment_attempt = payment_data.payment_attempt;let payment_intent = payment_data.payment_intent;+ let payment_link_data = payment_data.payment_link_data;let currency = payment_attempt.currency@@ -423,6 +424,7 @@ where.change_context(errors::ApiErrorResponse::InvalidDataValue {field_name: "payment_method_data",})?;+let merchant_decision = payment_intent.merchant_decision.to_owned();let frm_message = payment_data.frm_message.map(FrmMessage::foreign_from);@@ -679,6 +681,7 @@ where.set_feature_metadata(payment_intent.feature_metadata).set_connector_metadata(payment_intent.connector_metadata).set_reference_id(payment_attempt.connector_response_reference_id)+ .set_payment_link(payment_link_data).set_profile_id(payment_intent.profile_id).set_attempt_count(payment_intent.attempt_count).to_owned(),@@ -739,6 +742,7 @@ whereallowed_payment_method_types: payment_intent.allowed_payment_method_types,reference_id: payment_attempt.connector_response_reference_id,attempt_count: payment_intent.attempt_count,+ payment_link: payment_link_data,..Default::default()},headers,diff --git a/crates/router/src/db.rs b/crates/router/src/db.rsindex 356c1c6a51..fae242bc6d 100644--- a/crates/router/src/db.rs+++ b/crates/router/src/db.rs@@ -17,6 +17,7 @@ pub mod mandate;pub mod merchant_account;pub mod merchant_connector_account;pub mod merchant_key_store;+pub mod payment_link;pub mod payment_method;pub mod payout_attempt;pub mod payouts;@@ -74,6 +75,7 @@ pub trait StorageInterface:+ cards_info::CardsInfoInterface+ merchant_key_store::MerchantKeyStoreInterface+ MasterKeyInterface+ + payment_link::PaymentLinkInterface+ RedisConnInterface+ business_profile::BusinessProfileInterface+ 'staticdiff --git a/crates/router/src/db/payment_link.rs b/crates/router/src/db/payment_link.rsnew file mode 100644index 0000000000..38b59b1d60--- /dev/null+++ b/crates/router/src/db/payment_link.rs@@ -0,0 +1,66 @@+use error_stack::IntoReport;++use super::{MockDb, Store};+use crate::{+ connection,+ core::errors::{self, CustomResult},+ types::storage,+};++#[async_trait::async_trait]+pub trait PaymentLinkInterface {+ async fn find_payment_link_by_payment_link_id(+ &self,+ payment_link_id: &str,+ ) -> CustomResult<storage::PaymentLink, errors::StorageError>;++ async fn insert_payment_link(+ &self,+ _payment_link: storage::PaymentLinkNew,+ ) -> CustomResult<storage::PaymentLink, errors::StorageError>;+}++#[async_trait::async_trait]+impl PaymentLinkInterface for Store {+ async fn find_payment_link_by_payment_link_id(+ &self,+ payment_link_id: &str,+ ) -> CustomResult<storage::PaymentLink, errors::StorageError> {+ let conn = connection::pg_connection_read(self).await?;+ storage::PaymentLink::find_link_by_payment_link_id(&conn, payment_link_id)+ .await+ .map_err(Into::into)+ .into_report()+ }++ async fn insert_payment_link(+ &self,+ payment_link_object: storage::PaymentLinkNew,+ ) -> CustomResult<storage::PaymentLink, errors::StorageError> {+ let conn = connection::pg_connection_write(self).await?;+ payment_link_object+ .insert(&conn)+ .await+ .map_err(Into::into)+ .into_report()+ }+}++#[async_trait::async_trait]+impl PaymentLinkInterface for MockDb {+ async fn insert_payment_link(+ &self,+ _payment_link: storage::PaymentLinkNew,+ ) -> CustomResult<storage::PaymentLink, errors::StorageError> {+ // TODO: Implement function for `MockDb`+ Err(errors::StorageError::MockDbError)?+ }++ async fn find_payment_link_by_payment_link_id(+ &self,+ _payment_link_id: &str,+ ) -> CustomResult<storage::PaymentLink, errors::StorageError> {+ // TODO: Implement function for `MockDb`x+ Err(errors::StorageError::MockDbError)?+ }+}diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rsindex 738646b296..008991bb45 100644--- a/crates/router/src/lib.rs+++ b/crates/router/src/lib.rs@@ -127,7 +127,8 @@ pub fn mk_app(server_app = server_app.service(routes::PaymentMethods::server(state.clone())).service(routes::EphemeralKey::server(state.clone()))- .service(routes::Webhooks::server(state.clone()));+ .service(routes::Webhooks::server(state.clone()))+ .service(routes::PaymentLink::server(state.clone()));}#[cfg(feature = "olap")]diff --git a/crates/router/src/openapi.rs b/crates/router/src/openapi.rsindex a0f8643be3..5a36b03e7a 100644--- a/crates/router/src/openapi.rs+++ b/crates/router/src/openapi.rs@@ -61,6 +61,7 @@ Never share your secret api keys. Keep them guarded and secure.(name = "Disputes", description = "Manage disputes"),// (name = "API Key", description = "Create and manage API Keys"),(name = "Payouts", description = "Create and manage payouts"),+ (name = "payment link", description = "Create payment link"),),paths(crate::routes::refunds::refunds_create,@@ -112,6 +113,7 @@ Never share your secret api keys. Keep them guarded and secure.crate::routes::payouts::payouts_fulfill,crate::routes::payouts::payouts_retrieve,crate::routes::payouts::payouts_update,+ crate::routes::payment_link::payment_link_retrieve),components(schemas(crate::types::api::refunds::RefundRequest,@@ -336,7 +338,12 @@ Never share your secret api keys. Keep them guarded and secure.crate::types::api::api_keys::CreateApiKeyResponse,crate::types::api::api_keys::RetrieveApiKeyResponse,crate::types::api::api_keys::RevokeApiKeyResponse,- crate::types::api::api_keys::UpdateApiKeyRequest+ crate::types::api::api_keys::UpdateApiKeyRequest,+ api_models::payments::RetrievePaymentLinkRequest,+ api_models::payments::PaymentLinkResponse,+ api_models::payments::RetrievePaymentLinkResponse,+ api_models::payments::PaymentLinkInitiateRequest,+ api_models::payments::PaymentLinkObject)),modifiers(&SecurityAddon))]diff --git a/crates/router/src/routes.rs b/crates/router/src/routes.rsindex 20357040ce..307797e8ac 100644--- a/crates/router/src/routes.rs+++ b/crates/router/src/routes.rs@@ -14,6 +14,7 @@ pub mod health;pub mod lock_utils;pub mod mandates;pub mod metrics;+pub mod payment_link;pub mod payment_methods;pub mod payments;#[cfg(feature = "payouts")]@@ -31,8 +32,8 @@ pub use self::app::Payouts;pub use self::app::Verify;pub use self::app::{ApiKeys, AppState, BusinessProfile, Cache, Cards, Configs, Customers, Disputes, EphemeralKey,- Files, Health, Mandates, MerchantAccount, MerchantConnectorAccount, PaymentMethods, Payments,- Refunds, Webhooks,+ Files, Health, Mandates, MerchantAccount, MerchantConnectorAccount, PaymentLink,+ PaymentMethods, Payments, Refunds, Webhooks,};#[cfg(feature = "stripe")]pub use super::compatibility::stripe::StripeApis;diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rsindex 971459dc86..24d7217aef 100644--- a/crates/router/src/routes/app.rs+++ b/crates/router/src/routes/app.rs@@ -17,7 +17,7 @@ use super::payouts::*;use super::verification::{apple_pay_merchant_registration, retrieve_apple_pay_verified_domains};#[cfg(feature = "olap")]use super::{admin::*, api_keys::*, disputes::*, files::*};-use super::{cache::*, health::*};+use super::{cache::*, health::*, payment_link::*};#[cfg(any(feature = "olap", feature = "oltp"))]use super::{configs::*, customers::*, mandates::*, payments::*, refunds::*};#[cfg(feature = "oltp")]@@ -576,6 +576,22 @@ impl Cache {}}+pub struct PaymentLink;++impl PaymentLink {+ pub fn server(state: AppState) -> Scope {+ web::scope("/payment_link")+ .app_data(web::Data::new(state))+ .service(+ web::resource("/{payment_link_id}").route(web::get().to(payment_link_retrieve)),+ )+ .service(+ web::resource("{merchant_id}/{payment_id}")+ .route(web::get().to(initiate_payment_link)),+ )+ }+}+pub struct BusinessProfile;#[cfg(feature = "olap")]diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rsindex 80763ab434..cec510cd0c 100644--- a/crates/router/src/routes/lock_utils.rs+++ b/crates/router/src/routes/lock_utils.rs@@ -21,6 +21,7 @@ pub enum ApiIdentifier {Business,Verification,ApiKeys,+ PaymentLink,}impl From<Flow> for ApiIdentifier {@@ -112,6 +113,8 @@ impl From<Flow> for ApiIdentifier {| Flow::BusinessProfileList => Self::Business,Flow::Verification => Self::Verification,++ Flow::PaymentLinkInitiate | Flow::PaymentLinkRetrieve => Self::PaymentLink,}}}diff --git a/crates/router/src/routes/metrics/request.rs b/crates/router/src/routes/metrics/request.rsindex 1f1a9b3e38..30db586b7f 100644--- a/crates/router/src/routes/metrics/request.rs+++ b/crates/router/src/routes/metrics/request.rs@@ -60,6 +60,7 @@ pub fn track_response_status_code<Q>(response: &ApplicationResponse<Q>) -> i64 {| ApplicationResponse::StatusOk| ApplicationResponse::TextPlain(_)| ApplicationResponse::Form(_)+ | ApplicationResponse::PaymenkLinkForm(_)| ApplicationResponse::FileData(_)| ApplicationResponse::JsonWithHeaders(_) => 200,ApplicationResponse::JsonForRedirection(_) => 302,diff --git a/crates/router/src/routes/payment_link.rs b/crates/router/src/routes/payment_link.rsnew file mode 100644index 0000000000..b664ee4429--- /dev/null+++ b/crates/router/src/routes/payment_link.rs@@ -0,0 +1,82 @@+use actix_web::{web, Responder};+use router_env::{instrument, tracing, Flow};++use crate::{+ core::{api_locking, payment_link::*},+ services::{api, authentication as auth},+ AppState,+};++/// Payments Link - Retrieve+///+/// To retrieve the properties of a Payment Link. This may be used to get the status of a previously initiated payment or next action for an ongoing payment+#[utoipa::path(+ get,+ path = "/payment_link/{payment_link_id}",+ params(+ ("payment_link_id" = String, Path, description = "The identifier for payment link")+ ),+ request_body=RetrievePaymentLinkRequest,+ responses(+ (status = 200, description = "Gets details regarding payment link", body = RetrievePaymentLinkResponse),+ (status = 404, description = "No payment link found")+ ),+ tag = "Payments",+ operation_id = "Retrieve a Payment Link",+ security(("api_key" = []), ("publishable_key" = []))+)]+#[instrument(skip(state, req), fields(flow = ?Flow::PaymentLinkRetrieve))]++pub async fn payment_link_retrieve(+ state: web::Data<AppState>,+ req: actix_web::HttpRequest,+ path: web::Path<String>,+ json_payload: web::Query<api_models::payments::RetrievePaymentLinkRequest>,+) -> impl Responder {+ let flow = Flow::PaymentLinkRetrieve;+ let payload = json_payload.into_inner();+ let (auth_type, _) = match auth::check_client_secret_and_get_auth(req.headers(), &payload) {+ Ok(auth) => auth,+ Err(err) => return api::log_and_return_error_response(error_stack::report!(err)),+ };+ api::server_wrap(+ flow,+ state,+ &req,+ payload.clone(),+ |state, _auth, _| retrieve_payment_link(state, path.clone()),+ &*auth_type,+ api_locking::LockAction::NotApplicable,+ )+ .await+}++pub async fn initiate_payment_link(+ state: web::Data<AppState>,+ req: actix_web::HttpRequest,+ path: web::Path<(String, String)>,+) -> impl Responder {+ let flow = Flow::PaymentLinkInitiate;+ let (merchant_id, payment_id) = path.into_inner();+ let payload = api_models::payments::PaymentLinkInitiateRequest {+ payment_id,+ merchant_id: merchant_id.clone(),+ };+ api::server_wrap(+ flow,+ state,+ &req,+ payload.clone(),+ |state, auth, _| {+ intiate_payment_link_flow(+ state,+ auth.merchant_account,+ payload.merchant_id.clone(),+ payload.payment_id.clone(),+ )+ },+ &crate::services::authentication::MerchantIdAuth(merchant_id),+ api_locking::LockAction::NotApplicable,+ )+ .await+}diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rsindex def00bb3f2..b56e55b6c7 100644--- a/crates/router/src/services/api.rs+++ b/crates/router/src/services/api.rs@@ -1,6 +1,5 @@pub mod client;pub mod request;-use std::{collections::HashMap,error::Error,@@ -20,6 +19,7 @@ use masking::{ExposeOptionInterface, PeekInterface};use router_env::{instrument, tracing, tracing_actix_web::RequestId, Tag};use serde::Serialize;use serde_json::json;+use tera::{Context, Tera};use self::request::{HeaderExt, RequestBuilderExt};use crate::{@@ -655,10 +655,17 @@ pub enum ApplicationResponse<R> {TextPlain(String),JsonForRedirection(api::RedirectionResponse),Form(Box<RedirectionFormData>),+ PaymenkLinkForm(Box<PaymentLinkFormData>),FileData((Vec<u8>, mime::Mime)),JsonWithHeaders((R, Vec<(String, String)>)),}+#[derive(Debug, Eq, PartialEq, Clone, serde::Serialize, serde::Deserialize)]+pub struct PaymentLinkFormData {+ pub js_script: String,+ pub sdk_url: String,+}+#[derive(Debug, Eq, PartialEq)]pub struct RedirectionFormData {pub redirect_form: RedirectForm,@@ -887,6 +894,20 @@ where.respond_to(request).map_into_boxed_body()}++ Ok(ApplicationResponse::PaymenkLinkForm(payment_link_data)) => {+ match build_payment_link_html(*payment_link_data) {+ Ok(rendered_html) => http_response_html_data(rendered_html),+ Err(_) => http_response_err(+ r#"{+ "error": {+ "message": "Error while rendering payment link html page"+ }+ }"#,+ ),+ }+ }+Ok(ApplicationResponse::JsonWithHeaders((response, headers))) => {let request_elapsed_time = request.headers().get(X_HS_LATENCY).and_then(|value| {if value == "true" {@@ -1006,6 +1027,10 @@ pub fn http_response_file_data<T: body::MessageBody + 'static>(HttpResponse::Ok().content_type(content_type).body(res)}+pub fn http_response_html_data<T: body::MessageBody + 'static>(res: T) -> HttpResponse {+ HttpResponse::Ok().content_type(mime::TEXT_HTML).body(res)+}+pub fn http_response_ok() -> HttpResponse {HttpResponse::Ok().finish()}@@ -1329,3 +1354,32 @@ mod tests {assert_eq!(mime::APPLICATION_JSON.essence_str(), "application/json");}}++pub fn build_payment_link_html(+ payment_link_data: PaymentLinkFormData,+) -> CustomResult<String, errors::ApiErrorResponse> {+ let html_template = include_str!("../core/payment_link/payment_link.html").to_string();++ let mut tera = Tera::default();++ let _ = tera.add_raw_template("payment_link", &html_template);++ let mut context = Context::new();+ context.insert(+ "hyperloader_sdk_link",+ &get_hyper_loader_sdk(&payment_link_data.sdk_url),+ );+ context.insert("payment_details_js_script", &payment_link_data.js_script);++ match tera.render("payment_link", &context) {+ Ok(rendered_html) => Ok(rendered_html),+ Err(tera_error) => {+ crate::logger::warn!("{tera_error}");+ Err(errors::ApiErrorResponse::InternalServerError)?+ }+ }+}++fn get_hyper_loader_sdk(sdk_url: &str) -> String {+ format!("<script src=\"{sdk_url}\"></script>")+}diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rsindex 922d560a4a..eec872a9f3 100644--- a/crates/router/src/services/authentication.rs+++ b/crates/router/src/services/authentication.rs@@ -378,6 +378,12 @@ impl ClientSecretFetch for api_models::payments::PaymentsRetrieveRequest {}}+impl ClientSecretFetch for api_models::payments::RetrievePaymentLinkRequest {+ fn get_client_secret(&self) -> Option<&String> {+ self.client_secret.as_ref()+ }+}+pub fn get_auth_type_and_flow<A: AppStateInfo + Sync>(headers: &HeaderMap,) -> RouterResult<(diff --git a/crates/router/src/types/storage.rs b/crates/router/src/types/storage.rsindex 9995f7cce8..623a5f9498 100644--- a/crates/router/src/types/storage.rs+++ b/crates/router/src/types/storage.rs@@ -19,6 +19,7 @@ pub mod merchant_account;pub mod merchant_connector_account;pub mod merchant_key_store;pub mod payment_attempt;+pub mod payment_link;pub mod payment_method;pub use diesel_models::{ProcessTracker, ProcessTrackerNew, ProcessTrackerUpdate};pub use scheduler::db::process_tracker;@@ -37,8 +38,9 @@ pub use data_models::payments::{pub use self::{address::*, api_keys::*, capture::*, cards_info::*, configs::*, connector_response::*,customers::*, dispute::*, ephemeral_key::*, events::*, file::*, locker_mock_up::*, mandate::*,- merchant_account::*, merchant_connector_account::*, merchant_key_store::*, payment_method::*,- payout_attempt::*, payouts::*, process_tracker::*, refund::*, reverse_lookup::*,+ merchant_account::*, merchant_connector_account::*, merchant_key_store::*, payment_link::*,+ payment_method::*, payout_attempt::*, payouts::*, process_tracker::*, refund::*,+ reverse_lookup::*,};#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]diff --git a/crates/router/src/types/storage/payment_link.rs b/crates/router/src/types/storage/payment_link.rsnew file mode 100644index 0000000000..1fa2465e51--- /dev/null+++ b/crates/router/src/types/storage/payment_link.rs@@ -0,0 +1 @@+pub use diesel_models::payment_link::{PaymentLink, PaymentLinkNew};diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rsindex 04334fc201..2e376b0c21 100644--- a/crates/router/src/types/transformers.rs+++ b/crates/router/src/types/transformers.rs@@ -831,6 +831,22 @@ impl}}+impl ForeignFrom<storage::PaymentLink> for api_models::payments::RetrievePaymentLinkResponse {+ fn foreign_from(payment_link_object: storage::PaymentLink) -> Self {+ Self {+ payment_link_id: payment_link_object.payment_link_id,+ payment_id: payment_link_object.payment_id,+ merchant_id: payment_link_object.merchant_id,+ link_to_pay: payment_link_object.link_to_pay,+ amount: payment_link_object.amount,+ currency: payment_link_object.currency,+ created_at: payment_link_object.created_at,+ last_modified_at: payment_link_object.last_modified_at,+ link_expiry: payment_link_object.fulfilment_time,+ }+ }+}+impl From<domain::Address> for payments::AddressDetails {fn from(addr: domain::Address) -> Self {Self {diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rsindex d633cb4a5e..e838c5d9d5 100644--- a/crates/router_env/src/logger/types.rs+++ b/crates/router_env/src/logger/types.rs@@ -195,6 +195,10 @@ pub enum Flow {RetrieveDisputeEvidence,/// Invalidate cache flowCacheInvalidate,+ /// Payment Link Retrieve flow+ PaymentLinkRetrieve,+ /// payment Link Initiate flow+ PaymentLinkInitiate,/// Create a business profileBusinessProfileCreate,/// Update a business profilediff --git a/crates/storage_impl/src/mock_db.rs b/crates/storage_impl/src/mock_db.rsindex e41d7a3aba..ca043ac587 100644--- a/crates/storage_impl/src/mock_db.rs+++ b/crates/storage_impl/src/mock_db.rs@@ -40,6 +40,7 @@ pub struct MockDb {pub merchant_key_store: Arc<Mutex<Vec<crate::store::merchant_key_store::MerchantKeyStore>>>,pub business_profiles: Arc<Mutex<Vec<crate::store::business_profile::BusinessProfile>>>,pub reverse_lookups: Arc<Mutex<Vec<store::ReverseLookup>>>,+ pub payment_link: Arc<Mutex<Vec<store::payment_link::PaymentLink>>>,}impl MockDb {@@ -72,6 +73,7 @@ impl MockDb {merchant_key_store: Default::default(),business_profiles: Default::default(),reverse_lookups: Default::default(),+ payment_link: Default::default(),})}}diff --git a/crates/storage_impl/src/mock_db/payment_intent.rs b/crates/storage_impl/src/mock_db/payment_intent.rsindex 43d7207d45..2dc720b9f5 100644--- a/crates/storage_impl/src/mock_db/payment_intent.rs+++ b/crates/storage_impl/src/mock_db/payment_intent.rs@@ -105,6 +105,7 @@ impl PaymentIntentInterface for MockDb {attempt_count: new.attempt_count,profile_id: new.profile_id,merchant_decision: new.merchant_decision,+ payment_link_id: new.payment_link_id,payment_confirm_source: new.payment_confirm_source,};payment_intents.push(payment_intent.clone());diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rsindex 6814512028..c4718b3425 100644--- a/crates/storage_impl/src/payments/payment_intent.rs+++ b/crates/storage_impl/src/payments/payment_intent.rs@@ -90,6 +90,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {attempt_count: new.attempt_count,profile_id: new.profile_id.clone(),merchant_decision: new.merchant_decision.clone(),+ payment_link_id: new.payment_link_id.clone(),payment_confirm_source: new.payment_confirm_source,};@@ -697,6 +698,7 @@ impl DataModelExt for PaymentIntentNew {attempt_count: self.attempt_count,profile_id: self.profile_id,merchant_decision: self.merchant_decision,+ payment_link_id: self.payment_link_id,payment_confirm_source: self.payment_confirm_source,}}@@ -734,6 +736,7 @@ impl DataModelExt for PaymentIntentNew {attempt_count: storage_model.attempt_count,profile_id: storage_model.profile_id,merchant_decision: storage_model.merchant_decision,+ payment_link_id: storage_model.payment_link_id,payment_confirm_source: storage_model.payment_confirm_source,}}@@ -766,9 +769,9 @@ impl DataModelExt for PaymentIntent {setup_future_usage: self.setup_future_usage,off_session: self.off_session,client_secret: self.client_secret,- active_attempt_id: self.active_attempt_id,business_country: self.business_country,business_label: self.business_label,+ active_attempt_id: self.active_attempt_id,order_details: self.order_details,allowed_payment_method_types: self.allowed_payment_method_types,connector_metadata: self.connector_metadata,@@ -776,6 +779,7 @@ impl DataModelExt for PaymentIntent {attempt_count: self.attempt_count,profile_id: self.profile_id,merchant_decision: self.merchant_decision,+ payment_link_id: self.payment_link_id,payment_confirm_source: self.payment_confirm_source,}}@@ -814,6 +818,7 @@ impl DataModelExt for PaymentIntent {attempt_count: storage_model.attempt_count,profile_id: storage_model.profile_id,merchant_decision: storage_model.merchant_decision,+ payment_link_id: storage_model.payment_link_id,payment_confirm_source: storage_model.payment_confirm_source,}}diff --git a/migrations/2023-09-08-101302_add_payment_link/down.sql b/migrations/2023-09-08-101302_add_payment_link/down.sqlnew file mode 100644index 0000000000..f2ff37da55--- /dev/null+++ b/migrations/2023-09-08-101302_add_payment_link/down.sql@@ -0,0 +1,2 @@+-- This file should undo anything in `up.sql`+drop table payment_link;\ No newline at end of filediff --git a/migrations/2023-09-08-101302_add_payment_link/up.sql b/migrations/2023-09-08-101302_add_payment_link/up.sqlnew file mode 100644index 0000000000..565f53d9e5--- /dev/null+++ b/migrations/2023-09-08-101302_add_payment_link/up.sql@@ -0,0 +1,13 @@+-- Your SQL goes here+CREATE TABLE payment_link (+ payment_link_id VARCHAR(255) NOT NULL,+ payment_id VARCHAR(64) NOT NULL,+ link_to_pay VARCHAR(255) NOT NULL,+ merchant_id VARCHAR(64) NOT NULL,+ amount INT8 NOT NULL,+ currency "Currency",+ created_at TIMESTAMP NOT NULL,+ last_modified_at TIMESTAMP NOT NULL,+ fulfilment_time TIMESTAMP,+ PRIMARY KEY (payment_link_id)+);diff --git a/migrations/2023-09-08-114828_add_payment_link_id_in_payment_intent/down.sql b/migrations/2023-09-08-114828_add_payment_link_id_in_payment_intent/down.sqlnew file mode 100644index 0000000000..6cead95623--- /dev/null+++ b/migrations/2023-09-08-114828_add_payment_link_id_in_payment_intent/down.sql@@ -0,0 +1,2 @@+-- This file should undo anything in `up.sql`+ALTER TABLE payment_intent DROP COLUMN payment_link_id;diff --git a/migrations/2023-09-08-114828_add_payment_link_id_in_payment_intent/up.sql b/migrations/2023-09-08-114828_add_payment_link_id_in_payment_intent/up.sqlnew file mode 100644index 0000000000..9c827740a9--- /dev/null+++ b/migrations/2023-09-08-114828_add_payment_link_id_in_payment_intent/up.sql@@ -0,0 +1,2 @@+-- Your SQL goes here+ALTER TABLE payment_intent ADD column payment_link_id VARCHAR(255);\ No newline at end of filediff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.jsonindex 27b73f1c09..d9fd4055c9 100644--- a/openapi/openapi_spec.json+++ b/openapi/openapi_spec.json@@ -794,6 +794,60 @@]}},+ "/payment_link/{payment_link_id}": {+ "get": {+ "tags": [+ "Payments"+ ],+ "summary": "Payments Link - Retrieve",+ "description": "Payments Link - Retrieve\n\nTo retrieve the properties of a Payment Link. This may be used to get the status of a previously initiated payment or next action for an ongoing payment",+ "operationId": "Retrieve a Payment Link",+ "parameters": [+ {+ "name": "payment_link_id",+ "in": "path",+ "description": "The identifier for payment link",+ "required": true,+ "schema": {+ "type": "string"+ }+ }+ ],+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/RetrievePaymentLinkRequest"+ }+ }+ },+ "required": true+ },+ "responses": {+ "200": {+ "description": "Gets details regarding payment link",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/RetrievePaymentLinkResponse"+ }+ }+ }+ },+ "404": {+ "description": "No payment link found"+ }+ },+ "security": [+ {+ "api_key": []+ },+ {+ "publishable_key": []+ }+ ]+ }+ },"/payment_methods": {"post": {"tags": [@@ -7710,6 +7764,50 @@}]},+ "PaymentLinkInitiateRequest": {+ "type": "object",+ "required": [+ "merchant_id",+ "payment_id"+ ],+ "properties": {+ "merchant_id": {+ "type": "string"+ },+ "payment_id": {+ "type": "string"+ }+ }+ },+ "PaymentLinkObject": {+ "type": "object",+ "properties": {+ "link_expiry": {+ "type": "string",+ "format": "date-time",+ "nullable": true+ },+ "merchant_custom_domain_name": {+ "type": "string",+ "nullable": true+ }+ }+ },+ "PaymentLinkResponse": {+ "type": "object",+ "required": [+ "link",+ "payment_link_id"+ ],+ "properties": {+ "link": {+ "type": "string"+ },+ "payment_link_id": {+ "type": "string"+ }+ }+ },"PaymentListConstraints": {"type": "object","properties": {@@ -8769,6 +8867,14 @@],"nullable": true},+ "payment_link_object": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentLinkObject"+ }+ ],+ "nullable": true+ },"profile_id": {"type": "string","description": "The business profile to use for this payment, if not passed the default business profile\nassociated with the merchant account will be used.",@@ -9116,6 +9222,14 @@],"nullable": true},+ "payment_link_object": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentLinkObject"+ }+ ],+ "nullable": true+ },"profile_id": {"type": "string","description": "The business profile to use for this payment, if not passed the default business profile\nassociated with the merchant account will be used.",@@ -9510,6 +9624,14 @@"example": "993672945374576J","nullable": true},+ "payment_link": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentLinkResponse"+ }+ ],+ "nullable": true+ },"profile_id": {"type": "string","description": "The business profile that is associated with this payment",@@ -10573,6 +10695,66 @@}}},+ "RetrievePaymentLinkRequest": {+ "type": "object",+ "properties": {+ "client_secret": {+ "type": "string",+ "nullable": true+ }+ }+ },+ "RetrievePaymentLinkResponse": {+ "type": "object",+ "required": [+ "payment_link_id",+ "payment_id",+ "merchant_id",+ "link_to_pay",+ "amount",+ "created_at",+ "last_modified_at"+ ],+ "properties": {+ "payment_link_id": {+ "type": "string"+ },+ "payment_id": {+ "type": "string"+ },+ "merchant_id": {+ "type": "string"+ },+ "link_to_pay": {+ "type": "string"+ },+ "amount": {+ "type": "integer",+ "format": "int64"+ },+ "currency": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Currency"+ }+ ],+ "nullable": true+ },+ "created_at": {+ "type": "string",+ "format": "date-time"+ },+ "last_modified_at": {+ "type": "string",+ "format": "date-time"+ },+ "link_expiry": {+ "type": "string",+ "format": "date-time",+ "nullable": true+ }+ }+ },"RetryAction": {"type": "string","enum": [@@ -11508,6 +11690,10 @@{"name": "Payouts","description": "Create and manage payouts"+ },+ {+ "name": "payment link",+ "description": "Create payment link"}]}\ No newline at end of file