diff --git a/examples/payout_usage.php b/examples/payout_usage.php index d14ab46..9f471bb 100644 --- a/examples/payout_usage.php +++ b/examples/payout_usage.php @@ -113,7 +113,7 @@ public function markPayoutAsPaid() public function approvePayout() { - $payoutId =''; + $payoutId = ''; try { $client = new PullPayment($this->host, $this->apiKey); var_dump($client->approvePayout( diff --git a/examples/store_onchain_wallet.php b/examples/store_onchain_wallet.php index 99751ad..77a21e8 100644 --- a/examples/store_onchain_wallet.php +++ b/examples/store_onchain_wallet.php @@ -32,6 +32,21 @@ public function getStoreOnChainWalletOverview() } } + public function createStoreOnChainWallet() + { + $cryptoCode = 'BTC'; + + try { + $client = new StoreOnChainWallet($this->host, $this->apiKey); + var_dump($client->createStoreOnchainWallet( + $this->storeId, + $cryptoCode + )); + } catch (\Throwable $e) { + echo "Error: " . $e->getMessage(); + } + } + public function getStoreOnChainWalletFeeRate() { $cryptoCode = 'BTC'; @@ -171,3 +186,4 @@ public function getStoreOnChainWalletUTXOs() $store->getStoreOnChainWalletTransactions(); //$store->getStoreOnChainWalletTransaction(); //$store->getStoreOnChainWalletUTXOs(); +//$store->createStoreOnChainWallet(); diff --git a/src/Client/InvoiceCheckoutOptions.php b/src/Client/InvoiceCheckoutOptions.php index e88d562..144ea0b 100644 --- a/src/Client/InvoiceCheckoutOptions.php +++ b/src/Client/InvoiceCheckoutOptions.php @@ -170,7 +170,7 @@ public function toArray(): array $lastIndex = strrpos($k, $separator); if ($lastIndex !== false) { - $k = substr($k, $lastIndex +1); + $k = substr($k, $lastIndex + 1); } $array[$k] = $v; } diff --git a/src/Client/StoreOnChainWallet.php b/src/Client/StoreOnChainWallet.php index 4633f54..0315a5c 100644 --- a/src/Client/StoreOnChainWallet.php +++ b/src/Client/StoreOnChainWallet.php @@ -35,6 +35,50 @@ public function getStoreOnChainWalletOverview( } } + public function createStoreOnChainWallet( + string $storeId, + string $cryptoCode, + ?string $existingMnemonic = null, + ?string $passphrase = null, + int $accountNumber = 0, + bool $savePrivateKeys = false, + bool $importKeysToRPC = false, + string $wordList = 'English', + int $wordCount = 12, + string $scriptPubKeyType = 'Segwit' + ): ResultStoreOnChainWallet { + $url = $this->getApiUrl() . 'stores/' . + urlencode($storeId) . '/payment-methods/onchain/' . + urlencode($cryptoCode) . '/generate'; + + $headers = $this->getRequestHeaders(); + $method = 'POST'; + + $body = json_encode( + [ + 'existingMnemonic' => $existingMnemonic, + 'passphrase' => $passphrase, + 'accountNumber' => $accountNumber, + 'savePrivateKeys' => $savePrivateKeys, + 'importKeysToRPC' => $importKeysToRPC, + 'wordList' => $wordList, + 'wordCount' => $wordCount, + 'scriptPubKeyType' => $scriptPubKeyType + ], + JSON_THROW_ON_ERROR + ); + + $response = $this->getHttpClient()->request($method, $url, $headers, $body); + + if ($response->getStatus() === 200) { + return new ResultStoreOnChainWallet( + json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR) + ); + } else { + throw $this->getExceptionByStatusCode($method, $url, $response); + } + } + public function getStoreOnChainWalletFeeRate( string $storeId, string $cryptoCode,