Compare commits

...

19 Commits

Author SHA1 Message Date
Nicolas Dorier
4c0bf5a5bf
Update README.md 2021-11-08 21:02:40 +09:00
nicolas.dorier
75bd0f95f5
bump version 2021-10-03 10:42:34 +09:00
Nicolas Dorier
d59411a396
Merge pull request #23 from ndeet/patch-1
Fix Lets Encrypt root cert error
2021-10-03 10:40:16 +09:00
Andreas Tasch
16862d2ed6
Fix Lets Encrypt root cert error
@NicolasDorier 

Do not use the custom ca-bundle.crt as it contains outdated certs and there is no obvious reason imo to why even use it at all. Normally the system ssl library is good enough for major SSL certs to work. Maybe Bitpay had some need for self signed certs or something to even do that.

Note: just did edit in the web UI and not delete the ca-bundle.crt file for now.

Context:
https://chat.btcpayserver.org/btcpayserver/pl/cm9itj98hfbr9jgiq4t38hkeuw

including the comments afterwards of another user that tried this fix successfully.

Todo: after merging this somebody needs to do a WooCommerce plugin release, not sure who is in charge of that atm.
2021-10-02 22:52:09 +02:00
Andrew Camilleri
3b161c5d00
Merge pull request #22 from ndeet/allow-any-currency
Allow any currency symbol via overloaded class.
2021-01-29 12:24:57 +01:00
Andrew Camilleri
ca9e77e5df
Merge pull request #21 from ndeet/payment-currencies
Support for payment currencies.
2021-01-29 12:24:28 +01:00
Andreas Tasch
01057e8da8 Make sure to use CurrencyUnrestricted here to not break IPN callback. 2021-01-26 14:22:46 +01:00
Andreas Tasch
5522adcf5e Allow any currency symbol via overloaded class. 2021-01-26 13:28:07 +01:00
Andreas Tasch
c41360a6e2 Support for payment currencies. 2021-01-26 13:24:33 +01:00
nicolas.dorier
7815bc0312
bump ca 2020-07-17 21:07:10 +09:00
nicolas.dorier
79ac751e54 fix version 2019-04-23 16:33:13 +09:00
nicolas.dorier
3e0425497c do not try to clean orderId 2019-04-23 15:35:12 +09:00
Nicolas Dorier
1e08ee7c91
Merge pull request #16 from kakaska/fix-get-invoice-tutorial
Fix getInvoice.php and IPNlogger.php tutorial
2019-02-26 13:44:43 +09:00
kakaska
f04618c667 Fix IPNlogger.php tutorial 2019-02-25 22:27:17 +01:00
kakaska
8b3f1663f1 Fix getInvoice.php tutorial 2019-02-25 19:00:35 +01:00
Nicolas Dorier
43076fdd9b
Merge pull request #12 from psyb0t/fix/remove-null-props-when-creating-invoice
Check body object keys for null value and unset them if found
2019-02-21 18:21:35 +09:00
Ciprian Mandache
79d1f1e51b Check body object keys for null value and unset them if found 2019-02-21 11:07:40 +02:00
Nicolas Dorier
36578f803c
Merge pull request #8 from kakaska/update-readme
Update README.md installation section
2019-02-17 20:34:00 +09:00
kakaska
dbc3aeec94 Update README.md installation section 2019-02-17 11:40:35 +01:00
10 changed files with 1293 additions and 1641 deletions

View File

@ -1,3 +1,7 @@
# === Warning ===
This is the old BitPay based PHP client and should be considered deprecated (even though it currently still works). If you are building something from scratch, [use the new Greenfield API](https://github.com/btcpayserver/btcpayserver-greenfield-php).
bitpay/php-bitpay-client
=================
@ -33,8 +37,15 @@ Add to your composer.json file by hand.
...
"require": {
...
"bitpay/php-client": "~2.2"
}
"bitpay/php-client": "dev-master"
},
"repositories": [
...
{
"type": "vcs",
"url": "https://github.com/btcpayserver/php-bitpay-client"
}
],
...
}
```

View File

@ -34,7 +34,7 @@ if (true === empty($ipn)) {
throw new \Exception('Could not decode the JSON payload from BitPay.');
}
if (true === empty($ipn -> id)) {
if (true === empty($ipn->id)) {
fwrite($myfile, $date . " : Error. Invalid Bitpay payment notification message received - did not receive invoice ID.\n");
fclose($myfile);
throw new \Exception('Invalid Bitpay payment notification message received - did not receive invoice ID.');
@ -42,15 +42,20 @@ if (true === empty($ipn -> id)) {
// Now fetch the invoice from BitPay
// This is needed, since the IPN does not contain any authentication
$storageEngine = new \Bitpay\Storage\EncryptedFilesystemStorage('YourTopSecretPassword');
$privateKey = $storageEngine->load('/tmp/bitpay.pri');
$publicKey = $storageEngine->load('/tmp/bitpay.pub');
$client = new \Bitpay\Client\Client();
$adapter = new \Bitpay\Client\Adapter\CurlAdapter();
$client->setPrivateKey($privateKey);
$client->setPublicKey($publicKey);
$client->setUri('https://btcpay.server/');
$client->setAdapter($adapter);
$token = new \Bitpay\Token();
$token->setToken('UpdateThisValue'); // UPDATE THIS VALUE
$client->setToken($token);
$token->setFacade('merchant');
/**
* This is where we will fetch the invoice object

View File

@ -15,13 +15,19 @@ require __DIR__.'/../../vendor/autoload.php';
// Now fetch the invoice from BitPay
$storageEngine = new \Bitpay\Storage\EncryptedFilesystemStorage('YourTopSecretPassword');
$privateKey = $storageEngine->load('/tmp/bitpay.pri');
$publicKey = $storageEngine->load('/tmp/bitpay.pub');
$client = new \Bitpay\Client\Client();
$adapter = new \Bitpay\Client\Adapter\CurlAdapter();
$client->setPrivateKey($privateKey);
$client->setPublicKey($publicKey);
$client->setUri('https://btcpay.server/');
$client->setAdapter($adapter);
$token = new \Bitpay\Token();
$token->setToken('UpdateThisValue'); // UPDATE THIS VALUE
$token->setFacade('merchant');
$client->setToken($token);

View File

@ -103,7 +103,6 @@ class CurlAdapter implements AdapterInterface
CURLOPT_TIMEOUT => 10,
CURLOPT_SSL_VERIFYPEER => 1,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_CAINFO => __DIR__.'/ca-bundle.crt',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FORBID_REUSE => 1,
CURLOPT_FRESH_CONNECT => 1,

File diff suppressed because it is too large Load Diff

View File

@ -111,7 +111,7 @@ class Client implements ClientInterface
$invoiceTime = is_numeric($data['invoiceTime']) ? intval($data['invoiceTime']/1000) : $data['invoiceTime'];
$expirationTime = is_numeric($data['expirationTime']) ? intval($data['expirationTime']/1000) : $data['expirationTime'];
$currentTime = is_numeric($data['currentTime']) ? intval($data['currentTime']/1000) : $data['currentTime'];
$invoiceToken = new \Bitpay\Token();
$invoice
->setToken($invoiceToken->setToken($data['token']))
@ -121,7 +121,7 @@ class Client implements ClientInterface
->setBtcPrice(array_key_exists('btcPrice', $data) ? $data['btcPrice'] : '')
->setPrice($data['price'])
->setTaxIncluded($data['taxIncluded'])
->setCurrency(new \Bitpay\Currency($data['currency']))
->setCurrency(new \Bitpay\CurrencyUnrestricted($data['currency']))
->setOrderId(array_key_exists('orderId', $data) ? $data['orderId'] : '')
->setInvoiceTime($invoiceTime)
->setExpirationTime($expirationTime)
@ -183,8 +183,15 @@ class Client implements ClientInterface
'guid' => Util::guid(),
'nonce' => Util::nonce(),
'token' => $this->token->getToken(),
'paymentCurrencies' => $invoice->getPaymentCurrencies(),
);
foreach(array_keys($body) as $key) {
if(null === $body[$key]) {
unset($body[$key]);
}
}
$request->setBody(json_encode($body));
$this->addIdentityHeader($request);
$this->addSignatureHeader($request);
@ -598,7 +605,7 @@ class Client implements ClientInterface
}
$data = $body['data'];
$invoice = new \Bitpay\Invoice();
$invoice = $this->fillInvoiceData($invoice, $data);
@ -606,7 +613,7 @@ class Client implements ClientInterface
}
/**

View File

@ -25,8 +25,8 @@ interface ClientInterface
*
* @see RFC2616 section 14.43 for User-Agent Format
*/
const NAME = 'BitPay PHP-Client';
const VERSION = '2.2.20';
const NAME = 'BitPay PHP-Client BTCPAY';
const VERSION = '2.2.23';
//public function createApplication(ApplicationInterface $application);

View File

@ -0,0 +1,16 @@
<?php
namespace Bitpay;
class CurrencyUnrestricted extends Currency
{
/**
* Overrides the parent method to allow any currency symbol to be set.
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
}

View File

@ -155,6 +155,10 @@ class Invoice implements InvoiceInterface
*/
protected $paymentTotals;
/**
* @var array
*/
protected $paymentCurrencies;
/**
* @inheritdoc
@ -598,10 +602,7 @@ class Invoice implements InvoiceInterface
*/
public function setOrderId($orderId)
{
if (!empty($orderId) && ctype_print($orderId)) {
$this->orderId = trim($orderId);
}
$this->orderId = $orderId;
return $this;
}
@ -922,4 +923,21 @@ class Invoice implements InvoiceInterface
return $this;
}
/**
* @inheritdoc
*/
public function getPaymentCurrencies() {
return $this->paymentCurrencies;
}
/**
* @inheritdoc
*/
public function setPaymentCurrencies($paymentCurrencies) {
$this->paymentCurrencies = $paymentCurrencies;
return $this;
}
}

View File

@ -379,4 +379,22 @@ interface InvoiceInterface
* @return array|object
*/
public function getRefundAddresses();
/**
* Get the enforced transaction currencies.
*
* @return array|null
*/
public function getPaymentCurrencies();
/**
* Set specific invoice currencies and to enforce them on payment step.
*
* @param array $paymentCurrencies
* The currencies need to match what is supported by BTCPay Server.
* E.g. BTC, BTC_ONCHAIN, BTC_OFFCHAIN, LTC, XMR_MONEROLIKE etc.
*
* @return InvoiceInterface
*/
public function setPaymentCurrencies($paymentCurrencies);
}