Compare commits

..

No commits in common. "master" and "fix-syntax-associative-array" have entirely different histories.

9 changed files with 21 additions and 40 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,14 +16,12 @@ 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
+ be sure your BTCPay server is whitelisted by Prestashop server
+ be sure your Prestashop server is whitelisted by BTCPay server
* Install PHP bcmath module
## Plugin Configuration
### For Prestashop versions 1.7:
1. Download the latest release from https://github.com/btcpayserver/prestashop-plugin/releases
1. Download the latest release from https://github.com/adapp-tech/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,5 +1,3 @@
> :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
@ -16,7 +14,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/btcpayserver/prestashop-plugin/blob/master/GUIDE.md
To get up and running with our plugin quickly, see the GUIDE here: https://github.com/adapp-tech/prestashop-plugin/blob/master/GUIDE.md
# Internals
@ -50,7 +48,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/btcpayserver/prestashop-plugin/issues)
* [GitHub Issues](https://github.com/adapptech/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.2';
$this->version = '0.3.1';
$this->author = 'ADAPP';
$this->className = 'BTCpay';
$this->className = 'btcpay';
$this->currencies = true;
$this->currencies_mode = 'checkbox';
$this->display = 'view';
@ -503,15 +503,8 @@ 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;
@ -524,7 +517,7 @@ class BTCpay extends PaymentModule {
$cart_total = $cart->getOrderTotal(true);
// This is the callback url for invoice paid
$notification_url = Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/ipn.php';
$notification_url = 'https://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/'.$this->name.'/ipn.php';
// Get a BitPay Client to prepare for invoice creation
$client = new \Bitpay\Client\Client();
@ -575,11 +568,12 @@ 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($currency->iso_code);
$btcpay_currency = new \Bitpay\Currency('EUR');
$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)) {
@ -708,7 +702,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 = $client->getInvoice($result_invoice_id['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.2]]></version>
<version><![CDATA[0.3.1]]></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.2]]></version>
<version><![CDATA[0.3.1]]></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,10 +99,6 @@ 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);
@ -163,8 +159,8 @@ if (true == array_key_exists('name', $event)
$status_btcpay,
$cart_total,
$display_name, //bitcoin btcpay
null, //message should be new Message
array(), //extravars for mail
$rate, //message
array(), //extravars
null, //currency special
false, // don't touch amount
$secure_key
@ -213,10 +209,6 @@ 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);
@ -394,8 +386,7 @@ 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);