setCode('skuNumber') ->setDescription('General Description of Item') ->setPrice('1.99'); /** * Create Buyer object that will be used later. */ $buyer = new \Bitpay\Buyer(); $buyer ->setFirstName('Some') ->setLastName('Customer') ->setPhone('555-5555-5555') ->setEmail('test@test.com') ->setAddress( array( '123 Main St', 'Suite 1', ) ) ->setCity('Atlanta') ->setState('GA') ->setZip('30120') ->setCountry('US'); /** * Create the invoice */ $invoice = new \Bitpay\Invoice(); // Add the item to the invoice $invoice->setItem($item); // Add the buyers info to invoice $invoice->setBuyer($buyer); // Configure the rest of the invoice $invoice ->setOrderId('OrderIdFromYourSystem') // You will receive IPN's at this URL, should be HTTPS for security purposes! ->setNotificationUrl('https://store.example.com/bitpay/callback'); /** * BitPay offers services for many different currencies. You will need to * configure the currency in which you are selling products with. */ $currency = new \Bitpay\Currency(); $currency->setCode('USD'); // Set the invoice currency $invoice->setCurrency($currency); /** * To load up keys that you have previously saved, you need to use the same * storage engine. You also need to tell it the location of the key you want * to load. */ $storageEngine = new \Bitpay\Storage\FilesystemStorage(); $privateKey = $storageEngine->load('/tmp/private.key'); $publicKey = $storageEngine->load('/tmp/public.key'); /** * Create a new client. */ $bitpay = new \Bitpay\Bitpay(); /** * Create the client that will be used to send requests to BitPay's API */ $client = $bitpay->get('client'); $client->setPrivateKey($privateKey); $client->setPublicKey($publicKey); /** * Add your btcpayserver url */ $client->setUri('https://btcpay.server/'); /** * You will need to set the token that was returned when you paired your * keys. */ $token = new \Bitpay\Token(); $token->setToken('your token here'); $client->setToken($token); // Send invoice $client->createInvoice($invoice); var_dump( (string) $client->getRequest(), (string) $client->getResponse(), $invoice );