diff --git a/Cargo.toml b/Cargo.toml index 2f97d7c..4f2b27e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "blockchyp" -version = "2.18.8" +version = "2.19.0" edition = "2021" description = "This is the SDK for Rust. Like all BlockChyp SDKs, it provides a full client for the BlockChyp gateway and BlockChyp payment terminals." documentation = "https://docs.blockchyp.com/#overview" diff --git a/README.md b/README.md index 83ca283..6675446 100644 --- a/README.md +++ b/README.md @@ -5251,6 +5251,68 @@ fn main() -> Result<(), Box> { ``` +#### Add Gateway Merchant + + + +* **API Credential Types:** Partner +* **Required Role:** Gateway Boarding + +This is a partner level API that can be used to manually board gateway merchants. Use this API in conjunction +with Platform Configuration to instantly board gateway merchants. Note that most partners don't have +permission to do this and are unlikely to get it. + +Settings can be changed by using the Update Merchant API. + + + + +```rust +use blockchyp; +use std::error::Error; + +fn add_gateway_merchant_example() -> Result<(), Box> { + // sample credentials + let creds = blockchyp::APICredentials { + api_key: "ZDSMMZLGRPBPRTJUBTAFBYZ33Q".to_string(), + bearer_token: "ZLBW5NR4U5PKD5PNP3ZP3OZS5U".to_string(), + signing_key: "9c6a5e8e763df1c9256e3d72bd7f53dfbd07312938131c75b3bfd254da787947".to_string(), + }; + + // instantiate the client + let client = blockchyp::Client::new(creds); + + let request = blockchyp::AddGatewayMerchantRequest{ + profile: blockchyp::MerchantProfile{ + dba_name: "DBA Name".to_string(), + company_name: "Corporate Entity Name".to_string(), + ..Default::default() + }, + ..Default::default() + }; + let (response, err) = client.add_gateway_merchant(&request); + + if let Some(e) = err { + eprintln!("Unexpected error occurred: {:?}", e); + return Err(e) + } + + if response.success { + println!("Success"); + } + + println!("Response: {:?}", response); + Ok(()) +} + +fn main() -> Result<(), Box> { + add_gateway_merchant_example()?; + println!("Example completed successfully!"); + Ok(()) +} + +``` + #### Add Test Merchant diff --git a/examples/add_gateway_merchant_example.rs b/examples/add_gateway_merchant_example.rs new file mode 100644 index 0000000..fe09c31 --- /dev/null +++ b/examples/add_gateway_merchant_example.rs @@ -0,0 +1,42 @@ +use blockchyp; +use std::error::Error; + +fn add_gateway_merchant_example() -> Result<(), Box> { + // sample credentials + let creds = blockchyp::APICredentials { + api_key: "ZDSMMZLGRPBPRTJUBTAFBYZ33Q".to_string(), + bearer_token: "ZLBW5NR4U5PKD5PNP3ZP3OZS5U".to_string(), + signing_key: "9c6a5e8e763df1c9256e3d72bd7f53dfbd07312938131c75b3bfd254da787947".to_string(), + }; + + // instantiate the client + let client = blockchyp::Client::new(creds); + + let request = blockchyp::AddGatewayMerchantRequest{ + profile: blockchyp::MerchantProfile{ + dba_name: "DBA Name".to_string(), + company_name: "Corporate Entity Name".to_string(), + ..Default::default() + }, + ..Default::default() + }; + let (response, err) = client.add_gateway_merchant(&request); + + if let Some(e) = err { + eprintln!("Unexpected error occurred: {:?}", e); + return Err(e) + } + + if response.success { + println!("Success"); + } + + println!("Response: {:?}", response); + Ok(()) +} + +fn main() -> Result<(), Box> { + add_gateway_merchant_example()?; + println!("Example completed successfully!"); + Ok(()) +} diff --git a/examples/update_merchant_platforms_example.rs b/examples/update_merchant_platforms_example.rs index d4c1527..7c8d4be 100644 --- a/examples/update_merchant_platforms_example.rs +++ b/examples/update_merchant_platforms_example.rs @@ -13,7 +13,7 @@ fn update_merchant_platforms_example() -> Result<(), Box> { let client = blockchyp::Client::new(creds); let request = blockchyp::MerchantPlatform{ - merchant_id: "XXXXXXXXXXXXX".to_string(), + ..Default::default() }; let (response, err) = client.update_merchant_platforms(&request); diff --git a/src/blockchyp.rs b/src/blockchyp.rs index 140ac1e..b7435f4 100644 --- a/src/blockchyp.rs +++ b/src/blockchyp.rs @@ -2058,6 +2058,28 @@ impl Client { None }; + (response, err) + } + /// Adds a live gateway merchant account. + pub fn add_gateway_merchant(&self, request: &AddGatewayMerchantRequest) -> (MerchantProfileResponse, Option>) { + let mut response = MerchantProfileResponse::default(); + let response_err = self.dashboard_request("/api/add-gateway-merchant", "POST", request, &mut response, Some(request.timeout)); + + let err = if let Err(e) = response_err { + if let Some(reqwest_err) = e.downcast_ref::() { + if reqwest_err.is_timeout() { + response.response_description = RESPONSE_TIMED_OUT.to_string(); + } else { + response.response_description = e.to_string(); + } + } else { + response.response_description = e.to_string(); + } + Some(e) + } else { + None + }; + (response, err) } /// Adds a test merchant account. diff --git a/src/models.rs b/src/models.rs index 69b0b4b..454d260 100644 --- a/src/models.rs +++ b/src/models.rs @@ -4194,6 +4194,21 @@ pub struct AddTestMerchantRequest { } +/// Models basic information needed to create a gateway merchant. +#[derive(Debug, Default, Clone, Serialize, Deserialize)] +pub struct AddGatewayMerchantRequest { + /// Whether or not to route transaction to the test gateway. + #[serde(rename = "test")] + pub test: bool, + /// The merchant profile to be boarded. + #[serde(rename = "profile")] + pub profile: MerchantProfile, + /// The request timeout in seconds. + #[serde(rename = "timeout")] + pub timeout: i32, + +} + /// Models a request for information about the merchant profile. #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub struct MerchantProfileRequest { @@ -4390,6 +4405,9 @@ pub struct MerchantProfile { /// The merchant id. #[serde(rename = "merchantId")] pub merchant_id: String, + /// The primary bank mid. + #[serde(rename = "bankMid")] + pub bank_mid: String, /// The merchant's company name. #[serde(rename = "companyName")] pub company_name: String, @@ -4562,6 +4580,9 @@ pub struct MerchantProfileResponse { /// The merchant id. #[serde(rename = "merchantId")] pub merchant_id: String, + /// The primary bank mid. + #[serde(rename = "bankMid")] + pub bank_mid: String, /// The merchant's company name. #[serde(rename = "companyName")] pub company_name: String, @@ -5257,6 +5278,39 @@ pub struct MerchantPlatformsResponse { } +/// Used to up platform configuration for gateway merchants. +#[derive(Debug, Default, Clone, Serialize, Deserialize)] +pub struct UpdateMerchantPlatformRequest { + /// The request timeout in seconds. + #[serde(rename = "timeout")] + pub timeout: i32, + /// Whether or not to route transaction to the test gateway. + #[serde(rename = "test")] + pub test: bool, + /// The merchant platform configuration. + #[serde(rename = "platform")] + pub platform: MerchantPlatform, + +} + +/// Echoes back the state of the current platform configuration after a change. +#[derive(Debug, Default, Clone, Serialize, Deserialize)] +pub struct UpdateMerchantPlatformResponse { + /// Whether or not the request succeeded. + #[serde(rename = "success")] + pub success: bool, + /// The error, if an error occurred. + #[serde(rename = "error")] + pub error: String, + /// A narrative description of the transaction result. + #[serde(rename = "responseDescription")] + pub response_description: String, + /// The current platform configuration. + #[serde(rename = "platform")] + pub platform: MerchantPlatform, + +} + /// Details about a merchant board platform configuration. #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub struct MerchantPlatform { @@ -7115,6 +7169,9 @@ pub struct MerchantCredentialGenerationRequest { /// Free form description of the purpose or intent behind the credentials. #[serde(rename = "notes")] pub notes: String, + /// Type of credentials to generate, either API or TOKENIZING. Defaults to API. + #[serde(rename = "credentialType")] + pub credential_type: String, } @@ -7139,6 +7196,9 @@ pub struct MerchantCredentialGenerationResponse { /// The merchant signing key. #[serde(rename = "signingKey")] pub signing_key: String, + /// The tokenizing key. + #[serde(rename = "tokenizingKey")] + pub tokenizing_key: String, } diff --git a/tests/add_gateway_merchant_tests.rs b/tests/add_gateway_merchant_tests.rs new file mode 100644 index 0000000..924ab3d --- /dev/null +++ b/tests/add_gateway_merchant_tests.rs @@ -0,0 +1,33 @@ +// Copyright 2019-2024 BlockChyp, Inc. All rights reserved. Use of this code +// is governed by a license that can be found in the LICENSE file. +// +// This file was generated automatically by the BlockChyp SDK Generator. +// Changes to this file will be lost every time the code is regenerated. + +mod test_utils; +use blockchyp; + +#[test] +fn test_add_gateway_merchant() { + let config = test_utils::load_test_configuration(); + let client = config.new_test_client(Some("partner")); + + // request object + let request = blockchyp::AddGatewayMerchantRequest{ + profile: blockchyp::MerchantProfile{ + dba_name: "DBA Name".to_string(), + company_name: "Corporate Entity Name".to_string(), + ..Default::default() + }, + ..Default::default() + }; + println!("Request: {:?}", request); + + let (response, err) = client.add_gateway_merchant(&request); + assert!(err.is_none(), "err is not none: {:?}", err); + + println!("Response: {:?}", response); + + // response assertions + assert!(response.success); +}