This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pieter Poorthuis
committed
Jan 19, 2018
0 parents
commit 3df8939
Showing
26 changed files
with
2,709 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Changelog | ||
|
||
All Notable changes to `opencart3-plugin` will be documented in this file | ||
|
||
## [3.0] - 2018-01-19 | ||
Initial v3 version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Contributing | ||
|
||
Contributions are **welcome** and will be fully **credited**. | ||
|
||
We accept contributions via Pull Requests on [Github](https://github.com/bitpay/opencart-plugin). | ||
|
||
|
||
## Pull Requests | ||
|
||
- **[OpenCart Coding Standard](https://github.com/opencart/opencart/wiki/Coding-standards)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). | ||
|
||
- **Add tests!** - Your patch won't be accepted if it doesn't have tests. | ||
|
||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. | ||
|
||
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. | ||
|
||
- **Create feature branches** - Don't ask us to pull from your master branch. | ||
|
||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. | ||
|
||
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting. | ||
|
||
|
||
## Running Tests | ||
|
||
``` bash | ||
$ phpunit | ||
``` | ||
|
||
|
||
**Happy coding**! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Using BitPay for OpenCart | ||
## Prerequisites | ||
Last Cart Version Tested: 3.0.2.0 | ||
|
||
You must have a BitPay merchant account to use this library. It's free to [sign-up for a BitPay merchant account](https://bitpay.com/start). | ||
You can also test this plugin with a test BitPay merchant account. For more information about setting up a test BitPay merchant account & a testnet bitcoin wallet, please see https://bitpay.com/docs/testing | ||
|
||
## Getting Started | ||
Go to the [latest release](https://github.com/bitpay/opencart-plugin/releases/latest) and download the file called `bitpay-opencart.ocmod.zip` | ||
|
||
Note: if you're running an older version of OpenCart (e.g. v2.2), please select the plugin from https://github.com/bitpay/opencart-plugin/releases | ||
|
||
|
||
## Install | ||
### Via Extension Installer | ||
In your OpenCart store's administration section, go to Extensions > Extension Installer | ||
|
||
Upload `bitpay-opencart.ocmod.zip` | ||
|
||
OpenCart needs a working FTP server to install files. If the progress bar hangs half way, it probably means that your OpenCart FTP settings are incorrect. You can configure the FTP credentials of your server under System -> Settings -> FTP | ||
|
||
After the installation indicates it's successful, you can continue with the setup. | ||
|
||
## Setup | ||
### Install the Payment Extension | ||
Go to Extensions > Payments. | ||
Find the BitPay payment extension and click the green install button. The page will refresh, you'll see a success message, and the install button will turn into a red uninstall button. | ||
Click on the edit button. You are now at the BitPay plugin's configuration screen. | ||
|
||
### Connect to BitPay | ||
For live transactions, just press the Connect to BitPay button. For test transactions, press the drop down button attached to the Connect to Bitpay button and select testnet. | ||
You will be redirected to your BitPay merchant account and asked to approve a token which connects your store to BitPay's API. | ||
After pressing Approve, please go back to the BitPay/OpenCart plugin configuration screen. | ||
|
||
Configure the settings that work best for you. Each setting has a tooltip that can help explain what it does. | ||
Set the status setting to enabled and click save at the top right of the page. | ||
|
||
You're done! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# The MIT License (MIT) | ||
|
||
Copyright (c) 2018 BitPay, Inc. | ||
|
||
> Permission is hereby granted, free of charge, to any person obtaining a copy | ||
> of this software and associated documentation files (the "Software"), to deal | ||
> in the Software without restriction, including without limitation the rights | ||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
> copies of the Software, and to permit persons to whom the Software is | ||
> furnished to do so, subject to the following conditions: | ||
> | ||
> The above copyright notice and this permission notice shall be included in | ||
> all copies or substantial portions of the Software. | ||
> | ||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
> THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Notice | ||
|
||
This is a Community-supported project. | ||
|
||
If you are interested in becoming a maintainer of this project, please contact us at support@bitpay.com. Developers at BitPay will attempt to work along the new maintainers to ensure the project remains viable for the foreseeable future. | ||
|
||
# BitPay for OpenCart | ||
|
||
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) | ||
[![Build Status](https://img.shields.io/travis/bitpay/opencart-plugin/master.svg?style=flat-square)](https://travis-ci.org/bitpay/opencart-plugin) | ||
|
||
## Last Cart Version Tested: 3.0.2.0 | ||
|
||
## Installation | ||
|
||
Follow the instructions found in the [BitPay for OpenCart Guide](GUIDE.md) | ||
|
||
## Development Setup | ||
|
||
``` bash | ||
# Clone the repo | ||
$ git clone https://github.com/bitpay/opencart-plugin.git | ||
$ cd ./opencart-plugin | ||
|
||
# Install dependencies via Composer | ||
$ composer install | ||
|
||
# Set Environment Variables (variables needed can be found in .env.sample) | ||
$ cp .env.sample .env | ||
|
||
# After modifying the Environment Variables for your environment setup OpenCart | ||
$ ./bin/robo setup | ||
``` | ||
|
||
## Development Workflow | ||
|
||
``` bash | ||
# Run PHP Server of OpenCart installation and redirect bash I/O | ||
$ ./bin/robo server & | ||
|
||
# Watch for source code changes and copy them to the OpenCart installation | ||
$ ./bin/robo watch | ||
``` | ||
|
||
## Testing | ||
|
||
``` bash | ||
$ ./bin/robo test | ||
``` | ||
|
||
## Build | ||
|
||
``` bash | ||
$ ./bin/robo build | ||
|
||
# Outputs: | ||
# ./build/bitpay-opencart - the distribution files | ||
# ./build/bitpay-opencart.ocmod.zip - the distribution archive | ||
``` | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details. | ||
|
||
## Support | ||
|
||
**BitPay Support:** | ||
|
||
* Last OpenCart Version Tested: 3.0.2.0 (not compatible with v2 branch) | ||
* [GitHub Issues](https://github.com/bitpay/magento-plugin/issues) | ||
* Open an issue if you are having issues with this plugin. | ||
* [Support](https://help.bitpay.com) | ||
* BitPay merchant support documentation | ||
|
||
**OpenCart Support:** | ||
|
||
* [Homepage](http://www.opencart.com) | ||
* [GitHub Issues](https://github.com/opencart/opencart/issues) | ||
* [Support](http://www.opencart.com/index.php?route=support/support) | ||
* [Forums](http://forum.opencart.com) | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<?php | ||
|
||
require_once('vendor/autoload.php'); | ||
if (file_exists(__DIR__.'/.env')) { | ||
Dotenv::load(__DIR__); | ||
} | ||
|
||
class RoboFile extends \Robo\Tasks | ||
{ | ||
|
||
use \Robo\Task\Development\loadTasks; | ||
use \Robo\Common\TaskIO; | ||
protected $config; | ||
|
||
public function __construct() | ||
{ | ||
foreach ($_ENV as $option => $value) { | ||
if (substr($option, 0, 3) === 'OC_') { | ||
$option = strtolower(substr($option, 3)); | ||
$this->config[$option] = $value; | ||
} | ||
} | ||
$required = array('db_username', 'password', 'email', 'http_server'); | ||
$missing = array(); | ||
foreach ($required as $config) { | ||
if (empty($this->config[$config])) { | ||
$missing[] = 'OC_'.strtoupper($config); | ||
} | ||
} | ||
if (!empty($missing)) { | ||
$this->printTaskError("<error> Missing ".implode(', ', $missing)); | ||
$this->printTaskError("<error> See .env.sample "); | ||
die(); | ||
} | ||
} | ||
|
||
public function setup() | ||
{ | ||
$this->taskDeleteDir('www')->run(); | ||
$this->taskFileSystemStack() | ||
->mirror('vendor/opencart/opencart/upload', 'www') | ||
->chmod('www', 0777, 0000, true) | ||
// ->touch('www/config.php') | ||
// ->touch('www/admin/config.php') | ||
->run(); | ||
$this->_exec(sprintf('mysql -u %1$s -p%2$s -Nse \'show tables\' %3$s | while read table; do mysql -u %1s -p%2$s -e "drop table $table" %3$s; done', $this->config['db_username'], $this->config['db_password'], $this->config['db_database'])); | ||
$install = $this->taskExec('php')->arg('www/install/cli_install.php')->arg('install'); | ||
foreach ($this->config as $option => $value) { | ||
$install->option($option, $value); | ||
} | ||
$install->run(); | ||
$this->taskDeleteDir('www/install')->run(); | ||
$this->taskGitStack() | ||
->stopOnFail() | ||
->dir('www') | ||
->exec('init') | ||
->add('-A') | ||
->commit('Clean install') | ||
->run(); | ||
$this->taskFileSystemStack() | ||
->mirror('vendor/bitpay/php-client/src/Bitpay', 'www/system/library/Bitpay') | ||
->run(); | ||
$this->taskGitStack() | ||
->stopOnFail() | ||
->dir('www') | ||
->add('-A') | ||
->commit('Added bitpay/php-client library') | ||
->run(); | ||
|
||
} | ||
|
||
public function setuptest() | ||
{ | ||
$this->taskDeleteDir('tests/phpcs')->run(); | ||
$this->taskFileSystemStack() | ||
->mirror('vendor/opencart/opencart/tests/phpcs', 'tests/phpcs')->run(); | ||
} | ||
|
||
public function test() | ||
{ | ||
if (!file_exists(__DIR__.'/tests/phpcs/OpenCart/ruleset.xml')) { | ||
$this->setuptest(); | ||
} | ||
$this->taskExec('phpcs')->arg('src')->arg('--standard='.__DIR__.'/tests/phpcs/OpenCart/ruleset.xml')->run(); | ||
} | ||
|
||
public function server() | ||
{ | ||
$port = parse_url($this->config['http_server'], PHP_URL_PORT); | ||
$port = (is_null($port)) ? 80 : $port; | ||
$host = parse_url($this->config['http_server'], PHP_URL_HOST); | ||
$this->taskServer($port) | ||
->host($host) | ||
->dir('www') | ||
->run(); | ||
} | ||
|
||
public function watch() | ||
{ | ||
$this->dev(); | ||
$this->taskWatch() | ||
->monitor('composer.json', function () { | ||
$this->taskComposerUpdate()->run(); | ||
$this->dev(); | ||
})->monitor('src/', function () { | ||
$this->dev(); | ||
})->run(); | ||
} | ||
|
||
public function dev() | ||
{ | ||
$this->taskGitStack() | ||
->stopOnFail() | ||
->dir('www') | ||
->exec('clean -df') | ||
->run(); | ||
$this->taskFileSystemStack()->mirror('src/upload', 'www')->run(); | ||
$this->taskReplaceInFile('www/system/library/bitpay.php') | ||
->from('{{bitpay_lib_version}}') | ||
->to($this->depver('bitpay/php-client')) | ||
->run(); | ||
} | ||
|
||
private function depver($dep) | ||
{ | ||
if ($composerLock = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'composer.lock')) { | ||
$json = json_decode($composerLock); | ||
foreach ($json->packages as $package) { | ||
if ($package->name === $dep) { | ||
return $package->version; | ||
} | ||
} | ||
return "Not Found"; | ||
} | ||
return "Not Installed"; | ||
} | ||
|
||
public function build() | ||
{ | ||
$this->taskDeleteDir('build')->run(); | ||
$this->taskFileSystemStack()->mirror('src', 'build/bitpay-opencart')->run(); | ||
$this->taskFileSystemStack()->mirror('vendor/bitpay/php-client/src/Bitpay', 'build/bitpay-opencart/upload/system/library/Bitpay')->run(); | ||
$this->taskReplaceInFile('build/bitpay-opencart/upload/system/library/bitpay.php') | ||
->from('{{bitpay_lib_version}}') | ||
->to($this->depver('bitpay/php-client')) | ||
->run(); | ||
$this->taskExec('zip')->dir('build/bitpay-opencart')->arg('-r')->arg('../bitpay-opencart.ocmod.zip')->arg('./')->run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"name": "bitpay/opencart-plugin", | ||
"description": "BitPay Payment Method for OpenCart", | ||
"version": "3.0", | ||
"type": "opencart-extension", | ||
"keywords": ["bitcoin", "bitpay", "opencart", "payment", "btc", "xbt"], | ||
"homepage": "https://github.com/bitpay/opencart-plugin", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "BitPay, Inc.", | ||
"homepage": "https://bitpay.com" | ||
} | ||
], | ||
"support": { | ||
"email": "support@bitpay.com", | ||
"issues": "https://github.com/bitpay/opencart-plugin/issues" | ||
}, | ||
"repositories": [ | ||
{ | ||
"type": "package", | ||
"package": { | ||
"name": "opencart/opencart", | ||
"version": "3.0.2.0", | ||
"dist": { | ||
"url": "https://github.com/opencart/opencart/archive/3.0.2.0.zip", | ||
"type": "zip" | ||
}, | ||
"source": { | ||
"url": "https://github.com/opencart/opencart", | ||
"type": "git", | ||
"reference": "7911c76c43e29ddc1e4168f36dff6a0be6179719" | ||
} | ||
} | ||
} | ||
], | ||
"require": { | ||
"php" : ">=5.4.0", | ||
"bitpay/php-client": "~2.2" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit" : "4.*", | ||
"squizlabs/php_codesniffer": "2.*", | ||
"codegyre/robo": "*", | ||
"opencart/opencart" : "3.0.2.0", | ||
"vlucas/phpdotenv": "~1.1.0" | ||
}, | ||
"minimum-stability": "stable", | ||
"config": { | ||
"bin-dir": "bin/", | ||
"preferred-install": "source" | ||
} | ||
} |
Oops, something went wrong.