Skip to content

Commit

Permalink
Merge pull request #282 from blockchyp/feature/CHYP-3620
Browse files Browse the repository at this point in the history
Added merchant application submission
  • Loading branch information
devops-blockchyp committed Sep 17, 2024
1 parent 0c56c5b commit 58ef0f5
Show file tree
Hide file tree
Showing 6 changed files with 633 additions and 2 deletions.
69 changes: 68 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5843,7 +5843,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 +5869,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
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(())
}
22 changes: 22 additions & 0 deletions src/blockchyp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,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 58ef0f5

Please sign in to comment.