Skip to content
This repository has been archived by the owner on Jul 15, 2020. It is now read-only.

Commit

Permalink
Reverted changes related with removing php sdk dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
imeleshko committed Dec 23, 2018
1 parent 02843e7 commit ec64121
Show file tree
Hide file tree
Showing 48 changed files with 1,441 additions and 279 deletions.
13 changes: 0 additions & 13 deletions .circleci/README.md

This file was deleted.

21 changes: 0 additions & 21 deletions .circleci/config.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .circleci/params.ini

This file was deleted.

154 changes: 0 additions & 154 deletions .circleci/scripts/release_uploader.php

This file was deleted.

5 changes: 0 additions & 5 deletions .gitignore

This file was deleted.

9 changes: 4 additions & 5 deletions README.md
Expand Up @@ -3,11 +3,10 @@
# Installation
1. Signup for an account at [Coinbase Commerce](https://commerce.coinbase.com/).
2. Create an API Key by going to the Settings tab in the Coinbase Commerce dashboard.
3. Download zip archive from [release page](https://github.com/coinbase/coinbase-commerce-prestashop/releases) and unzip or clone plugin and run `composer install` inside clonned folder
4. Copy the `coinbase/` folder to your Prestashop `modules/` folder.
5. Login to your Prestashop Back Office, navigate to the Modules tab, go to the "Installed Modules" tab and search for "Coinbase Commerce". Click Install to activate the plugin.
6. Click Configure to go to the settings page of the plugin. Set the API Key, Shared Secret Key from Coinbase Commerce Dashboard.
7. Copy webhook url from settings page of the plugin to Coinbase Commerce DashBoard Settings.
3. Copy the `coinbase/` folder to your Prestashop `modules/` folder.
4. Login to your Prestashop Back Office, navigate to the Modules tab, go to the "Installed Modules" tab and search for "Coinbase Commerce". Click Install to activate the plugin.
5. Click Configure to go to the settings page of the plugin. Set the API Key, Shared Secret Key from Coinbase Commerce Dashboard.
6. Copy webhook url from settings page of the plugin to Coinbase Commerce DashBoard Settings.

**NOTE:** There is a setting for "Unsafe" mode on the plugins settings page. This should never be set to "Enabled" on a production website.
It is only used for making testing easier during development, since it will deactivate any validation of the requests that is send to the webhook, which
Expand Down
3 changes: 1 addition & 2 deletions coinbase/coinbase.php
Expand Up @@ -77,8 +77,7 @@ public function hookPaymentOptions($params)
if (!$this->active) {
return;
}

$paymentOption = new PaymentOption();
$paymentOption = new \PrestaShop\PrestaShop\Core\Payment\PaymentOption();
$paymentOption->setCallToActionText($this->l('Coinbase Commerce'))
->setAction($this->context->link->getModuleLink($this->name, 'process', array(), true))
->setAdditionalInformation($this->context->smarty->fetch('module:coinbase/views/templates/front/payment_infos.tpl'))
Expand Down
12 changes: 0 additions & 12 deletions coinbase/config.xml

This file was deleted.

8 changes: 4 additions & 4 deletions coinbase/controllers/front/process.php
Expand Up @@ -6,8 +6,8 @@

if (defined('_PS_MODULE_DIR_')) {
require_once _PS_MODULE_DIR_ . 'coinbase/classes/OrderManager.php';
require_once _PS_MODULE_DIR_ . 'coinbase/vendor/autoload.php';
require_once _PS_MODULE_DIR_ . 'coinbase/vendor/const.php';
require_once _PS_MODULE_DIR_ . 'coinbase/vendor/CoinbaseSDK/init.php';
require_once _PS_MODULE_DIR_ . 'coinbase/vendor/CoinbaseSDK/const.php';
}

class CoinbaseProcessModuleFrontController extends ModuleFrontController
Expand Down Expand Up @@ -84,8 +84,8 @@ public function apiCreateCharge($cart)
);

$apiKey = Configuration::get('COINBASE_API_KEY');
\CoinbaseCommerce\ApiClient::init($apiKey);
\CoinbaseSDK\ApiClient::init($apiKey);

return \CoinbaseCommerce\Resources\Charge::create($chargeData);
return \CoinbaseSDK\Resources\Charge::create($chargeData);
}
}
12 changes: 6 additions & 6 deletions coinbase/controllers/front/webhook.php
Expand Up @@ -4,18 +4,18 @@
}

if (defined('_PS_MODULE_DIR_')) {
require_once _PS_MODULE_DIR_ . 'coinbase/vendor/autoload.php';
require_once _PS_MODULE_DIR_ . 'coinbase/vendor/const.php';
require_once _PS_MODULE_DIR_ . 'coinbase/vendor/CoinbaseSDK/init.php';
require_once _PS_MODULE_DIR_ . 'coinbase/vendor/CoinbaseSDK/const.php';
}

class CoinbaseWebhookModuleFrontController extends ModuleFrontController
{
public function postProcess()
{
$event = $this->constructEvent();
\CoinbaseCommerce\ApiClient::init(Configuration::get('COINBASE_API_KEY'));
\CoinbaseSDK\ApiClient::init(Configuration::get('COINBASE_API_KEY'));
$chargeId = $event->data->id;
$chargeObj = \CoinbaseCommerce\Resources\Charge::retrieve($chargeId);
$chargeObj = \CoinbaseSDK\Resources\Charge::retrieve($chargeId);
if (empty($chargeObj->timeline)) {
throw new Exception('Invalid charge');
}
Expand Down Expand Up @@ -84,13 +84,13 @@ private function constructEvent()
// if test mode don't run validation
if ((bool)Configuration::get('COINBASE_SANDBOX')) {
$data = \json_decode($payload, true);
return new \CoinbaseCommerce\Resources\Event($data['event']);
return new \CoinbaseSDK\Resources\Event($data['event']);
}

$sharedSecret = Configuration::get('COINBASE_SHARED_SECRET');
$headers = array_change_key_case(getallheaders());
$signatureHeader = isset($headers[SIGNATURE_HEADER]) ? $headers[SIGNATURE_HEADER] : null;

return \CoinbaseCommerce\Webhook::buildEvent($payload, $signatureHeader, $sharedSecret);
return \CoinbaseSDK\Webhook::buildEvent($payload, $signatureHeader, $sharedSecret);
}
}
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions coinbase/vendor/CoinbaseSDK/init.php
@@ -0,0 +1,29 @@
<?php
spl_autoload_register(function ($class) {

// project-specific namespace prefix
$prefix = 'CoinbaseSDK\\';

// base directory for the namespace prefix
$base_dir = __DIR__ . '/lib/';

// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
// no, move to the next registered autoloader
return;
}

// get the relative class name
$relative_class = substr($class, $len);

// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';

// if the file exists, require it
if (file_exists($file)) {
require $file;
}
});

0 comments on commit ec64121

Please sign in to comment.