Skip to content

Commit

Permalink
Merge pull request #281 from blockchyp/develop
Browse files Browse the repository at this point in the history
Develop to Master
  • Loading branch information
devops-blockchyp committed Sep 12, 2024
1 parent 08f044c commit 2cb6e39
Show file tree
Hide file tree
Showing 8 changed files with 274 additions and 3 deletions.
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5273,6 +5273,67 @@ func inviteMerchantUserExample() {

```

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




```go
package main

import (
"fmt"
"log"

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

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

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

// setup request object
request := blockchyp.AddGatewayMerchantRequest{
Profile: blockchyp.MerchantProfile{
DBAName: "DBA Name",
CompanyName: "Corporate Entity Name",
},
}

response, err := client.AddGatewayMerchant(request)

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

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

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

```

#### Add Test Merchant


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

// AddGatewayMerchant adds a live gateway merchant account.
func (client *Client) AddGatewayMerchant(request AddGatewayMerchantRequest) (*MerchantProfileResponse, error) {
var response MerchantProfileResponse

err := client.DashboardRequest("/api/add-gateway-merchant", "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
}

// AddTestMerchant adds a test merchant account.
func (client *Client) AddTestMerchant(request AddTestMerchantRequest) (*MerchantProfileResponse, error) {
var response MerchantProfileResponse
Expand Down
1 change: 1 addition & 0 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ type CommandLineArguments struct {
DeleteProtected bool `json:"deteleProtected"`
Roles string `json:"roles"`
Notes string `json:"notes"`
CredType string `json:"credType"`
}

var defaultSettings = &ConfigSettings{
Expand Down
55 changes: 55 additions & 0 deletions cmd/blockchyp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ func parseArgs() blockchyp.CommandLineArguments {
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 @@ -323,6 +324,12 @@ func processCommand(args blockchyp.CommandLineArguments) {
processSideLoad(client, args)
case "add-test-merchant":
processAddTestMerchant(client, args)
case "add-gateway-merchant":
processAddGatewayMerchant(client, args)
case "merchant-platforms":
processMerchantPlatforms(client, args)
case "update-merchant-platforms":
processUpdateMerchantPlatform(client, args)
case "delete-test-merchant":
processDeleteTestMerchant(client, args)
case "invite-merchant-user":
Expand Down Expand Up @@ -524,6 +531,7 @@ func processMerchantCredentialGeneration(client *blockchyp.Client, args blockchy
MerchantID: args.MerchantID,
DeleteProtected: args.DeleteProtected,
Notes: args.Notes,
CredentialType: args.CredType,
}

if args.Roles != "" {
Expand Down Expand Up @@ -2334,6 +2342,53 @@ func processAddTestMerchant(client *blockchyp.Client, args blockchyp.CommandLine
dumpResponse(&args, res)
}

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

req := &blockchyp.MerchantPlatform{}

if !parseJSONInput(args, req) {
handleError(&args, errors.New("unable to parse platform json"))
}
res, err := client.UpdateMerchantPlatforms(*req)
if err != nil {
handleError(&args, err)
}
dumpResponse(&args, res)
}

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

req := blockchyp.MerchantProfileRequest{
MerchantID: args.MerchantID,
}

res, err := client.MerchantPlatforms(req)
if err != nil {
handleError(&args, err)
}
dumpResponse(&args, res)
}

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

req := &blockchyp.AddGatewayMerchantRequest{}

if !parseJSONInput(args, req) {
validateRequired(args.CompanyName, "companyName")
req = &blockchyp.AddGatewayMerchantRequest{
Profile: blockchyp.MerchantProfile{
DBAName: args.DBAName,
CompanyName: args.CompanyName,
},
}
}
res, err := client.AddGatewayMerchant(*req)
if err != nil {
handleError(&args, err)
}
dumpResponse(&args, res)
}

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

req := &blockchyp.SlideShowRequest{}
Expand Down
56 changes: 56 additions & 0 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -4234,6 +4234,19 @@ type AddTestMerchantRequest struct {
Timeout int `json:"timeout"`
}

// AddGatewayMerchantRequest models basic information needed to create a
// gateway merchant.
type AddGatewayMerchantRequest struct {
// Test specifies whether or not to route transaction to the test gateway.
Test bool `json:"test"`

// Profile is the merchant profile to be boarded.
Profile MerchantProfile `json:"profile"`

// Timeout is the request timeout in seconds.
Timeout int `json:"timeout"`
}

// MerchantProfileRequest models a request for information about the merchant
// profile.
type MerchantProfileRequest struct {
Expand Down Expand Up @@ -4436,6 +4449,9 @@ type MerchantProfile struct {
// MerchantID is the merchant id.
MerchantID string `json:"merchantId"`

// BankMid is the primary bank mid.
BankMid string `json:"bankMid"`

// CompanyName is the merchant's company name.
CompanyName string `json:"companyName"`

Expand Down Expand Up @@ -4617,6 +4633,9 @@ type MerchantProfileResponse struct {
// MerchantID is the merchant id.
MerchantID string `json:"merchantId"`

// BankMid is the primary bank mid.
BankMid string `json:"bankMid"`

// CompanyName is the merchant's company name.
CompanyName string `json:"companyName"`

Expand Down Expand Up @@ -5321,6 +5340,36 @@ type MerchantPlatformsResponse struct {
Results []MerchantPlatform `json:"results"`
}

// UpdateMerchantPlatformRequest is used to up platform configuration for
// gateway merchants.
type UpdateMerchantPlatformRequest struct {
// Timeout is the request timeout in seconds.
Timeout int `json:"timeout"`

// Test specifies whether or not to route transaction to the test gateway.
Test bool `json:"test"`

// Platform is the merchant platform configuration.
Platform MerchantPlatform `json:"platform"`
}

// UpdateMerchantPlatformResponse echoes back the state of the current
// platform configuration after a change.
type UpdateMerchantPlatformResponse struct {
// Success indicates whether or not the request succeeded.
Success bool `json:"success"`

// Error is the error, if an error occurred.
Error string `json:"error"`

// ResponseDescription contains a narrative description of the transaction
// result.
ResponseDescription string `json:"responseDescription"`

// Platform is the current platform configuration.
Platform MerchantPlatform `json:"platform"`
}

// MerchantPlatform contains details about a merchant board platform
// configuration.
type MerchantPlatform struct {
Expand Down Expand Up @@ -7174,6 +7223,10 @@ type MerchantCredentialGenerationRequest struct {
// Notes free form description of the purpose or intent behind the
// credentials.
Notes string `json:"notes"`

// CredentialType type of credentials to generate, either API or TOKENIZING.
// Defaults to API.
CredentialType string `json:"credentialType"`
}

// MerchantCredentialGenerationResponse contains merchant api credential data.
Expand All @@ -7196,6 +7249,9 @@ type MerchantCredentialGenerationResponse struct {

// SigningKey is the merchant signing key.
SigningKey string `json:"signingKey"`

// TokenizingKey is the tokenizing key.
TokenizingKey string `json:"tokenizingKey"`
}

// BuyRateLineItem models a single buy rate calculation line item.
Expand Down
41 changes: 41 additions & 0 deletions pkg/examples/add_gateway_merchant_example.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package main

import (
"fmt"
"log"

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

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

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

// setup request object
request := blockchyp.AddGatewayMerchantRequest{
Profile: blockchyp.MerchantProfile{
DBAName: "DBA Name",
CompanyName: "Corporate Entity Name",
},
}

response, err := client.AddGatewayMerchant(request)

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

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

fmt.Printf("Response: %+v\n", response)
}
4 changes: 1 addition & 3 deletions pkg/examples/update_merchant_platforms_example.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ func updateMerchantPlatformsExample() {
client := blockchyp.NewClient(creds)

// setup request object
request := blockchyp.MerchantPlatform{
MerchantID: "XXXXXXXXXXXXX",
}
request := blockchyp.MerchantPlatform{}

response, err := client.UpdateMerchantPlatforms(request)

Expand Down
44 changes: 44 additions & 0 deletions pkg/itests/add_gateway_merchant_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//go:build integration
// +build integration

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

package itests

import (
"testing"

"github.com/stretchr/testify/assert"

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

func TestAddGatewayMerchant(t *testing.T) {
assert := assert.New(t)

config := loadTestConfiguration(t)
client := config.newTestClient(t, "partner")

// setup request object
request := blockchyp.AddGatewayMerchantRequest{
Profile: blockchyp.MerchantProfile{
DBAName: "DBA Name",
CompanyName: "Corporate Entity Name",
},
}

logObj(t, "Request:", request)

response, err := client.AddGatewayMerchant(request)

assert.NoError(err)

logObj(t, "Response:", response)

// response assertions
assert.True(response.Success)
}

0 comments on commit 2cb6e39

Please sign in to comment.