muyaedward / wbapp-bitpay
Bitpay wrapper for WritersBay App
Requires
- php: ^7.1
- bitpay/php-client: ~2.2
Requires (Dev)
- larapack/dd: ^1.0
- phpunit/phpunit: ^7.5
This package is not auto-updated.
Last update: 2025-03-01 08:30:00 UTC
README
Accept Bitcoin and Bitcoin Cash for your WritersBay App and BitPay client.
Installation
You can install the package via composer:
composer require muyaedward/wbapp-bitpay
Publish config file with:
php artisan vendor:publish --provider="Muyaedward\WbappBitpay\WbappBitpayServiceProvider"
Steps to configure and pair with BitPay Server
-
Add following keys to
.env
file and updated the details (view more about configuration):BITPAY_PRIVATE_KEY_PATH=/tmp/bitpay.pri BITPAY_PUBLIC_KEY_PATH=/tmp/bitpay.pub BITPAY_NETWORK=testnet BITPAY_KEY_STORAGE_PASSWORD=SomeRandomePasswordForKeypairEncryption BITPAY_TOKEN=
-
Create Test Account(for devlopement) or Live Account on BitPay.
-
Create new token for application(test account) or new token for application on BitPay and copy newly generated 7 character Pairing Code.
-
Create keypairs and pair your client(application) with BitPay server.
php artisan wbapp-bitpay:createkeypair yourPairingCode
Above command will generate private key, public key and save to your specified location. Next it will pair your client i.e. application with BitPay server referring your provided pairing code and create new token/key and will be saved in .env
.
- Done. ⛳
Usage
Create Invoice and checkout
public function createInvoice() { // Create instance of invoice $invoice = WbappBitpay::Invoice(); // Create instance of item $item = WbappBitpay::Item(); // Set item details $item->setCode('124') ->setDescription('Item 1') ->setPrice('1.99'); // Add item to invoice. (Only one item can be added) $invoice->setItem($item); // Order reference number from the point-of-sale (POS). // It should be a unique identifier for each order that you submit. $invoice->setPosData(uniqid()); // Optional // Create buyer instance $buyer = WbappBitpay::Buyer(); // Add buyer details $buyer->setFirstName('Vaibhav') ->setLastName('Roham'); // Add buyer to invoice $invoice->setBuyer($buyer); // Set currency for this invoice $invoice->setCurrency(WbappBitpay::Currency('USD')); // Create invoice on BitPay server $invoice = WbappBitpay::createInvoice($invoice); // Redirect URL on success $invoice->setRedirectUrl(route('bitpay-redirect-back')); // Webhook URL to receive various events $invoice->setNotificationUrl(route('bitpay-webhook')); // Redirect user to following URL for payment approval. // Or you can create stripe like checkout from https://bitpay.com/create-checkout $paymentUrl = $invoice->getUrl(); }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email muyaedward@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.