Skip to content

Commit

Permalink
Bump version to 2.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
devops-blockchyp committed Nov 20, 2024
1 parent da9fb43 commit 80d5fcc
Show file tree
Hide file tree
Showing 8 changed files with 1,060 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blockchyp"
version = "2.19.0"
version = "2.20.1"
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"
Expand Down
143 changes: 142 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,80 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

```

#### Card Metadata



* **API Credential Types:** Merchant
* **Required Role:** Payment API Access

This API allows you to retrieve card metadata.

Card metadata requests can use a payment terminal to retrieve metadata or
use a previously enrolled payment token.

**Terminal Transactions**

For terminal transactions, make sure you pass in the terminal name using the `terminalName` property.

**Token Transactions**

If you have a payment token, omit the `terminalName` property and pass in the token with the `token`
property instead.

**Card Numbers and Mag Stripes**

You can also pass in PANs and Mag Stripes, but you probably shouldn't, as this will
put you in PCI scope and the most common vector for POS breaches is keylogging.
If you use terminals for manual card entry, you'll bypass any keyloggers that
might be maliciously running on the point-of-sale system.




```rust
use blockchyp;
use std::error::Error;

fn card_metadata_example() -> Result<(), Box<dyn Error>> {
// 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 mut request = blockchyp::CardMetadataRequest{
test: true,
terminal_name: "Test Terminal".to_string(),
..Default::default()
};
let (response, err) = client.card_metadata(&mut 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<dyn std::error::Error>> {
card_metadata_example()?;
println!("Example completed successfully!");
Ok(())
}

```

#### Time Out Reversal


Expand Down Expand Up @@ -5843,7 +5917,7 @@ fn merchant_credential_generation_example() -> Result<(), Box<dyn Error>> {
let client = blockchyp::Client::new(creds);

let request = blockchyp::MerchantCredentialGenerationRequest{

merchant_id: "<MERCHANT ID>".to_string(),
..Default::default()
};
let (response, err) = client.merchant_credential_generation(&request);
Expand All @@ -5869,6 +5943,73 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

```

#### Submit Application



* **API Credential Types:** Partner
* **Required Role:** INVITE MERCHANT

This is a partner level API that can be used to submit applications to add new merchant accounts. The application requires a significant amount of detailed information about the merchant and their business. Rather than providing an exhaustive list of required fields, we recommend submitting as much information as possible in your initial request.

If any required fields are missing or if there are any validation errors, the API will return specific error messages indicating which fields need to be addressed. Simply review these validation errors, fill in the missing information or correct any errors, and resubmit the application.

Key areas of information include:
- Business details (name, type, tax information)
- Contact information
- Address information (physical and mailing)
- Owner details
- Bank account information
- Transaction volume estimates
- Operational settings (timezone, batch close time, etc.)

**Note:** Some fields may be conditionally required based on the values of other fields. The validation process will guide you through ensuring all necessary information is provided.




```rust
use blockchyp;
use std::error::Error;

fn submit_application_example() -> Result<(), Box<dyn Error>> {
// 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::SubmitApplicationRequest{

..Default::default()
};
let (response, err) = client.submit_application(&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<dyn std::error::Error>> {
submit_application_example()?;
println!("Example completed successfully!");
Ok(())
}

```




Expand Down
39 changes: 39 additions & 0 deletions examples/card_metadata_example.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use blockchyp;
use std::error::Error;

fn card_metadata_example() -> Result<(), Box<dyn Error>> {
// 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 mut request = blockchyp::CardMetadataRequest{
test: true,
terminal_name: "Test Terminal".to_string(),
..Default::default()
};
let (response, err) = client.card_metadata(&mut 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<dyn std::error::Error>> {
card_metadata_example()?;
println!("Example completed successfully!");
Ok(())
}
2 changes: 1 addition & 1 deletion examples/merchant_credential_generation_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn merchant_credential_generation_example() -> Result<(), Box<dyn Error>> {
let client = blockchyp::Client::new(creds);

let request = blockchyp::MerchantCredentialGenerationRequest{

merchant_id: "<MERCHANT ID>".to_string(),
..Default::default()
};
let (response, err) = client.merchant_credential_generation(&request);
Expand Down
38 changes: 38 additions & 0 deletions examples/submit_application_example.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use blockchyp;
use std::error::Error;

fn submit_application_example() -> Result<(), Box<dyn Error>> {
// 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::SubmitApplicationRequest{

..Default::default()
};
let (response, err) = client.submit_application(&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<dyn std::error::Error>> {
submit_application_example()?;
println!("Example completed successfully!");
Ok(())
}
79 changes: 79 additions & 0 deletions src/blockchyp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,63 @@ impl Client {
(response, err)
}

/// Retrieves card metadata.
pub fn card_metadata(&self, request: &mut CardMetadataRequest) -> (CardMetadataResponse, Option<Box<dyn Error>>) {
let mut response = CardMetadataResponse::default();
let response_err: Result<(), Box<dyn Error>>;

if let Err(e) = self.populate_signature_options(request) {
return (response, Some(e));
}

if !request.terminal_name.is_empty() {
match self.resolve_terminal_route(&request.terminal_name) {
Ok(route) => {
if route.cloud_relay_enabled {
response_err = self.relay_request("/api/card-metadata", "POST", &request, &mut response, request.test, Some(request.timeout));
} else {
let auth_request = TerminalCardMetadataRequest {
api_credentials: route.transient_credentials.clone().unwrap_or_default(),
request: request.clone(),
};
response_err = self.terminal_request(route, "/api/card-metadata", "POST", &auth_request, &mut response, Some(request.timeout));
}
}
Err(e) => {
if e.downcast_ref::<ErrUnknownTerminal>().is_some() {
response.response_description = RESPONSE_UNKNOWN_TERMINAL.to_string();
return (response, Some(e))
} else {
return (response, Some(e))
}
}
}
} else {
response_err = self.gateway_request("/api/card-metadata", "POST", request, &mut response, request.test, Some(request.timeout));
}

let err = if let Err(e) = response_err {
if let Some(reqwest_err) = e.downcast_ref::<reqwest::Error>() {
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
};

if let Err(e) = self.handle_signature(&request, &mut response) {
return (response, Some(e));
}

(response, err)
}

/// Activates or recharges a gift card.
pub fn gift_activate(&self, request: &mut GiftActivateRequest) -> (GiftActivateResponse, Option<Box<dyn Error>>) {
let mut response = GiftActivateResponse::default();
Expand Down Expand Up @@ -1969,6 +2026,28 @@ impl Client {
None
};

(response, err)
}
/// Submits and application to add a new merchant account.
pub fn submit_application(&self, request: &SubmitApplicationRequest) -> (Acknowledgement, Option<Box<dyn Error>>) {
let mut response = Acknowledgement::default();
let response_err = self.dashboard_request("/api/submit-application", "POST", request, &mut response, Some(request.timeout));

let err = if let Err(e) = response_err {
if let Some(reqwest_err) = e.downcast_ref::<reqwest::Error>() {
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.
Expand Down
Loading

0 comments on commit 80d5fcc

Please sign in to comment.