Skip to content

Commit

Permalink
Merge pull request #33 from colbyalbo/master
Browse files Browse the repository at this point in the history
Format app name for token label
  • Loading branch information
vrajroham authored Aug 24, 2021
2 parents 1d5fff2 + adeddab commit 546b43a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ BITPAY_TOKEN=
```

#### Add webhook event listener
By default package is capable of handling of webhook requests. Bitpay payment status updates are completely based on webhooks. Whenever webhook is received from server, `BitpayWebhookReceived` event is dispatched. You just need to provide a listener for this event.
By default, package is capable of handling of webhook requests. Bitpay payment status updates are completely based on webhooks. Whenever webhook is received from server, `BitpayWebhookReceived` event is dispatched. You just need to provide a listener for this event.

You can add your listener as below,
```php
Expand Down Expand Up @@ -126,7 +126,7 @@ class EventServiceProvider extends ServiceProvider{
+ SIN (Service Identification Number) for your client will be created to uniquely identify requests from your server.
+ By using SIN **new Token and Pairing Code** will be created for your client on bitpay server and will be shown on your console output.
+ Token will be used for all future request to bitpay and will automatically be copied to your `.env` file.
+ Based on environment you set **TEST/LIVE**, command will provide URL to approve your client and you need to copy and search Pairing Code on bitpay server & approve it.
+ Based on environment you set **TEST/LIVE**, command will provide URL to approve your client, and then you need to copy and search Pairing Code on bitpay server & approve it.

- You are all set. :golf:

Expand Down
10 changes: 5 additions & 5 deletions config/laravel-bitpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
* This is the full path and name for the private key.
* The default value is /tmp/laravel-bitpay.pri
*/
'private_key' => env('BITPAY_PRIVATE_KEY_PATH', '/tmp/laravel-bitpay.pri'),
'private_key' => env('BITPAY_PRIVATE_KEY_PATH', '/tmp/laravel-bitpay.pri'),

/*
* This is the full path and name for the public key.
* The default value is /tmp/laravel-bitpay.pub
*/
'public_key' => env('BITPAY_PUBLIC_KEY_PATH', '/tmp/laravel-bitpay.pub'),
'public_key' => env('BITPAY_PUBLIC_KEY_PATH', '/tmp/laravel-bitpay.pub'),

/*
* Specifies using the Live Bitcoin network or
* Test Bitcoin network: livenet or testnet.
*
* The default is livenet
*/
'network' => env('BITPAY_NETWORK', 'livenet'),
'network' => env('BITPAY_NETWORK', 'livenet'),

/*
* The key_storage option allows you to specify a class for persisting and retrieving keys.
*
* By default this uses the Bitpay\Storage\EncryptedFilesystemStorage class.
*/
'key_storage' => \BitPayKeyUtils\Storage\EncryptedFilesystemStorage::class,
'key_storage' => \BitPayKeyUtils\Storage\EncryptedFilesystemStorage::class,

/*
* This is the password used to encrypt and decrypt keys on the filesystem.
Expand All @@ -36,5 +36,5 @@
/*
* BitPay Token
*/
'token' => env('BITPAY_TOKEN', ''),
'token' => env('BITPAY_TOKEN', ''),
];
14 changes: 7 additions & 7 deletions src/Commands/CreateKeypair.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ public function handle()

$this->line('');

$this->line('<options=bold,underscore>Token</> - <options=bold;fg=green>'.$this->token.'</> //(Token copied to .env for you)');
$this->line('<options=bold,underscore>Pairing code</> - <options=bold;fg=green>'.$this->pairingCode.'</>');
$this->line('<options=bold,underscore>Token</> - <options=bold;fg=green>' . $this->token . '</> //(Token copied to .env for you)');
$this->line('<options=bold,underscore>Pairing code</> - <options=bold;fg=green>' . $this->pairingCode . '</>');

$this->line('');

$this->line('Please, copy the above pairing code and approve on your BitPay Account at the following link:');

$this->line('');

$this->line('Open -> <href='.$this->network.'/dashboard/merchant/api-tokens>'.$this->network.'/dashboard/merchant/api-tokens</>');
$this->line('Open -> <href=' . $this->network . '/dashboard/merchant/api-tokens>' . $this->network . '/dashboard/merchant/api-tokens</>');

$this->line('');

Expand Down Expand Up @@ -110,7 +110,7 @@ public function createAndPersistKeypair()
}

$this->bar->advance();
$this->info(' - Using <options=bold;fg=red>'.get_class($this->storageEngine).'</> for secure storage.');
$this->info(' - Using <options=bold;fg=red>' . get_class($this->storageEngine) . '</> for secure storage.');

$this->storageEngine->persist($this->privateKey);

Expand Down Expand Up @@ -144,17 +144,17 @@ public function pairWithServerAndCreateToken()
$this->info(' - Connecting Bitpay server 🖥️ and generating token & pairing code.');

try {
$this->pairingCodeLabel = config('app.name').'_BitPay_Client';
$this->pairingCodeLabel = ucwords(str_replace(" ", "_", config('app.name'))) . '_BitPay_Client';
$postData = [
'id' => (string) $this->sin,
'id' => (string)$this->sin,
'label' => $this->pairingCodeLabel,
'facade' => 'merchant',
];
$response = $bitpayClient->post('/tokens', [
'json' => $postData,
'headers' => [
'x-accept-version' => '2.0.0',
'Content-Type' => 'application/json',
'Content-Type' => 'application/json',
// Todo: If added below headers, bitpay responds with error, "This endpoint does not support the `user` facade"
// 'x-identity' => $this->publicKey->__toString(),
// 'x-signature' => $this->privateKey->sign($this->network.'/tokens'.json_encode($postData)),
Expand Down

0 comments on commit 546b43a

Please sign in to comment.