From 86bb6de77d961fcea8ac718cf507631761ed925a Mon Sep 17 00:00:00 2001 From: BlockChyp SDK Builder Date: Thu, 12 Sep 2024 15:11:39 +0000 Subject: [PATCH] Merge pull request #280 from blockchyp/feature/CHYP-3619 Feature/chyp 3619 --- README.md | 79 +++++++++++++++++++ .../AddGatewayMerchantExample.m | 26 ++++++ .../AddGatewayMerchantExample.swift | 24 ++++++ .../UpdateMerchantPlatformsExample.m | 1 - .../UpdateMerchantPlatformsExample.swift | 1 - blockchyp-ios/BlockChyp/BlockChyp.h | 3 + blockchyp-ios/BlockChyp/BlockChyp.m | 8 ++ blockchyp-ios/Tests/AddGatewayMerchantTest.m | 77 ++++++++++++++++++ 8 files changed, 217 insertions(+), 2 deletions(-) create mode 100644 blockchyp-ios-examples/AddGatewayMerchantExample.m create mode 100644 blockchyp-ios-examples/AddGatewayMerchantExample.swift create mode 100644 blockchyp-ios/Tests/AddGatewayMerchantTest.m diff --git a/README.md b/README.md index 1c6977e..420f02f 100644 --- a/README.md +++ b/README.md @@ -6522,6 +6522,85 @@ class ExampleClass { +#### 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. + + + +##### From Objective-C: + +```objective-c +#import +#import + +int main (int argc, const char * argv[]) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + BlockChyp *client = [[BlockChyp alloc] + initWithApiKey:@"SPBXTSDAQVFFX5MGQMUMIRINVI" + bearerToken:@"7BXBTBUPSL3BP7I6Z2CFU6H3WQ" + signingKey:@"bcae3708938cb8004ab1278e6c0fcd68f9d815e1c3c86228d028242b147af58e"]; + + NSMutableDictionary *request = [[NSMutableDictionary alloc] init]; + var profile: [String:Any] = [:] + profile["dbaName"] = "DBA Name" + profile["companyName"] = "Corporate Entity Name" + request["profile"] = profile + [client addGatewayMerchantWithRequest:request handler:^(NSDictionary *request, NSDictionary *response, NSError *error) { + NSNumber *success = [response objectForKey:@"success"]; + if (success.boolValue) { + NSLog(@"Success"); + } + }]; + [pool drain]; + return 0; +} + +``` + +##### From Swift: + +```swift +import BlockChyp + +class ExampleClass { + + func example() { + let client = BlockChyp.init( + apiKey: "ZN5WQGX5PN6BE2MF75CEAWRETM", + bearerToken: "SVVHJCYVFWJR2QKYKFWMZQVZL4", + signingKey: "7c1b9e4d1308e7bbe76a1920ddd9449ce50af2629f6bb70ed3c110365935970b" + ) + + var request: [String:Any] = [:] + var profile: [String:Any] = [:] + profile["dbaName"] = "DBA Name" + profile["companyName"] = "Corporate Entity Name" + request["profile"] = profile + client.addGatewayMerchant(withRequest: request, handler: { (request, response, error) in + let approved = response["success"] as? Bool + if (approved.unsafelyUnwrapped) { + NSLog("Success") + } + }) + } + + +``` + + + #### Add Test Merchant diff --git a/blockchyp-ios-examples/AddGatewayMerchantExample.m b/blockchyp-ios-examples/AddGatewayMerchantExample.m new file mode 100644 index 0000000..9e67ee9 --- /dev/null +++ b/blockchyp-ios-examples/AddGatewayMerchantExample.m @@ -0,0 +1,26 @@ +#import +#import + +int main (int argc, const char * argv[]) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + BlockChyp *client = [[BlockChyp alloc] + initWithApiKey:@"SPBXTSDAQVFFX5MGQMUMIRINVI" + bearerToken:@"7BXBTBUPSL3BP7I6Z2CFU6H3WQ" + signingKey:@"bcae3708938cb8004ab1278e6c0fcd68f9d815e1c3c86228d028242b147af58e"]; + + NSMutableDictionary *request = [[NSMutableDictionary alloc] init]; + var profile: [String:Any] = [:] + profile["dbaName"] = "DBA Name" + profile["companyName"] = "Corporate Entity Name" + request["profile"] = profile + [client addGatewayMerchantWithRequest:request handler:^(NSDictionary *request, NSDictionary *response, NSError *error) { + NSNumber *success = [response objectForKey:@"success"]; + if (success.boolValue) { + NSLog(@"Success"); + } + }]; + [pool drain]; + return 0; +} diff --git a/blockchyp-ios-examples/AddGatewayMerchantExample.swift b/blockchyp-ios-examples/AddGatewayMerchantExample.swift new file mode 100644 index 0000000..40f179a --- /dev/null +++ b/blockchyp-ios-examples/AddGatewayMerchantExample.swift @@ -0,0 +1,24 @@ +import BlockChyp + +class ExampleClass { + + func example() { + let client = BlockChyp.init( + apiKey: "ZN5WQGX5PN6BE2MF75CEAWRETM", + bearerToken: "SVVHJCYVFWJR2QKYKFWMZQVZL4", + signingKey: "7c1b9e4d1308e7bbe76a1920ddd9449ce50af2629f6bb70ed3c110365935970b" + ) + + var request: [String:Any] = [:] + var profile: [String:Any] = [:] + profile["dbaName"] = "DBA Name" + profile["companyName"] = "Corporate Entity Name" + request["profile"] = profile + client.addGatewayMerchant(withRequest: request, handler: { (request, response, error) in + let approved = response["success"] as? Bool + if (approved.unsafelyUnwrapped) { + NSLog("Success") + } + }) + } + diff --git a/blockchyp-ios-examples/UpdateMerchantPlatformsExample.m b/blockchyp-ios-examples/UpdateMerchantPlatformsExample.m index be23a66..c56d2f7 100644 --- a/blockchyp-ios-examples/UpdateMerchantPlatformsExample.m +++ b/blockchyp-ios-examples/UpdateMerchantPlatformsExample.m @@ -11,7 +11,6 @@ int main (int argc, const char * argv[]) signingKey:@"bcae3708938cb8004ab1278e6c0fcd68f9d815e1c3c86228d028242b147af58e"]; NSMutableDictionary *request = [[NSMutableDictionary alloc] init]; - request["merchantId"] = "XXXXXXXXXXXXX" [client updateMerchantPlatformsWithRequest:request handler:^(NSDictionary *request, NSDictionary *response, NSError *error) { NSNumber *success = [response objectForKey:@"success"]; if (success.boolValue) { diff --git a/blockchyp-ios-examples/UpdateMerchantPlatformsExample.swift b/blockchyp-ios-examples/UpdateMerchantPlatformsExample.swift index b3053b9..7e33302 100644 --- a/blockchyp-ios-examples/UpdateMerchantPlatformsExample.swift +++ b/blockchyp-ios-examples/UpdateMerchantPlatformsExample.swift @@ -10,7 +10,6 @@ class ExampleClass { ) var request: [String:Any] = [:] - request["merchantId"] = "XXXXXXXXXXXXX" client.updateMerchantPlatforms(withRequest: request, handler: { (request, response, error) in let approved = response["success"] as? Bool if (approved.unsafelyUnwrapped) { diff --git a/blockchyp-ios/BlockChyp/BlockChyp.h b/blockchyp-ios/BlockChyp/BlockChyp.h index 42e7d71..aff5c08 100644 --- a/blockchyp-ios/BlockChyp/BlockChyp.h +++ b/blockchyp-ios/BlockChyp/BlockChyp.h @@ -190,6 +190,9 @@ NS_ASSUME_NONNULL_BEGIN // Invites a user to join a merchant account. -(void)inviteMerchantUserWithRequest:(NSDictionary *)request handler:(BlockChypCompletionHandler)handler; +// Adds a live gateway merchant account. +-(void)addGatewayMerchantWithRequest:(NSDictionary *)request handler:(BlockChypCompletionHandler)handler; + // Adds a test merchant account. -(void)addTestMerchantWithRequest:(NSDictionary *)request handler:(BlockChypCompletionHandler)handler; diff --git a/blockchyp-ios/BlockChyp/BlockChyp.m b/blockchyp-ios/BlockChyp/BlockChyp.m index cf5d3e8..6e88844 100644 --- a/blockchyp-ios/BlockChyp/BlockChyp.m +++ b/blockchyp-ios/BlockChyp/BlockChyp.m @@ -408,6 +408,14 @@ -(void)inviteMerchantUserWithRequest:(NSDictionary *)request handler:(BlockChypC } +// Adds a live gateway merchant account. +-(void)addGatewayMerchantWithRequest:(NSDictionary *)request handler:(BlockChypCompletionHandler)handler { + + [self routeDashboardRequestWith:request path:@"/api/add-gateway-merchant" method:@"POST" handler:handler]; + +} + + // Adds a test merchant account. -(void)addTestMerchantWithRequest:(NSDictionary *)request handler:(BlockChypCompletionHandler)handler { diff --git a/blockchyp-ios/Tests/AddGatewayMerchantTest.m b/blockchyp-ios/Tests/AddGatewayMerchantTest.m new file mode 100644 index 0000000..bc7afe8 --- /dev/null +++ b/blockchyp-ios/Tests/AddGatewayMerchantTest.m @@ -0,0 +1,77 @@ +// Copyright 2019-2022 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. + +#import "BlockChypTest.h" + +@interface AddGatewayMerchantTest : BlockChypTest + + + +@end + +@implementation AddGatewayMerchantTest + +- (void)setUp { + + TestConfiguration *config = [self loadConfiguration]; + BlockChyp *client = [[BlockChyp alloc] initWithApiKey:config.apiKey bearerToken:config.bearerToken signingKey:config.signingKey]; + client.gatewayHost = config.gatewayHost; + client.testGatewayHost = config.testGatewayHost; + client.dashboardHost = config.dashboardHost; + + NSDictionary *profile = [config.profiles objectForKey:@"partner"]; + client.apiKey = (NSString*) [profile objectForKey:@"apiKey"]; + client.bearerToken = (NSString*) [profile objectForKey:@"bearerToken"]; + client.signingKey = (NSString*) [profile objectForKey:@"signingKey"]; + + +} + +- (void)tearDown { + +} + +- (void)testAddGatewayMerchant{ + + TestConfiguration *config = [self loadConfiguration]; + BlockChyp *client = [[BlockChyp alloc] initWithApiKey:config.apiKey bearerToken:config.bearerToken signingKey:config.signingKey]; + client.gatewayHost = config.gatewayHost; + client.testGatewayHost = config.testGatewayHost; + client.dashboardHost = config.dashboardHost; + + NSDictionary *profile = [config.profiles objectForKey:@"partner"]; + client.apiKey = (NSString*) [profile objectForKey:@"apiKey"]; + client.bearerToken = (NSString*) [profile objectForKey:@"bearerToken"]; + client.signingKey = (NSString*) [profile objectForKey:@"signingKey"]; + + XCTestExpectation *expectation = [self expectationWithDescription:@"AddGatewayMerchant Test"]; + + NSMutableDictionary *request = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *profile = [[NSMutableDictionary alloc] init]; + profile[@"dbaName"] = @"DBA Name"; + profile[@"companyName"] = @"Corporate Entity Name"; + request[@"profile"] = profile; + + [client addGatewayMerchantWithRequest:request handler:^(NSDictionary *request, NSDictionary *response, NSError *error) { + + [self logJSON:response]; + XCTAssertNotNil(response); + // response assertions + XCTAssertTrue([[response objectForKey:@"success"]boolValue]); + + [expectation fulfill]; + }]; + + @try { + [self waitForExpectationsWithTimeout:60 handler:nil]; + } + @catch (NSException *exception) { + NSLog(@"Exception:%@",exception); + } + +} + +@end