This repository has been archived by the owner on Jan 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 149
Unable to create token #245
Comments
$storageEngine = new \Bitpay\Storage\FilesystemStorage();
$privateKey = $storageEngine->load('/tmp/bitpay.pri');
$publicKey = $storageEngine->load('/tmp/bitpay.pub');
/**
* Generate our SIN:
*/
$sin = \Bitpay\SinKey::create()->setPublicKey($publicKey)->generate();
/**
* Create the client:
*/
$client = new \Bitpay\Client\Client();
/**
* The network is either livenet or testnet. You
* can also create your own as long as it
* implements the NetworkInterface. In this
* example we will use testnet.
*/
$network = new \Bitpay\Network\Livenet();
/**
* The adapter is what will make the calls to
* BitPay and return the response from BitPay.
* This can be updated or changed as long
* as it implements the AdapterInterface.
*/
$adapter = new \Bitpay\Client\Adapter\CurlAdapter();
/**
* Now all the objects are created and we can
* inject them into the client.
*/
$client->setPrivateKey($privateKey);
$client->setPublicKey($publicKey);
$client->setNetwork($network);
$client->setAdapter($adapter);
/**
* Paste the pairing code you generated
* in your merchant dashboard in STEP 2:
*/
$pairingCode = 'uw5deZ4';
$token = $client->createToken(
array(
'pairingCode' => $pairingCode,
'label' => 'Some description...',
'id' => (string) $sin,
)
);
/**
* Now persist (save) the token obtained OR,
* after it's created initially, you can call the
* getTokens() method to retrieve all tokens
* associated with your key.
*/
$persistThisValue = $token->getToken();
echo 'Token obtained: ' . $persistThisValue . PHP_EOL; |
$client->createToken respond error: Unable to create token |
Please make sure you use a valid pairingCode, created with a valid BitPay merchant account on www.bitpay.com. The code examples from the tutorial show to catch the exception and print more info: |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Client.php line:505
The text was updated successfully, but these errors were encountered: