Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6bc1d5632 | ||
|
|
f09c8cbc7c | ||
|
|
1a54b0cd4a | ||
|
|
0288b502c1 | ||
|
|
0d6e5519ca | ||
|
|
2a1e6984bd | ||
|
|
6c3da16ce9 |
14
composer.lock
generated
14
composer.lock
generated
@ -4,20 +4,20 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "0411678fc60196f00a3748362d083e80",
|
||||
"content-hash": "bdf8d088a05991246e9aa2f8ec35d506",
|
||||
"packages": [
|
||||
{
|
||||
"name": "btcpayserver/btcpayserver-greenfield-php",
|
||||
"version": "v1.3.3",
|
||||
"version": "v1.3.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/btcpayserver/btcpayserver-greenfield-php.git",
|
||||
"reference": "aff6ab92151431c2faa63c72805aa60736b0deea"
|
||||
"reference": "cc9ab93a8ecda8a8158b717f11ff37dfa5ab8962"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/btcpayserver/btcpayserver-greenfield-php/zipball/aff6ab92151431c2faa63c72805aa60736b0deea",
|
||||
"reference": "aff6ab92151431c2faa63c72805aa60736b0deea",
|
||||
"url": "https://api.github.com/repos/btcpayserver/btcpayserver-greenfield-php/zipball/cc9ab93a8ecda8a8158b717f11ff37dfa5ab8962",
|
||||
"reference": "cc9ab93a8ecda8a8158b717f11ff37dfa5ab8962",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -55,9 +55,9 @@
|
||||
"description": "BTCPay Server Greenfield API PHP client library.",
|
||||
"support": {
|
||||
"issues": "https://github.com/btcpayserver/btcpayserver-greenfield-php/issues",
|
||||
"source": "https://github.com/btcpayserver/btcpayserver-greenfield-php/tree/v1.3.3"
|
||||
"source": "https://github.com/btcpayserver/btcpayserver-greenfield-php/tree/v1.3.6"
|
||||
},
|
||||
"time": "2022-05-21T15:11:12+00:00"
|
||||
"time": "2022-09-12T21:30:25+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
|
||||
@ -87,6 +87,7 @@ class ControllerExtensionPaymentBTCPay extends Controller {
|
||||
'payment_btcpay_api_auth_token',
|
||||
'payment_btcpay_btcpay_storeid',
|
||||
'payment_btcpay_webhook',
|
||||
'payment_btcpay_modal_mode',
|
||||
'payment_btcpay_webhook_delete',
|
||||
'payment_btcpay_new_status_id',
|
||||
'payment_btcpay_paid_status_id',
|
||||
|
||||
@ -16,6 +16,7 @@ $_['entry_btcpay_storeid'] = 'BTCPay Store ID';
|
||||
$_['entry_webhook'] = 'Webhook Data';
|
||||
$_['entry_webhook_secret'] = 'Webhook Secret';
|
||||
$_['entry_webhook_delete'] = 'Delete Webhook';
|
||||
$_['entry_modal_mode'] = 'Modal/iFrame mode';
|
||||
$_['entry_total'] = 'Total';
|
||||
$_['entry_geo_zone'] = 'Geo Zone';
|
||||
$_['entry_sort_order'] = 'Sort Order';
|
||||
@ -33,6 +34,7 @@ $_['entry_debug_mode'] = 'Debug mode';
|
||||
|
||||
$_['help_btcpay_url'] = 'The public URL of your BTCPay Server instance. e.g. https://demo.mainnet.btcpayserver.org. You need to have a BTCPay Server instance running, see "Requirements" for several options of deployment on our <a href="https://docs.btcpayserver.org/OpenCart" target="_blank" rel="noopener">setup guide</a>.';
|
||||
$_['help_webhook'] = 'The webhook will get created automatically after you entered BTCPay Server URL, API Key and Store ID. If you see this field filled with data (after you saved the form) all went well.';
|
||||
$_['help_modal_mode'] = 'If enabled the invoice will be shown in a modal/overlay (iFrame). Default behaviour is that the user will get redirected to BTCPay Server invoice page.';
|
||||
$_['help_webhook_delete'] = 'This is useful if you switch hosts or have problems with webhooks. When checked this will delete the webhook on OpenCart (and BTCPay Server if possible). Make sure to delete the webhook on BTCPay Server Store settings too if not done automatically. <strong>ATTENTION:</strong> You need to edit and <strong>save</strong> this settings page again so a new webhook gets created on BTCPay Server.';
|
||||
$_['help_total'] = 'The checkout total the order must reach before this payment method becomes active.';
|
||||
$_['help_debug_mode'] = 'If enabled debug output will be saved to the error logs found in System -> Maintenance -> Error logs. Should be disabled after debugging.';
|
||||
|
||||
@ -109,6 +109,16 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="input-modal-mode">{{ entry_modal_mode }}</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="checkbox" name="payment_btcpay_modal_mode" value="1" id="input-modal-mode" class="form-control" {% if payment_btcpay_modal_mode %} checked="checked" {% endif %} />
|
||||
<div class="help-block">
|
||||
{{ help_modal_mode }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="input-new-status">{{ entry_new_status }}</label>
|
||||
<div class="col-sm-10">
|
||||
|
||||
@ -15,6 +15,7 @@ class ControllerExtensionPaymentBTCPay extends Controller
|
||||
{
|
||||
$this->load->language('extension/payment/btcpay');
|
||||
$this->load->model('checkout/order');
|
||||
$useModal = $this->config->get('payment_btcpay_modal_mode');
|
||||
|
||||
$data['button_confirm'] = $this->language->get('button_confirm');
|
||||
$data['action'] = $this->url->link(
|
||||
@ -23,7 +24,18 @@ class ControllerExtensionPaymentBTCPay extends Controller
|
||||
true
|
||||
);
|
||||
|
||||
return $this->load->view('extension/payment/btcpay', $data);
|
||||
if ($useModal) {
|
||||
$host = $this->config->get('payment_btcpay_url');
|
||||
$data['btcpay_host'] = $host;
|
||||
$data['modal_url'] = $host . '/modal/btcpay.js';
|
||||
$data['success_link'] = $this->url->link('checkout/success', '', true);
|
||||
$data['invoice_expired_text'] = $this->language->get('invoice_expired_text');
|
||||
|
||||
return $this->load->view('extension/payment/btcpay_modal', $data);
|
||||
} else {
|
||||
// Redirect.
|
||||
return $this->load->view('extension/payment/btcpay', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function checkout()
|
||||
@ -32,87 +44,51 @@ class ControllerExtensionPaymentBTCPay extends Controller
|
||||
$this->load->model('extension/payment/btcpay');
|
||||
|
||||
$debug = $this->config->get('payment_btcpay_debug_mode');
|
||||
$useModal = $this->config->get('payment_btcpay_modal_mode');
|
||||
|
||||
if ($debug) {
|
||||
$this->log->write('Entering checkout() of BTCPay catalog controller.');
|
||||
$this->log->write('Session data:');
|
||||
$this->log->write(print_r($this->session->data, true));
|
||||
}
|
||||
|
||||
$metadata = [];
|
||||
$token = md5(uniqid(rand(), true));
|
||||
|
||||
if (!isset($this->session->data['order_id'])) {
|
||||
$this->log->write('No session data order_id present, aborting.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$order_info = $this->model_checkout_order->getOrder(
|
||||
$this->session->data['order_id']
|
||||
);
|
||||
|
||||
// Set included tax amount.
|
||||
//// $metadata['taxIncluded'] = $order->get_cart_tax();
|
||||
$invoiceId = '';
|
||||
$checkoutLink = '';
|
||||
|
||||
// POS metadata.
|
||||
////todo: $metadata['posData'] = $this->preparePosMetadata( $order );
|
||||
// First, check if we have an existing and not expired wallet and do not create a new one.
|
||||
if ($existingInvoice = $this->orderHasExistingInvoice($order_info)) {
|
||||
$invoiceId = $existingInvoice->getId();
|
||||
$checkoutLink = $existingInvoice->getCheckoutLink();
|
||||
|
||||
// Checkout options.
|
||||
$checkoutOptions = new InvoiceCheckoutOptions();
|
||||
$redirectUrl = $this->url->link(
|
||||
'extension/payment/btcpay/success',
|
||||
['token' => $token],
|
||||
true
|
||||
);
|
||||
|
||||
$checkoutOptions->setRedirectURL(htmlspecialchars_decode($redirectUrl));
|
||||
if ($debug) {
|
||||
$this->log->write( 'Setting redirect url to: ' . $redirectUrl );
|
||||
}
|
||||
|
||||
// Calculate total and format it properly.
|
||||
$total = number_format(
|
||||
$order_info['total'] * $this->currency->getvalue(
|
||||
$order_info['currency_code']
|
||||
),
|
||||
8,
|
||||
'.',
|
||||
''
|
||||
);
|
||||
$amount = PreciseNumber::parseString(
|
||||
$total
|
||||
); // unlike method signature suggests, it returns string.
|
||||
|
||||
// API credentials.
|
||||
$apiKey = $this->config->get('payment_btcpay_api_auth_token');
|
||||
$host = $this->config->get('payment_btcpay_url');
|
||||
$storeId = $this->config->get('payment_btcpay_btcpay_storeid');
|
||||
|
||||
// Create the invoice on BTCPay Server.
|
||||
$client = new Invoice($host, $apiKey);
|
||||
try {
|
||||
$invoice = $client->createInvoice(
|
||||
$storeId,
|
||||
$order_info['currency_code'],
|
||||
$amount,
|
||||
$order_info['order_id'],
|
||||
null, // this is null here as we handle it in the metadata.
|
||||
$metadata,
|
||||
$checkoutOptions
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
$this->log->write($e->getMessage());
|
||||
}
|
||||
|
||||
if ($invoice->getData()['id']) {
|
||||
$this->model_extension_payment_btcpay->addOrder([
|
||||
'order_id' => $order_info['order_id'],
|
||||
'token' => $token,
|
||||
'invoice_id' => $invoice->getData(
|
||||
)['id'],
|
||||
]);
|
||||
|
||||
$this->model_checkout_order->addOrderHistory(
|
||||
$order_info['order_id'],
|
||||
$this->config->get('payment_btcpay_order_status_id')
|
||||
);
|
||||
|
||||
$this->response->redirect($invoice->getData()['checkoutLink']);
|
||||
if ($debug) {
|
||||
$this->log->write('Found existing and not yet expired invoice: ' . $invoiceId);
|
||||
}
|
||||
} else {
|
||||
// Create the invoice on BTCPay Server.
|
||||
$token = md5(uniqid(rand(), true));
|
||||
if ($newInvoice = $this->createInvoice($order_info, $token)) {
|
||||
$invoiceId = $newInvoice->getId();
|
||||
$checkoutLink = $newInvoice->getCheckoutLink();
|
||||
|
||||
// Add invoiceId to the btcpay order table.
|
||||
$this->model_extension_payment_btcpay->addOrder([
|
||||
'order_id' => $order_info['order_id'],
|
||||
'token' => $token,
|
||||
'invoice_id' => $invoiceId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($invoiceId)) {
|
||||
$this->log->write(
|
||||
"Order #" . $order_info['order_id'] . " is not valid or something went wrong. Please check BTCPay Server API request logs."
|
||||
);
|
||||
@ -120,6 +96,17 @@ class ControllerExtensionPaymentBTCPay extends Controller
|
||||
$this->url->link('checkout/checkout', '', true)
|
||||
);
|
||||
}
|
||||
|
||||
// Handle invoice in modal or redirect to BTCPay Server.
|
||||
if ($useModal) {
|
||||
// Return JSON data for Javascript to process.
|
||||
$data['invoiceId'] = $invoiceId;
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($data));
|
||||
} else {
|
||||
// Redirect to BTCPay Server.
|
||||
$this->response->redirect($checkoutLink);
|
||||
}
|
||||
}
|
||||
|
||||
public function cancel()
|
||||
@ -149,7 +136,7 @@ class ControllerExtensionPaymentBTCPay extends Controller
|
||||
$this->request->get['token']
|
||||
) !== 0) {
|
||||
if ($debug) {
|
||||
$this->log->write('Redirect to success page had no valid token.');
|
||||
$this->log->write('Redirect to home page, request had no valid token.');
|
||||
}
|
||||
$this->response->redirect(
|
||||
$this->url->link('common/home', '', true)
|
||||
@ -162,7 +149,7 @@ class ControllerExtensionPaymentBTCPay extends Controller
|
||||
|
||||
} else {
|
||||
if ($debug) {
|
||||
$this->log->write('Redirect to success page valid order id or session expired.');
|
||||
$this->log->write('Redirect to home page, no valid order id or session expired.');
|
||||
}
|
||||
$this->response->redirect(
|
||||
$this->url->link('common/home', '', true)
|
||||
@ -323,11 +310,110 @@ class ControllerExtensionPaymentBTCPay extends Controller
|
||||
/**
|
||||
* Check webhook signature to be a valid request.
|
||||
*/
|
||||
public function validWebhookRequest(string $signature, string $requestData): bool {
|
||||
protected function validWebhookRequest(string $signature, string $requestData): bool {
|
||||
if ($whData = $this->config->get('payment_btcpay_webhook')) {
|
||||
return Webhook::isIncomingWebhookRequestValid($requestData, $signature, $whData['secret']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function createInvoice(array $order_info, string $token): ?\BTCPayServer\Result\Invoice {
|
||||
// API credentials.
|
||||
$apiKey = $this->config->get('payment_btcpay_api_auth_token');
|
||||
$apiHost = $this->config->get('payment_btcpay_url');
|
||||
$apiStoreId = $this->config->get('payment_btcpay_btcpay_storeid');
|
||||
$client = new Invoice($apiHost, $apiKey);
|
||||
|
||||
$debug = $this->config->get('payment_btcpay_debug_mode');
|
||||
|
||||
// Checkout options.
|
||||
$checkoutOptions = new InvoiceCheckoutOptions();
|
||||
$redirectUrl = $this->url->link(
|
||||
'extension/payment/btcpay/success',
|
||||
['token' => $token],
|
||||
true
|
||||
);
|
||||
|
||||
$checkoutOptions->setRedirectURL(htmlspecialchars_decode($redirectUrl));
|
||||
if ($debug) {
|
||||
$this->log->write( 'Setting redirect url to: ' . $redirectUrl );
|
||||
}
|
||||
|
||||
// Metadata.
|
||||
$metadata = [];
|
||||
|
||||
$amount = $this->prepareOrderTotal($order_info['total'], $order_info['currency_code']);
|
||||
|
||||
// Create the invoice on BTCPay Server.
|
||||
try {
|
||||
$invoice = $client->createInvoice(
|
||||
$apiStoreId,
|
||||
$order_info['currency_code'],
|
||||
$amount,
|
||||
$order_info['order_id'],
|
||||
null, // this is null here as we handle it in the metadata.
|
||||
$metadata,
|
||||
$checkoutOptions
|
||||
);
|
||||
|
||||
return $invoice;
|
||||
} catch (\Throwable $e) {
|
||||
$this->log->write($e->getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the order already has an invoice id and it is still not expired.
|
||||
*/
|
||||
protected function orderHasExistingInvoice(array $order_info): ? \BTCPayServer\Result\Invoice {
|
||||
// API credentials.
|
||||
$apiKey = $this->config->get('payment_btcpay_api_auth_token');
|
||||
$apiHost = $this->config->get('payment_btcpay_url');
|
||||
$apiStoreId = $this->config->get('payment_btcpay_btcpay_storeid');
|
||||
$debug = $this->config->get('payment_btcpay_debug_mode');
|
||||
|
||||
$client = new Invoice($apiHost, $apiKey);
|
||||
|
||||
// Calculate order total.
|
||||
$total = $this->prepareOrderTotal($order_info['total'], $order_info['currency_code']);
|
||||
// Round to 2 decimals to avoid mismatch.
|
||||
$totalRounded = round((float) $total->__toString(), 2);
|
||||
|
||||
$btcpay_order = $this->model_extension_payment_btcpay->getOrder(
|
||||
$order_info['order_id']
|
||||
);
|
||||
|
||||
if ($debug) {
|
||||
$this->log->write(__FUNCTION__);
|
||||
$this->log->write(print_r($btcpay_order, true));
|
||||
}
|
||||
|
||||
if (!empty($btcpay_order['invoice_id'])) {
|
||||
$existingInvoice = $client->getInvoice($apiStoreId, $btcpay_order['invoice_id']);
|
||||
$invoiceAmount = $existingInvoice->getAmount();
|
||||
|
||||
if ($existingInvoice->isExpired() === false &&
|
||||
$totalRounded === (float) $invoiceAmount->__toString()
|
||||
) {
|
||||
return $existingInvoice;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function prepareOrderTotal($total, $currencyCode): \BTCPayserver\Util\PreciseNumber {
|
||||
// Calculate total and format it properly.
|
||||
$total = number_format(
|
||||
$total * $this->currency->getvalue(
|
||||
$currencyCode
|
||||
),
|
||||
8,
|
||||
'.',
|
||||
''
|
||||
);
|
||||
return PreciseNumber::parseString($total);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,3 +2,6 @@
|
||||
|
||||
$_['text_title'] = 'Bitcoin via BTCPay Server';
|
||||
$_['button_confirm'] = 'Pay with Bitcoin';
|
||||
$_['invoice_expired_text'] = 'The invoice expired. Please try again or choose a different payment method.';
|
||||
$_['invoice_closed_text'] = 'Payment aborted. Please try again or choose a different payment method.';
|
||||
$_['invoice_failed_text'] = 'Payment aborted. Error processing the request. Please contact store owner if the problem persists.';
|
||||
|
||||
@ -6,7 +6,7 @@ class ModelExtensionPaymentBTCPay extends Model {
|
||||
}
|
||||
|
||||
public function getOrder($order_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "btcpay_order` WHERE `order_id` = '" . (int)$order_id . "' LIMIT 1");
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "btcpay_order` WHERE `order_id` = '" . (int)$order_id . "' ORDER BY btcpay_order_id DESC LIMIT 1 ");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
<script src="{{ modal_url }}"></script>
|
||||
|
||||
<div class="buttons">
|
||||
<div class="pull-right">
|
||||
<button class="btn btn-primary btcpay-modal">{{ button_confirm }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('button.btcpay-modal').click(function() {
|
||||
$.post("{{ action }}", function (data) {
|
||||
console.log(JSON.stringify(data));
|
||||
if (data.invoiceId !== undefined) {
|
||||
window.btcpay.setApiUrlPrefix('{{ btcpay_host }}');
|
||||
window.btcpay.showInvoice(data.invoiceId);
|
||||
}
|
||||
|
||||
let invoice_paid = false;
|
||||
|
||||
window.btcpay.onModalReceiveMessage(function (event) {
|
||||
if (isObject(event.data)) {
|
||||
console.log('invoiceId: ' + event.data.invoiceId);
|
||||
console.log('status: ' + event.data.status);
|
||||
if (event.data.status) {
|
||||
switch (event.data.status) {
|
||||
case 'complete':
|
||||
case 'paid':
|
||||
invoice_paid = true;
|
||||
window.location='{{ success_link }}';
|
||||
break;
|
||||
case 'expired':
|
||||
window.btcpay.hideFrame();
|
||||
showError('{{ invoice_expired_text }}');
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else { // handle event.data "loaded" "closed"
|
||||
if (event.data === 'close') {
|
||||
if (invoice_paid === true) {
|
||||
window.location='{{ success_link }}';
|
||||
}
|
||||
showError('{{ invoice_closed_text }}');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const isObject = obj => {
|
||||
return Object.prototype.toString.call(obj) === '[object Object]'
|
||||
}
|
||||
|
||||
}).fail(function() {
|
||||
showError('{{ invoice_failed_text }}');
|
||||
});
|
||||
|
||||
const showError = err => {
|
||||
const errFail = '<div class="alert alert-danger alert-dismissible">' + err + '<button type="button" class="close" data-dismiss="alert">×</button></div>';
|
||||
$(this).closest('.panel-body').first().prepend(errFail);
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
@ -3,8 +3,21 @@
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
if (PHP_VERSION_ID < 50600) {
|
||||
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
||||
exit(1);
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, $err);
|
||||
} elseif (!headers_sent()) {
|
||||
echo $err;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
$err,
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
@ -40,6 +40,7 @@ class PullPayments
|
||||
$paymentCurrency = 'BTC';
|
||||
$paymentPeriod = null;
|
||||
$boltExpiration = 1;
|
||||
$autoApproveClaims = false;
|
||||
$startsAt = null;
|
||||
$expiresAt = null;
|
||||
$paymentMethods = ['BTC'];
|
||||
@ -54,6 +55,7 @@ class PullPayments
|
||||
$paymentCurrency,
|
||||
$paymentPeriod,
|
||||
$boltExpiration,
|
||||
$autoApproveClaims,
|
||||
$startsAt,
|
||||
$expiresAt,
|
||||
$paymentMethods
|
||||
@ -109,13 +111,29 @@ class PullPayments
|
||||
}
|
||||
}
|
||||
|
||||
public function approvePayout()
|
||||
{
|
||||
$payoutId ='';
|
||||
try {
|
||||
$client = new PullPayment($this->host, $this->apiKey);
|
||||
var_dump($client->approvePayout(
|
||||
$this->storeId,
|
||||
$payoutId,
|
||||
0,
|
||||
null
|
||||
));
|
||||
} catch (\Throwable $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function getPullPayment()
|
||||
{
|
||||
$pullPaymentId = '';
|
||||
|
||||
try {
|
||||
$client = new PullPayment($this->host, $this->apiKey);
|
||||
var_dump($client->markPayoutAsPaid(
|
||||
var_dump($client->getPullPayment(
|
||||
$this->storeId,
|
||||
$pullPaymentId
|
||||
));
|
||||
@ -131,7 +149,7 @@ class PullPayments
|
||||
|
||||
try {
|
||||
$client = new PullPayment($this->host, $this->apiKey);
|
||||
var_dump($client->markPayoutAsPaid(
|
||||
var_dump($client->getPayouts(
|
||||
$pullPaymentId,
|
||||
$includeCancelled
|
||||
));
|
||||
@ -149,7 +167,7 @@ class PullPayments
|
||||
|
||||
try {
|
||||
$client = new PullPayment($this->host, $this->apiKey);
|
||||
var_dump($client->markPayoutAsPaid(
|
||||
var_dump($client->createPayout(
|
||||
$pullPaymentId,
|
||||
$destination,
|
||||
$amount,
|
||||
@ -167,7 +185,7 @@ class PullPayments
|
||||
|
||||
try {
|
||||
$client = new PullPayment($this->host, $this->apiKey);
|
||||
var_dump($client->markPayoutAsPaid(
|
||||
var_dump($client->getPayout(
|
||||
$pullPaymentId,
|
||||
$payoutId
|
||||
));
|
||||
@ -183,6 +201,7 @@ $pp = new PullPayments();
|
||||
//$pp->archivePullPayment();
|
||||
//$pp->cancelPayout();
|
||||
//$pp->markPayoutAsPaid();
|
||||
//$pp->approvePayout();
|
||||
//$pp->getPullPayment();
|
||||
//$pp->getPayouts();
|
||||
//$pp->createPayout();
|
||||
|
||||
@ -7,68 +7,169 @@ require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// Import Invoice client class.
|
||||
use BTCPayServer\Client\Invoice;
|
||||
use BTCPayServer\Client\Webhook;
|
||||
|
||||
// Fill in with your BTCPay Server data.
|
||||
$apiKey = '';
|
||||
$host = ''; // e.g. https://your.btcpay-server.tld
|
||||
$storeId = '';
|
||||
$secret = ""; // webhook secret configured in the BTCPay UI
|
||||
class WebhookExample
|
||||
{
|
||||
public $apiKey;
|
||||
public $host;
|
||||
public $storeId;
|
||||
public $secret;
|
||||
public $webhookId;
|
||||
|
||||
$myfile = fopen("BTCPay.log", 'ab');
|
||||
public function __construct()
|
||||
{
|
||||
// Fill in with your BTCPay Server data.
|
||||
$this->apiKey = '';
|
||||
$this->host = ''; // e.g. https://your.btcpay-server.tld
|
||||
$this->storeId = '';
|
||||
$this->secret = ''; // webhook secret as shown in the webhook UI / returned by createWebhook()
|
||||
$this->webhookId = ''; // only needed for the updateWebhook() example.
|
||||
}
|
||||
|
||||
$raw_post_data = file_get_contents('php://input');
|
||||
public function processWebhook()
|
||||
{
|
||||
$myfile = fopen("BTCPay.log", 'ab');
|
||||
$raw_post_data = file_get_contents('php://input');
|
||||
|
||||
$date = date('m/d/Y h:i:s a');
|
||||
$date = date('m/d/Y h:i:s a');
|
||||
|
||||
if (false === $raw_post_data) {
|
||||
fwrite($myfile, $date . " : Error. Could not read from the php://input stream or invalid BTCPayServer payload received.\n");
|
||||
fclose($myfile);
|
||||
throw new \Exception('Could not read from the php://input stream or invalid BTCPayServer payload received.');
|
||||
if (false === $raw_post_data) {
|
||||
fwrite(
|
||||
$myfile,
|
||||
$date . " : Error. Could not read from the php://input stream or invalid BTCPayServer payload received.\n"
|
||||
);
|
||||
fclose($myfile);
|
||||
throw new \RuntimeException(
|
||||
'Could not read from the php://input stream or invalid BTCPayServer payload received.'
|
||||
);
|
||||
}
|
||||
|
||||
$payload = json_decode($raw_post_data, false, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
if (empty($payload)) {
|
||||
fwrite(
|
||||
$myfile,
|
||||
$date . " : Error. Could not decode the JSON payload from BTCPay.\n"
|
||||
);
|
||||
fclose($myfile);
|
||||
throw new \RuntimeException('Could not decode the JSON payload from BTCPay.');
|
||||
}
|
||||
|
||||
// verify hmac256
|
||||
$headers = getallheaders();
|
||||
$sig = $headers['Btcpay-Sig'];
|
||||
|
||||
$webhookClient = new Webhook($this->host, $this->apiKey);
|
||||
|
||||
if ($webhookClient->isIncomingWebhookRequestValid($raw_post_data, $sig, $this->secret)) {
|
||||
fwrite(
|
||||
$myfile,
|
||||
$date . " : Error. Invalid Signature detected! \n was: " . $sig . " should be: " . hash_hmac(
|
||||
'sha256',
|
||||
$raw_post_data,
|
||||
$this->secret
|
||||
) . "\n"
|
||||
);
|
||||
fclose($myfile);
|
||||
throw new \RuntimeException(
|
||||
'Invalid BTCPayServer payment notification message received - signature did not match.'
|
||||
);
|
||||
}
|
||||
|
||||
if (true === empty($payload->invoiceId)) {
|
||||
fwrite(
|
||||
$myfile,
|
||||
$date . " : Error. Invalid BTCPayServer payment notification message received - did not receive invoice ID.\n"
|
||||
);
|
||||
fclose($myfile);
|
||||
throw new \RuntimeException(
|
||||
'Invalid BTCPayServer payment notification message received - did not receive invoice ID.'
|
||||
);
|
||||
}
|
||||
|
||||
// Load an existing invoice with the provided invoiceId.
|
||||
// Most of the time this is not needed as you can listen to specific webhook events
|
||||
// See: https://docs.btcpayserver.org/API/Greenfield/v1/#tag/Webhooks/paths/InvoiceCreated/post
|
||||
try {
|
||||
$client = new Invoice($this->host, $this->apiKey);
|
||||
$invoice = $client->getInvoice($this->storeId, $payload->invoiceId);
|
||||
} catch (\Throwable $e) {
|
||||
fwrite($myfile, "Error: " . $e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
|
||||
// optional: check whether your webhook is of the desired type
|
||||
if ($payload->type !== "InvoiceSettled") {
|
||||
throw new \RuntimeException(
|
||||
'Invalid payload message type. Only InvoiceSettled is supported, check the configuration of the webhook.'
|
||||
);
|
||||
}
|
||||
|
||||
$invoicePrice = $invoice->getData()['amount'];
|
||||
$buyerEmail = $invoice->getData()['metadata']['buyerEmail'];
|
||||
|
||||
fwrite(
|
||||
$myfile,
|
||||
$date . " : Payload received for BtcPay invoice " . $payload->invoiceId . " Type: " . $payload->type . " Price: " . $invoicePrice . " E-Mail: " . $buyerEmail . "\n"
|
||||
);
|
||||
fwrite($myfile, "Raw payload: " . $raw_post_data . "\n");
|
||||
|
||||
// your own processing code goes here!
|
||||
|
||||
echo 'OK';
|
||||
}
|
||||
|
||||
public function createWebhook()
|
||||
{
|
||||
$url = 'https://createdurl.test.example.com/webhook';
|
||||
$specificEvents = [
|
||||
'InvoiceExpired',
|
||||
'InvoiceSettled',
|
||||
'InvoiceInvalid'
|
||||
];
|
||||
|
||||
try {
|
||||
$client = new \BTCPayServer\Client\Webhook($this->host, $this->apiKey);
|
||||
var_dump($client->createWebhook($this->storeId, $url, $specificEvents, null));
|
||||
} catch (\Throwable $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function updateWebhook()
|
||||
{
|
||||
$url = 'https://updatedurl.test.example.com/webhook';
|
||||
$specificEvents = [
|
||||
'InvoiceReceivedPayment',
|
||||
'InvoicePaymentSettled',
|
||||
'InvoiceProcessing',
|
||||
'InvoiceExpired',
|
||||
'InvoiceSettled',
|
||||
'InvoiceInvalid'
|
||||
];
|
||||
|
||||
try {
|
||||
$client = new \BTCPayServer\Client\Webhook($this->host, $this->apiKey);
|
||||
var_dump($client->updateWebhook($this->storeId, $url, $this->webhookId, $specificEvents));
|
||||
} catch (\Throwable $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function getWebhook()
|
||||
{
|
||||
try {
|
||||
$client = new \BTCPayServer\Client\Webhook($this->host, $this->apiKey);
|
||||
var_dump($client->getWebhook($this->storeId, $this->webhookId));
|
||||
} catch (\Throwable $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$payload = json_decode($raw_post_data, false, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
if (true === empty($payload)) {
|
||||
fwrite($myfile, $date . " : Error. Could not decode the JSON payload from BTCPay.\n");
|
||||
fclose($myfile);
|
||||
throw new \Exception('Could not decode the JSON payload from BTCPay.');
|
||||
}
|
||||
|
||||
// verify hmac256
|
||||
$headers = getallheaders();
|
||||
$sig = $headers['Btcpay-Sig'];
|
||||
|
||||
if ($sig !== "sha256=" . hash_hmac('sha256', $raw_post_data, $secret)) {
|
||||
fwrite($myfile, $date . " : Error. Invalid Signature detected! \n was: " . $sig . " should be: " . hash_hmac('sha256', $raw_post_data, $secret) . "\n");
|
||||
fclose($myfile);
|
||||
throw new \Exception('Invalid BTCPayServer payment notification message received - signature did not match.');
|
||||
}
|
||||
|
||||
if (true === empty($payload->invoiceId)) {
|
||||
fwrite($myfile, $date . " : Error. Invalid BTCPayServer payment notification message received - did not receive invoice ID.\n");
|
||||
fclose($myfile);
|
||||
throw new \Exception('Invalid BTCPayServer payment notification message received - did not receive invoice ID.');
|
||||
}
|
||||
|
||||
try {
|
||||
$client = new Invoice($host, $apiKey);
|
||||
$invoice = $client->getInvoice($storeId, $payload->invoiceId);
|
||||
} catch (\Throwable $e) {
|
||||
fwrite($myfile, "Error: " . $e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
|
||||
// optional: check whether your webhook is of the desired type
|
||||
if ($payload->type !== "InvoiceSettled") {
|
||||
throw new \Exception('Invalid payload message type. Only InvoiceSettled is supported, check the configuration of the webhook.');
|
||||
}
|
||||
|
||||
$invoicePrice = $invoice->getData()['amount'];
|
||||
$buyerEmail = $invoice->getData()['metadata']['buyerEmail'];
|
||||
|
||||
fwrite($myfile, $date . " : Payload received for BtcPay invoice " . $payload->invoiceId . " Type: " . $payload->type . " Price: " . $invoicePrice . " E-Mail: " . $buyerEmail . "\n");
|
||||
fwrite($myfile, "Raw payload: " . $raw_post_data . "\n");
|
||||
|
||||
// your own processing code goes here!
|
||||
|
||||
echo 'OK';
|
||||
$wh = new WebhookExample();
|
||||
//$wh->processWebhook();
|
||||
//$wh->createWebhook();
|
||||
//$wh->getWebhook();
|
||||
//$wh->updateWebhook();
|
||||
|
||||
@ -43,6 +43,7 @@ class PullPayment extends AbstractClient
|
||||
string $currency,
|
||||
?int $period,
|
||||
?int $BOLT11Expiration,
|
||||
?bool $autoApproveClaims = false,
|
||||
?int $startsAt,
|
||||
?int $expiresAt,
|
||||
array $paymentMethods
|
||||
@ -60,6 +61,7 @@ class PullPayment extends AbstractClient
|
||||
'currency' => $currency,
|
||||
'period' => $period,
|
||||
'BOLT11Expiration' => $BOLT11Expiration,
|
||||
'autoApproveClaims' => $autoApproveClaims,
|
||||
'startsAt' => $startsAt,
|
||||
'expiresAt' => $expiresAt,
|
||||
'paymentMethods' => $paymentMethods
|
||||
@ -156,7 +158,7 @@ class PullPayment extends AbstractClient
|
||||
): bool {
|
||||
$url = $this->getApiUrl() . 'stores/' .
|
||||
urlencode($storeId) . '/' . 'payouts/' .
|
||||
urlencode($payoutId);
|
||||
urlencode($payoutId) . '/mark-paid';
|
||||
|
||||
$headers = $this->getRequestHeaders();
|
||||
$method = 'POST';
|
||||
|
||||
@ -118,11 +118,17 @@ class Webhook extends AbstractClient
|
||||
}
|
||||
}
|
||||
|
||||
public function createWebhook(string $storeId, string $url, ?array $specificEvents, ?string $secret): \BTCPayServer\Result\WebhookCreated
|
||||
{
|
||||
public function createWebhook(
|
||||
string $storeId,
|
||||
string $url,
|
||||
?array $specificEvents,
|
||||
?string $secret,
|
||||
bool $enabled = true,
|
||||
bool $automaticRedelivery = true
|
||||
): \BTCPayServer\Result\WebhookCreated {
|
||||
$data = [
|
||||
'enabled' => true,
|
||||
'automaticRedelivery' => true,
|
||||
'enabled' => $enabled,
|
||||
'automaticRedelivery' => $automaticRedelivery,
|
||||
'url' => $url
|
||||
];
|
||||
|
||||
@ -158,6 +164,62 @@ class Webhook extends AbstractClient
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing webhook.
|
||||
*
|
||||
* Important: due to a bug in BTCPay Server versions <= 1.6.3.0 you need
|
||||
* to pass the $secret explicitly as it would overwrite your existing secret
|
||||
* otherwise. On newer versions BTCPay Server >= 1.6.4.0, if you do NOT set
|
||||
* a secret it won't change it and everything will continue to work.
|
||||
*
|
||||
* @see https://github.com/btcpayserver/btcpayserver/issues/4010
|
||||
*
|
||||
* @return \BTCPayServer\Result\Webhook
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function updateWebhook(
|
||||
string $storeId,
|
||||
string $url,
|
||||
string $webhookId,
|
||||
?array $specificEvents,
|
||||
bool $enabled = true,
|
||||
bool $automaticRedelivery = true,
|
||||
?string $secret = null
|
||||
): \BTCPayServer\Result\Webhook {
|
||||
$data = [
|
||||
'enabled' => $enabled,
|
||||
'automaticRedelivery' => $automaticRedelivery,
|
||||
'url' => $url,
|
||||
'secret' => $secret
|
||||
];
|
||||
|
||||
// Specific events or all.
|
||||
if ($specificEvents === null) {
|
||||
$data['authorizedEvents'] = [
|
||||
'everything' => true
|
||||
];
|
||||
} elseif (count($specificEvents) === 0) {
|
||||
throw new \InvalidArgumentException('Argument $specificEvents should be NULL or contains at least 1 item.');
|
||||
} else {
|
||||
$data['authorizedEvents'] = [
|
||||
'everything' => false,
|
||||
'specificEvents' => $specificEvents
|
||||
];
|
||||
}
|
||||
|
||||
$url = $this->getApiUrl() . 'stores/' . urlencode($storeId) . '/webhooks/' . urlencode($webhookId);
|
||||
$headers = $this->getRequestHeaders();
|
||||
$method = 'PUT';
|
||||
$response = $this->getHttpClient()->request($method, $url, $headers, json_encode($data, JSON_THROW_ON_ERROR));
|
||||
|
||||
if ($response->getStatus() === 200) {
|
||||
$data = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR);
|
||||
return new \BTCPayServer\Result\Webhook($data);
|
||||
} else {
|
||||
throw $this->getExceptionByStatusCode($method, $url, $response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the request your received from a webhook is authentic and can be trusted.
|
||||
* @param string $requestBody Most likely you will use `$requestBody = file_get_contents('php://input');`
|
||||
|
||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace BTCPayServer\Result;
|
||||
|
||||
use BTCPayServer\Util\PreciseNumber;
|
||||
|
||||
class Invoice extends AbstractResult
|
||||
{
|
||||
public const STATUS_NEW = 'New';
|
||||
@ -24,6 +26,51 @@ class Invoice extends AbstractResult
|
||||
|
||||
public const ADDITIONAL_STATUS_PAID_LATE = 'PaidLate';
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->getData()['id'];
|
||||
}
|
||||
|
||||
public function getAmount(): PreciseNumber
|
||||
{
|
||||
return PreciseNumber::parseString($this->getData()['amount']);
|
||||
}
|
||||
|
||||
public function getCurrency(): string
|
||||
{
|
||||
return $this->getData()['currency'];
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->getData()['type'];
|
||||
}
|
||||
|
||||
public function getCheckoutLink(): string
|
||||
{
|
||||
return $this->getData()['checkoutLink'];
|
||||
}
|
||||
|
||||
public function getCreatedTime(): int
|
||||
{
|
||||
return $this->getData()['createdTime'];
|
||||
}
|
||||
|
||||
public function getExpirationTime(): int
|
||||
{
|
||||
return $this->getData()['expirationTime'];
|
||||
}
|
||||
|
||||
public function getMonitoringTime(): int
|
||||
{
|
||||
return $this->getData()['monitoringTime'];
|
||||
}
|
||||
|
||||
public function isArchived(): bool
|
||||
{
|
||||
return $this->getData()['archived'];
|
||||
}
|
||||
|
||||
public function isPaid(): bool
|
||||
{
|
||||
$data = $this->getData();
|
||||
|
||||
@ -50,29 +50,29 @@ class ClassLoader
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, int>>
|
||||
*/
|
||||
private $prefixLengthsPsr4 = [];
|
||||
private $prefixLengthsPsr4 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<int, string>>
|
||||
*/
|
||||
private $prefixDirsPsr4 = [];
|
||||
private $prefixDirsPsr4 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr4 = [];
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, string[]>>
|
||||
*/
|
||||
private $prefixesPsr0 = [];
|
||||
private $prefixesPsr0 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr0 = [];
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
/** @var bool */
|
||||
private $useIncludePath = false;
|
||||
@ -81,7 +81,7 @@ class ClassLoader
|
||||
* @var string[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $classMap = [];
|
||||
private $classMap = array();
|
||||
|
||||
/** @var bool */
|
||||
private $classMapAuthoritative = false;
|
||||
@ -90,7 +90,7 @@ class ClassLoader
|
||||
* @var bool[]
|
||||
* @psalm-var array<string, bool>
|
||||
*/
|
||||
private $missingClasses = [];
|
||||
private $missingClasses = array();
|
||||
|
||||
/** @var ?string */
|
||||
private $apcuPrefix;
|
||||
@ -98,7 +98,7 @@ class ClassLoader
|
||||
/**
|
||||
* @var self[]
|
||||
*/
|
||||
private static $registeredLoaders = [];
|
||||
private static $registeredLoaders = array();
|
||||
|
||||
/**
|
||||
* @param ?string $vendorDir
|
||||
@ -117,7 +117,7 @@ class ClassLoader
|
||||
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
||||
}
|
||||
|
||||
return [];
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -493,11 +493,7 @@ class ClassLoader
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = ClassLoader . phpstrtr(
|
||||
$class,
|
||||
'\\',
|
||||
DIRECTORY_SEPARATOR
|
||||
);
|
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||
@ -526,18 +522,11 @@ class ClassLoader
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = ClassLoader . phpsubstr(
|
||||
$logicalPathPsr4,
|
||||
0,
|
||||
$pos + 1
|
||||
);
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = ClassLoader . phpstrtr(
|
||||
$class,
|
||||
'_',
|
||||
DIRECTORY_SEPARATOR
|
||||
);
|
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||
}
|
||||
|
||||
if (isset($this->prefixesPsr0[$first])) {
|
||||
|
||||
@ -41,7 +41,7 @@ class InstalledVersions
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
*/
|
||||
private static $installedByVendor = [];
|
||||
private static $installedByVendor = array();
|
||||
|
||||
/**
|
||||
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
||||
@ -51,7 +51,7 @@ class InstalledVersions
|
||||
*/
|
||||
public static function getInstalledPackages()
|
||||
{
|
||||
$packages = [];
|
||||
$packages = array();
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
$packages[] = array_keys($installed['versions']);
|
||||
}
|
||||
@ -72,7 +72,7 @@ class InstalledVersions
|
||||
*/
|
||||
public static function getInstalledPackagesByType($type)
|
||||
{
|
||||
$packagesByType = [];
|
||||
$packagesByType = array();
|
||||
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
foreach ($installed['versions'] as $name => $package) {
|
||||
@ -141,7 +141,7 @@ class InstalledVersions
|
||||
continue;
|
||||
}
|
||||
|
||||
$ranges = [];
|
||||
$ranges = array();
|
||||
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
@ -269,7 +269,7 @@ class InstalledVersions
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = include __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = [];
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,7 +308,7 @@ class InstalledVersions
|
||||
public static function reload($data)
|
||||
{
|
||||
self::$installed = $data;
|
||||
self::$installedByVendor = [];
|
||||
self::$installedByVendor = array();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -321,7 +321,7 @@ class InstalledVersions
|
||||
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
||||
}
|
||||
|
||||
$installed = [];
|
||||
$installed = array();
|
||||
|
||||
if (self::$canGetVendors) {
|
||||
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
||||
@ -342,7 +342,7 @@ class InstalledVersions
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = require __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = [];
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
$installed[] = self::$installed;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname(dirname(dirname($vendorDir)));
|
||||
$baseDir = dirname(dirname(dirname(dirname($vendorDir))));
|
||||
|
||||
return array(
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname(dirname(dirname($vendorDir)));
|
||||
$baseDir = dirname(dirname(dirname(dirname($vendorDir))));
|
||||
|
||||
return array(
|
||||
);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname(dirname(dirname($vendorDir)));
|
||||
$baseDir = dirname(dirname(dirname(dirname($vendorDir))));
|
||||
|
||||
return array(
|
||||
'BTCPayServer\\' => array($vendorDir . '/btcpayserver/btcpayserver-greenfield-php/src'),
|
||||
|
||||
@ -16,12 +16,12 @@ class ComposerStaticInit0630a220d429326d17ccb4047a5ba4f3
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'BTCPayServer\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..',
|
||||
0 => __DIR__ . '/..' . '/btcpayserver/btcpayserver-greenfield-php/src',
|
||||
),
|
||||
);
|
||||
|
||||
public static $classMap = array (
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..',
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
|
||||
@ -2,17 +2,17 @@
|
||||
"packages": [
|
||||
{
|
||||
"name": "btcpayserver/btcpayserver-greenfield-php",
|
||||
"version": "v1.3.3",
|
||||
"version_normalized": "1.3.3.0",
|
||||
"version": "v1.3.6",
|
||||
"version_normalized": "1.3.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/btcpayserver/btcpayserver-greenfield-php.git",
|
||||
"reference": "aff6ab92151431c2faa63c72805aa60736b0deea"
|
||||
"reference": "cc9ab93a8ecda8a8158b717f11ff37dfa5ab8962"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/btcpayserver/btcpayserver-greenfield-php/zipball/aff6ab92151431c2faa63c72805aa60736b0deea",
|
||||
"reference": "aff6ab92151431c2faa63c72805aa60736b0deea",
|
||||
"url": "https://api.github.com/repos/btcpayserver/btcpayserver-greenfield-php/zipball/cc9ab93a8ecda8a8158b717f11ff37dfa5ab8962",
|
||||
"reference": "cc9ab93a8ecda8a8158b717f11ff37dfa5ab8962",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -27,7 +27,7 @@
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"vimeo/psalm": "^4.8"
|
||||
},
|
||||
"time": "2022-05-21T15:11:12+00:00",
|
||||
"time": "2022-09-12T21:30:25+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
@ -52,7 +52,7 @@
|
||||
"description": "BTCPay Server Greenfield API PHP client library.",
|
||||
"support": {
|
||||
"issues": "https://github.com/btcpayserver/btcpayserver-greenfield-php/issues",
|
||||
"source": "https://github.com/btcpayserver/btcpayserver-greenfield-php/tree/v1.3.3"
|
||||
"source": "https://github.com/btcpayserver/btcpayserver-greenfield-php/tree/v1.3.6"
|
||||
},
|
||||
"install-path": "../btcpayserver/btcpayserver-greenfield-php"
|
||||
}
|
||||
|
||||
@ -1,30 +1,30 @@
|
||||
<?php return array(
|
||||
'root' => array(
|
||||
'name' => 'btcpayserver/opencart3',
|
||||
'pretty_version' => '1.0.0+no-version-set',
|
||||
'version' => '1.0.0.0',
|
||||
'reference' => NULL,
|
||||
'name' => 'btcpayserver/opencart',
|
||||
'pretty_version' => '3.x-dev',
|
||||
'version' => '3.9999999.9999999.9999999-dev',
|
||||
'reference' => '6c3da16ce919703ec6c956f59df350bc6d934890',
|
||||
'type' => 'opencart-extension',
|
||||
'install_path' => __DIR__ . '/../../../btcpay/',
|
||||
'install_path' => __DIR__ . '/../../../../../',
|
||||
'aliases' => array(),
|
||||
'dev' => true,
|
||||
),
|
||||
'versions' => array(
|
||||
'btcpayserver/btcpayserver-greenfield-php' => array(
|
||||
'pretty_version' => 'v1.3.3',
|
||||
'version' => '1.3.3.0',
|
||||
'reference' => 'aff6ab92151431c2faa63c72805aa60736b0deea',
|
||||
'pretty_version' => 'v1.3.6',
|
||||
'version' => '1.3.6.0',
|
||||
'reference' => 'cc9ab93a8ecda8a8158b717f11ff37dfa5ab8962',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../btcpayserver/btcpayserver-greenfield-php',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'btcpayserver/opencart3' => array(
|
||||
'pretty_version' => '1.0.0+no-version-set',
|
||||
'version' => '1.0.0.0',
|
||||
'reference' => NULL,
|
||||
'btcpayserver/opencart' => array(
|
||||
'pretty_version' => '3.x-dev',
|
||||
'version' => '3.9999999.9999999.9999999-dev',
|
||||
'reference' => '6c3da16ce919703ec6c956f59df350bc6d934890',
|
||||
'type' => 'opencart-extension',
|
||||
'install_path' => __DIR__ . '/../../../btcpay/',
|
||||
'install_path' => __DIR__ . '/../../../../../',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
// platform_check.php @generated by Composer
|
||||
|
||||
$issues = [];
|
||||
$issues = array();
|
||||
|
||||
if (!(PHP_VERSION_ID >= 70300)) {
|
||||
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.3.0". You are running ' . PHP_VERSION . '.';
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
<?php
|
||||
|
||||
define('BTCPAY_OPENCART_EXTENSION_VERSION', '3.0.2');
|
||||
define('BTCPAY_OPENCART_EXTENSION_VERSION', '3.1.0');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user