Skip to content

Commit 1166c5e

Browse files
committed
RT-5679 Create top-level merchant for each PM we onboard
1 parent da21a99 commit 1166c5e

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Paysafe\AccountManagement;
4+
5+
/**
6+
* Class Merchant
7+
* @package Paysafe\AccountManagement
8+
*
9+
* @property string $id
10+
* @property string $name
11+
* @property \Paysafe\Link[] $links
12+
*/
13+
class Merchant extends \Paysafe\JSONObject implements \Paysafe\Pageable {
14+
15+
public static function getPageableArrayKey() {
16+
return "merchant";
17+
}
18+
19+
protected static $fieldTypes = array(
20+
'id' => 'string',
21+
'name' => 'string',
22+
'links' => 'array:\Paysafe\Link'
23+
);
24+
}

source/Paysafe/MerchantAccountService.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Paysafe;
44

5+
use Paysafe\AccountManagement\Merchant;
56
use Paysafe\AccountManagement\MerchantAccount;
67
use Paysafe\AccountManagement\MerchantAccountAddress;
78
use Paysafe\AccountManagement\MerchantAccountBusinessOwner;
@@ -411,4 +412,25 @@ function createMerchantSubAccount(MerchantSubAccount $subAccount)
411412

412413
return new MerchantSubAccount($response);
413414
}
415+
416+
/**
417+
* Add merchant account
418+
* @param Merchant $merchant
419+
* @return Merchant
420+
* @throws PaysafeException
421+
*/
422+
function addMerchant(Merchant $merchant)
423+
{
424+
$merchant->setRequiredFields(array(
425+
'name'
426+
));
427+
$request = new Request(array(
428+
'method' => Request::POST,
429+
'uri' => $this->prepareURI('/merchants'),
430+
'body' => $merchant
431+
));
432+
$response = $this->client->processRequest($request);
433+
434+
return new Merchant($response);
435+
}
414436
}

0 commit comments

Comments
 (0)