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 519b577 commit b659109
Show file tree
Hide file tree
Showing 7 changed files with 673 additions and 11 deletions.
69 changes: 68 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5858,7 +5858,9 @@ func merchantCredentialGenerationExample() {
client := blockchyp.NewClient(creds)

// setup request object
request := blockchyp.MerchantCredentialGenerationRequest{}
request := blockchyp.MerchantCredentialGenerationRequest{
MerchantID: "<MERCHANT ID>",
}

response, err := client.MerchantCredentialGeneration(request)

Expand All @@ -5876,6 +5878,71 @@ func merchantCredentialGenerationExample() {

```

#### 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.




```go
package main

import (
"fmt"
"log"

blockchyp "github.com/blockchyp/blockchyp-go/v2"
)

func submitApplicationExample() {
// sample credentials
creds := blockchyp.APICredentials{
APIKey: "ZDSMMZLGRPBPRTJUBTAFBYZ33Q",
BearerToken: "ZLBW5NR4U5PKD5PNP3ZP3OZS5U",
SigningKey: "9c6a5e8e763df1c9256e3d72bd7f53dfbd07312938131c75b3bfd254da787947",
}

// instantiate the client
client := blockchyp.NewClient(creds)

// setup request object
request := blockchyp.SubmitApplicationRequest{}

response, err := client.SubmitApplication(request)

if err != nil {
log.Fatal(err)
}

//process the result
if response.Success {
fmt.Println("Success")
}

fmt.Printf("Response: %+v\n", response)
}

```




Expand Down
15 changes: 15 additions & 0 deletions blockchyp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,21 @@ func (client *Client) MerchantCredentialGeneration(request MerchantCredentialGen
return &response, err
}

// SubmitApplication submits and application to add a new merchant account.
func (client *Client) SubmitApplication(request SubmitApplicationRequest) (*Acknowledgement, error) {
var response Acknowledgement

err := client.DashboardRequest("/api/submit-application", "POST", request, &response, request.Timeout)

if err, ok := err.(net.Error); ok && err.Timeout() {
response.ResponseDescription = ResponseTimedOut
} else if err != nil {
response.ResponseDescription = err.Error()
}

return &response, err
}

// GetMerchants adds a test merchant account.
func (client *Client) GetMerchants(request GetMerchantsRequest) (*GetMerchantsResponse, error) {
var response GetMerchantsResponse
Expand Down
38 changes: 29 additions & 9 deletions cmd/blockchyp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,24 @@ func parseArgs() blockchyp.CommandLineArguments {
flag.BoolVar(&args.Incremental, "incremental", false, "force incremental firmware downloads")
flag.BoolVar(&args.ChipRejection, "chipRejection", false, "simulates a chip rejection")
flag.BoolVar(&args.OutOfOrderReversal, "outOfOrderReversal", false, "simulates an out of order auto reversal")
flag.BoolVar(&args.AsyncReversals, "asyncReversals", false, "causes auto-reversals to run asynchronously")
flag.BoolVar(&args.AsyncReversals, "asyncReversals", false, "causes auto-reversals to run asynchronously.")
flag.BoolVar(&args.CardOnFile, "cardOnFile", false, "flags a transaction as MOTO / card on file.")
flag.BoolVar(&args.Recurring, "recurring", false, "flags a transaction as recurring.")
flag.BoolVar(&args.MIT, "mit", false, "manually sets the MIT flag.")
flag.BoolVar(&args.CIT, "cit", false, "manually sets the CIT flag.")
flag.BoolVar(&args.Subscription, "subscription", false, "flags a transaction as a subscription.")
flag.StringVar(&args.PONumber, "po", "", "purchase order for L2 transactions")
flag.StringVar(&args.SupplierReferenceNumber, "srn", "", "supplier reference number for L2 transactions")
flag.StringVar(&args.PolicyID, "policy", "", "policy id for pricing policy related operations")
flag.StringVar(&args.StatementID, "statementId", "", "statement id for partner or merchant statement operations")
flag.StringVar(&args.InvoiceID, "invoiceId", "", "invoice id for partner or merchant statement/invoice operations")
flag.StringVar(&args.SupplierReferenceNumber, "srn", "", "supplier reference number for L2 transactions.")
flag.StringVar(&args.PolicyID, "policy", "", "policy id for pricing policy related operations.")
flag.StringVar(&args.StatementID, "statementId", "", "statement id for partner or merchant statement operations.")
flag.StringVar(&args.InvoiceID, "invoiceId", "", "invoice id for partner or merchant statement/invoice operations.")
flag.IntVar(&args.ShipmentNumber, "shipmentNumber", 0, "indicates the shipment number in a split shipment order.")
flag.IntVar(&args.ShipmentCount, "shipmentCount", 0, "indicates the total number of shipments in a split shipment order.")
flag.StringVar(&args.EntryMethod, "entryMethod", "", "is the method by which the payment card was entered.")
flag.BoolVar(&args.DeleteProtected, "deleteProtected", false, "protects the credentials from deletion")
flag.StringVar(&args.Roles, "roles", "", "an optional array of role codes that will be assigned to the credentials")
flag.StringVar(&args.Notes, "notes", "", "free form description of the purpose or intent behind the credentials")
flag.StringVar(&args.CredType, "credType", "", "is the type of credential to be generated, API or TOKENIZING")
flag.BoolVar(&args.DeleteProtected, "deleteProtected", false, "protects the credentials from deletion.")
flag.StringVar(&args.Roles, "roles", "", "an optional array of role codes that will be assigned to the credentials.")
flag.StringVar(&args.Notes, "notes", "", "free form description of the purpose or intent behind the credentials.")
flag.StringVar(&args.CredType, "credType", "", "is the type of credential to be generated, API or TOKENIZING.")
flag.Parse()

if args.Version {
Expand Down Expand Up @@ -476,6 +476,8 @@ func processCommand(args blockchyp.CommandLineArguments) {
processUnlinkToken(client, args)
case "drop-terminal-socket":
processDropSocket(client, args)
case "submit-application":
processSubmitApplication(client, args)
default:
fatalErrorf("unknown command: %s", cmd)
}
Expand Down Expand Up @@ -2747,6 +2749,24 @@ func processTokenDelete(client *blockchyp.Client, args blockchyp.CommandLineArgu
dumpResponse(&args, res)
}

func processSubmitApplication(client *blockchyp.Client, args blockchyp.CommandLineArguments) {

request := &blockchyp.SubmitApplicationRequest{}

if !parseJSONInput(args, request) {
if (args.JSON == "") && args.JSONFile == "" {
fatalError("-json or -jsonFile required")
}
}

ack, err := client.SubmitApplication(*request)
if err != nil {
handleError(&args, err)
}

dumpResponse(&args, ack)
}

func parseTimestamp(ts string) (time.Time, error) {

parsedResult, err := parseTimestampWithFormat(ts, time.RFC3339)
Expand Down
Loading

0 comments on commit b659109

Please sign in to comment.