Compare commits

..

12 Commits

Author SHA1 Message Date
Nicolas Dorier
2e4673c832
Update README.md 2021-01-11 11:34:33 +09:00
Nicolas Dorier
7ba9816e25
Update README.md 2021-01-11 11:31:45 +09:00
Adrien Bensaïbi
8e088c737a
Merge pull request #11 from btcpayserver/improvments
Improvments
2019-02-04 16:48:16 +01:00
Adrien Bensaïbi
257724c584 fix: rm old logs 2019-02-04 16:47:21 +01:00
Adrien Bensaïbi
4a5ce954dc fix: respect class convention 2019-02-03 02:07:25 +01:00
Adrien Bensaïbi
04658e4e92 fix: add some sleep to let order_bitcoin update 2019-02-02 22:45:29 +01:00
Adrien Bensaïbi
c6bb530fa2 chore: dump version 2019-02-02 19:18:31 +01:00
Adrien Bensaïbi
87092e062f feat: cleaning and links 2019-02-02 19:16:50 +01:00
Adrien Bensaïbi
96601c9222 doc: resolve #8 small notice about servers access 2019-02-02 18:34:09 +01:00
Adrien Bensaïbi
67dba23743
Merge pull request #10 from btcpayserver/fix-currency
fix: multi currency instead of euro only
2019-02-02 18:17:40 +01:00
Adrien Bensaïbi
04ec130145 fix: multi currency instead of euro only 2019-02-02 18:03:12 +01:00
Adrien Bensaïbi
e523d46703
Merge pull request #9 from btcpayserver/fix-syntax-associative-array
Fix syntax associative array
2019-02-02 17:17:57 +01:00
9 changed files with 40 additions and 21 deletions

View File

@ -5,8 +5,8 @@
1.7.0 (19 June 2017)
* Now compatible with PrestaShop 1.6 and 1.7
1.5.0 (11 March 2015)
1.5.0 (11 March 2015)
* Now compatible with PrestaShop 1.5+
Version 0.5
* Tested against PrestaShop v1.5.4.1 and 1.6.0.5
* Tested against PrestaShop v1.5.4.1 and 1.6.0.5

View File

@ -16,12 +16,14 @@ If you want to test in test mode, just paste an other btcpayserver url with test
+ PHP 5+
+ Curl PHP Extension
+ JSON PHP Extension
* Install PHP bcmath module
+ Install PHP bcmath module
+ be sure your BTCPay server is whitelisted by Prestashop server
+ be sure your Prestashop server is whitelisted by BTCPay server
## Plugin Configuration
### For Prestashop versions 1.7:
1. Download the latest release from https://github.com/adapp-tech/prestashop-plugin/releases
1. Download the latest release from https://github.com/btcpayserver/prestashop-plugin/releases
2. Go to your PrestaShop administration. Under "Modules and services" select "Upload a module" (v1.7)
3. Go to your "installed modules" -> "BTCPay" and click [Configure]<br />
4. Go on your BTCPay server, in your store and display access tokens.

View File

@ -1,3 +1,5 @@
> :warning: THIS PLUGIN IS FUNCTIONING BUT DEPRECATED, USE https://github.com/btcpayserver/prestashop-plugin INSTEAD
# Prestashop Plugin for BTCPay server, an opensource Payment processor
Warning this is an Beta version
@ -14,7 +16,7 @@ and if you want, some companies provide hosting services.
## Quick Start Guide
To get up and running with our plugin quickly, see the GUIDE here: https://github.com/adapp-tech/prestashop-plugin/blob/master/GUIDE.md
To get up and running with our plugin quickly, see the GUIDE here: https://github.com/btcpayserver/prestashop-plugin/blob/master/GUIDE.md
# Internals
@ -48,7 +50,7 @@ e.g: plugin use order state id: 39,40,41,42. Should use 49,50,51,52 if other pl
## Contribute
To contribute to this project, please fork and submit a pull request.
* [GitHub Issues](https://github.com/adapptech/prestashop-plugin/issues)
* [GitHub Issues](https://github.com/btcpayserver/prestashop-plugin/issues)
## PrestaShop Support

View File

@ -37,7 +37,7 @@ if (!defined('_PS_VERSION_')) {
exit;
}
class btcpay extends PaymentModule {
class BTCpay extends PaymentModule {
private $_html = '';
private $key;
protected $_postErrors = array();
@ -70,9 +70,9 @@ class btcpay extends PaymentModule {
$this->name = 'btcpay';
$this->tab = 'payments_gateways';
$this->version = '0.3.1';
$this->version = '0.3.2';
$this->author = 'ADAPP';
$this->className = 'btcpay';
$this->className = 'BTCpay';
$this->currencies = true;
$this->currencies_mode = 'checkbox';
$this->display = 'view';
@ -503,8 +503,15 @@ class btcpay extends PaymentModule {
// Get shopping currency, currently tested with be EUR
$currency = Currency::getCurrencyInstance((int)$cart->id_currency);
if (true === empty($currency)) {
$currency = Currency::getDefaultCurrency();
return;
}
$transaction_speed = Configuration::get('btcpay_TXSPEED');
if (true === empty($transaction_speed)) {
$transaction_speed = 'default';
}
// get the cart id to fetch cart information
$cart_id = $cart->id;
@ -517,7 +524,7 @@ class btcpay extends PaymentModule {
$cart_total = $cart->getOrderTotal(true);
// This is the callback url for invoice paid
$notification_url = 'https://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/'.$this->name.'/ipn.php';
$notification_url = Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/ipn.php';
// Get a BitPay Client to prepare for invoice creation
$client = new \Bitpay\Client\Client();
@ -568,12 +575,11 @@ class btcpay extends PaymentModule {
PrestaShopLogger::addLog('[Error] The BTCPay payment plugin was called to process a payment but could not instantiate an Invoice object.', 3);
}
$btcpay_currency = new \Bitpay\Currency('EUR');
$btcpay_currency = new \Bitpay\Currency($currency->iso_code);
$invoice->setOrderId((string)$cart_id);
$invoice->setCurrency($btcpay_currency);
$invoice->setFullNotifications(true);
$invoice->setExtendedNotifications(true);
// Add a priced item to the invoice
$item = new \Bitpay\Item();
if (false === isset($item) || true === empty($item)) {
@ -702,7 +708,7 @@ class btcpay extends PaymentModule {
if(isset($redirect) && !empty($redirect))
{
$result_invoice_id = $this->get_order_field($cart_id, 'invoice_id');
$invoice = $client->getInvoice($result_invoice_id['invoice_id']);
$invoice = $client->getInvoice($result_invoice_id);
$status = $invoice->getStatus();
if($status === 'invalid' || $status === 'expired')
{

View File

@ -2,7 +2,7 @@
<module>
<name>btcpay</name>
<displayName><![CDATA[BTCPay]]></displayName>
<version><![CDATA[0.3.1]]></version>
<version><![CDATA[0.3.2]]></version>
<description><![CDATA[Accepts Bitcoin payments via BTCPay.]]></description>
<author><![CDATA[ADAPP]]></author>
<tab><![CDATA[payments_gateways]]></tab>

View File

@ -2,7 +2,7 @@
<module>
<name>btcpay</name>
<displayName><![CDATA[btcpay]]></displayName>
<version><![CDATA[0.3.1]]></version>
<version><![CDATA[0.3.2]]></version>
<description><![CDATA[Acceptez les paiements en bitcoin via BTCPay.]]></description>
<author><![CDATA[ADAPP]]></author>
<tab><![CDATA[payments_gateways]]></tab>

View File

@ -1,7 +1,7 @@
<?php
class btcpayPaymentModuleFrontController extends ModuleFrontController
class BTCpayPaymentModuleFrontController extends ModuleFrontController
{
public $ssl = true;
public $display_column_left = false;

View File

@ -1,7 +1,7 @@
<?php
class btcpayValidationModuleFrontController extends ModuleFrontController
class BTCpayValidationModuleFrontController extends ModuleFrontController
{
/**
* @see FrontController::postProcess()

View File

@ -29,7 +29,7 @@
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/btcpay.php');
$btcpay = new btcpay();
$btcpay = new BTCpay();
$post = file_get_contents('php://input');
if (!$post) {
@ -99,6 +99,10 @@ if (true == array_key_exists('name', $event)
&& $event['name'] === "invoice_created"
&& $btcpay_ordermode === "beforepayment" ) {
// sleep to not receive ipn notification
// before the update of bitcoin order table
sleep(15);
// check if we have needed data
if (true === empty($data)) {
PrestaShopLogger::addLog('[Error] No data',3);
@ -159,8 +163,8 @@ if (true == array_key_exists('name', $event)
$status_btcpay,
$cart_total,
$display_name, //bitcoin btcpay
$rate, //message
array(), //extravars
null, //message should be new Message
array(), //extravars for mail
null, //currency special
false, // don't touch amount
$secure_key
@ -209,6 +213,10 @@ if (true == array_key_exists('name', $event)
&& $event['name'] === 'invoice_receivedPayment'
&& $btcpay_ordermode === 'afterpayment' ) {
// sleep to not receive ipn notification
// before the update of bitcoin order table
sleep(15);
// check if we have needed data
if (true === empty($data)) {
PrestaShopLogger::addLog('[Error] No data',3);
@ -386,7 +394,8 @@ if (true === array_key_exists('name', $event)
}
if (true === array_key_exists('name', $event)
&& $event['name'] === 'invoice_failedToConfirm' or $event['name'] === 'invoice_markedInvalid' ) {
&& $event['name'] === 'invoice_failedToConfirm'
or $event['name'] === 'invoice_markedInvalid' ) {
if (true === empty($data)) {
PrestaShopLogger::addLog('[Error] invalide json', 3);