关于如何仅使用一个项目创建发票,有一个示例here,但如何添加更多?我已经尝试两次创建$ 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);
答案 0 :(得分:1)
在labs.bitpay.com上,Rich Morgans回答了我的问题,如何以编程方式创建可包含多个项目的帐单。它的工作方式略有不同。请阅读docs。你会发现the createRefund snippet很有用。您必须修改Client.php并将以下代码添加到Client类。
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);
答案 1 :(得分:0)
bitpay中的发票用于固定价格的发票。如果您想要多件物品,您将需要使用账单。我建议稍微阅读他们的休息api:
答案 2 :(得分:0)
因此,对于发票项目,它与您的本地发票不同。有一个名为&#39; posData&#39;的参数。您可以将其用作本地发票的传递。 Bitpay的发票应该反映它是第三方发票。所以你的订单项应该说
"Invoice 123123 for {{your company name}}" "$35.00"
或更具体的内容
"{{company}} service for July" "$35.00"
您应该在Bitpay之外跟踪自己的发票。您的计算和总计是否做出相关描述然后将其发送给Bitpay。