Compare commits

..

2 Commits

Author SHA1 Message Date
Kukks
b2d8071910 add remaining areas for redirect auto 2019-05-02 10:42:17 +02:00
Andrew Camilleri
bd9731a688
Add Redirect Automatically option 2019-05-01 14:52:31 +02:00
8 changed files with 1657 additions and 1262 deletions

View File

@ -1,7 +1,3 @@
# === 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
=================

View File

@ -103,6 +103,7 @@ 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

@ -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\CurrencyUnrestricted($data['currency']))
->setCurrency(new \Bitpay\Currency($data['currency']))
->setOrderId(array_key_exists('orderId', $data) ? $data['orderId'] : '')
->setInvoiceTime($invoiceTime)
->setExpirationTime($expirationTime)
@ -164,6 +164,7 @@ class Client implements ClientInterface
'transactionSpeed' => $invoice->getTransactionSpeed(),
'fullNotifications' => $invoice->isFullNotifications(),
'extendedNotifications' => $invoice->isExtendedNotifications(),
'redirectAutomatically' => $invoice->isRedirectAutomatically(),
'notificationEmail' => $invoice->getNotificationEmail(),
'redirectURL' => $invoice->getRedirectUrl(),
'orderID' => $invoice->getOrderId(),
@ -183,7 +184,6 @@ class Client implements ClientInterface
'guid' => Util::guid(),
'nonce' => Util::nonce(),
'token' => $this->token->getToken(),
'paymentCurrencies' => $invoice->getPaymentCurrencies(),
);
foreach(array_keys($body) as $key) {

View File

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

View File

@ -1,16 +0,0 @@
<?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

@ -66,7 +66,10 @@ class Invoice implements InvoiceInterface
* @var boolean
*/
protected $extendedNotifications = false;
/**
* @var boolean
*/
protected $redirectAutomatically = false;
/**
* @var string
*/
@ -155,10 +158,6 @@ class Invoice implements InvoiceInterface
*/
protected $paymentTotals;
/**
* @var array
*/
protected $paymentCurrencies;
/**
* @inheritdoc
@ -443,6 +442,21 @@ class Invoice implements InvoiceInterface
return $this;
}
/**
* @inheritdoc
*/
public function isRedirectAutomatically()
{
return $this->redirectAutomatically;
}
public function setRedirectAutomatically($redirectAutomatically)
{
$this->redirectAutomatically = (boolean) $redirectAutomatically;
return $this;
}
/**
* @inheritdoc
@ -923,21 +937,4 @@ 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

@ -185,7 +185,14 @@ interface InvoiceInterface
* @return boolean
*/
public function isExtendedNotifications();
/**
* default value: false
* true: Redirect from the checkout UI to the set redirect url
* false: checkout UIwill not redirect but will display a button with a link to the set redirect url
*
* @return boolean
*/
public function isRedirectAutomatically();
/**
* The unique id of the invoice assigned by bitpay.com
*
@ -379,22 +386,4 @@ 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);
}