有一个关于如何创建只有一个项目的发票的示例这里,但是如何添加更多?我尝试过两次创建$item并将其添加到$invoice中,但没有成功。API不接受它。
摘录自上面的例子:
/**
* Code that makes the invoice
*/
$invoice = new \Bitpay\Invoice();
$item = new \Bitpay\Item();
$item
->setCode('skuNumber')
->setDescription('General Description of Item')
->setPrice('1.99');
$invoice->setCurrency(new \Bitpay\Currency('USD'));
$client = $bitpay->get('client');
$client->setToken($token);
$client->createInvoice($invoice);发布于 2015-06-10 08:43:05
在labs.bitpay.com上,Rich回答了我的问题,如何以编程方式创建账单,其中可以包含多个项目。它的工作原理轻盈不同。请阅读文档。您会发现createRefund片段很有用。您必须修改Client.php并将以下代码添加到客户端类中。
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());
}你这样叫它
<?php
require __DIR__ . '/../vendor/autoload.php';
$bitpay = new \Bitpay\Bitpay(
array(
'bitpay' => 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);发布于 2015-05-07 14:35:01
bitpay中的发票用于固定定价的发票。如果你想要有多个项目,你会想要使用一张账单。我建议多读一下他们的rest:
发布于 2015-06-09 17:27:56
因此,发票项与当地发票不同。有一个名为“posData”的参数,您可以使用它作为本地发票的传递。比特支付的发票应反映它是第三方发票。所以你的项目应该说
"Invoice 123123 for {{your company name}}" "$35.00"
或者更具体的东西
"{{company}} service for July" "$35.00"
你应该在Bitpay之外追踪你自己的发票。进行计算和汇总,做出相关说明,然后将其发送到Bitpay。
https://stackoverflow.com/questions/30103801
复制相似问题