Here's the exact request data you can use to create your bill and the successful response data returned from our gateway:
[request] => {"items":[{"description":"somecooldescription","price":1.45,"quantity":5}],"guid":"6eae4e0e-e8cf-386e-f767-79c43de60806","nonce":1422407765.2744,"token":"7U24AhTLM3A36iN4bUsEvcEcxB8UeEPSn7ghEYuCbkoc"}
[response] => {"facade":"merchant/bill","data":{"id":"AZwvMKsLuYyxisfVJqLUsD","status":"draft","items":[{"price":1.45,"quantity":5,"description":"somecooldescription"}],"createdDate":"2015-01-28T01:13:00.088Z","currency":"BTC","token":"6Qo7YAcW1b4LBXmSo9UB6izPHs3BHZSCBt8fNhvo2DQEGTZajySqBafWuSxBLCti9w"}}
Here's the slightly modified Client::createBill()
function used for this example:
public function createBill(\Bitpay\Bill $bill)
{
$request = $this->createNewRequest();
$request->setMethod(Request::METHOD_POST);
$request->setPath('bills');
$body = array(
'items' => array(array('description' => 'somecooldescription', 'price' => 1.45, 'quantity' => 5)),
'guid' => Util::guid(),
'nonce' => Util::nonce(),
'token' => '7U24AhTLM3A36iN4bUsEvcEcxB8UeEPSn7ghEYuCbkoc',
);
$request->setBody(json_encode($body));
$this->addIdentityHeader($request);
$this->addSignatureHeader($request);
$this->request = $request;
$this->response = $this->sendRequest($request);
$response = json_decode($this->response->getBody(), true);
return array('request' => json_encode($body), 'response' => $this->response->getBody());
}
And here's the contents of my billtest.php
script used for this exercise:
array(
'network' => 'testnet',
'public_key' => '/tmp/public.key',
'private_key' => '/tmp/private.key',
'key_storage' => 'Bitpay\Storage\FilesystemStorage',
)
)
);
$client = $bitpay->get('client');
$tokens = $client->getTokens();
$client->setAdapter(new \Bitpay\Client\Adapter\CurlAdapter());
$bill = new \Bitpay\Bill;
$info = $client->createBill($bill);
print_r($info);
Comments
0 comments
Article is closed for comments.