This repository has been archived by the owner on Mar 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
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
0 parents
commit 5f2bcec
Showing
35 changed files
with
4,357 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,9 @@ | ||
# temp/vendor files | ||
tmp/ | ||
*.zip | ||
vendor/ | ||
|
||
# OS- and editor-generated files | ||
*.swp | ||
*~ | ||
.DS_Store |
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,58 @@ | ||
# DashPayments for WooCommerce | ||
|
||
DashPayments for WooCommerce is a Wordpress plugin that enables WooCommerce merchants to accept [Dash](https://www.dash.org "Dash - Digital Cash") directly, without the need for a third-party payment processor. | ||
|
||
* Uses BIP32 extended public (xpub) keys for address generation. | ||
* Requires access to an [Insight-API-Dash](https://github.com/udjinm6/insight-api-dash) instance | ||
|
||
### Requirements: | ||
|
||
* An Electrum-Dash wallet for receiving payments | ||
* WordPress 4.4.2+ | ||
* WooCommerce 2.5.2+ | ||
* PHP 5.5+ with valid extensions: | ||
- gmp | ||
- bcmath | ||
- gd | ||
- mcrypt | ||
- openssl | ||
- curl | ||
- json | ||
|
||
### Developers: Building the plugin | ||
|
||
Install composer using your package manager, then use ```composer install``` to fetch all dependencies and place them into 'vendor/'. | ||
|
||
If desired, use 'zip' to package the directory into a zip file with the same name: | ||
|
||
cd .. && zip -r dashpay-woocommerce.zip dashpay-woocommerce/ | ||
|
||
### Installation and Activation | ||
|
||
Extract the .zip file and copy or FTP the dashpay-woocommerce directory to the WordPress 'plugins' directory. Activate the plugin in the WordPress-admin console. | ||
|
||
Navigate to WooCommerce -> Settings -> Checkout. Click the 'Dash' option at the top of the page. Paste your xpub key from Electrum-Dash into the box labeled "Dash BIP32 Extended Public Key", and click 'Save changes' at the bottom of the page. | ||
|
||
If you see a message stating "Dash payment gateway is operational", you should be ready to accept payment in Dash. | ||
|
||
### **HIGHLY RECOMMENDED (READ THIS SECTION)** | ||
|
||
It's highly recommended that you setup a cron job to handle background order processing. It's not technically required, but will catch things like if a user closes their browser before the payment gets processed. | ||
|
||
For manual cron jobs, add this line to your crontab (replace <yourdomain.com> with your own WordPress site URL): | ||
|
||
* * * * * curl -s http://<yourdomain.com>/wp-cron.php?doing_wp_cron > /dev/null 2>&1 | ||
|
||
For CPANEL, run the command below every minute (replace <yourdomain.com> with your own WordPress site URL): | ||
|
||
curl -s http://<yourdomain.com>/wp-cron.php?doing_wp_cron > /dev/null 2>&1 | ||
|
||
### Contributions/Bugs/Issues | ||
|
||
If you'd like to contribute to the project, please submit a pull request at this Github repository (please fork this project and submit a pull request using a feature-branch). | ||
|
||
If you think you've found a bug, please file an issue at this Github repo (start by clicking the issues tab above). | ||
|
||
### License | ||
|
||
DashPayments for WooCommerce is released under the terms of the MIT license. See http://opensource.org/licenses/MIT. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,66 @@ | ||
// TODO: ensure we're on the correct page ("thankyou_page") | ||
// -- the one with the QR code & address for payment | ||
// | ||
var intervalId; | ||
var is_finalized; | ||
var instructions_hash; | ||
|
||
// store URL params (needed for order_key, to validate order) | ||
var params={};window.location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(str,key,value){params[key] = value;}); | ||
|
||
function do_the_thing() { | ||
|
||
// TODO: don't insert the order_id as a hidden input if possible | ||
|
||
// TODO: grab the order_key and ensure that a match exists before processing | ||
// in process_order_callback | ||
|
||
// get the ID & order_key here, then call ajax post... | ||
var order_id = jQuery('#order_id').val(); | ||
is_finalized = jQuery('#is_finalized').val(); | ||
|
||
var order_key = params.key; | ||
//console.log("params: ..."); | ||
//console.log(params); | ||
console.log("order_key = [" + order_key + "]"); | ||
|
||
console.log("calling ajax url now..."); | ||
jQuery.post(obj.ajaxurl, | ||
{ | ||
'action': 'check_order', | ||
'instructions_hash': instructions_hash, | ||
'order_key': order_key, | ||
'order_id': order_id | ||
}, | ||
function(response){ | ||
console.log('The server responded: ' + response); | ||
var resp = JSON.parse( response ); | ||
|
||
// get new instructions hash... | ||
instructions_hash = resp.instructions_hash; | ||
|
||
// console.log(resp); | ||
if ( resp.invoice_state_changed ) { | ||
// console.log("state changed, replacing HTML instructions..."); | ||
var b64_encoded = resp.payment_instructions; | ||
// console.log("b64_encoded = " + b64_encoded); | ||
jQuery('#payment_instructions').html( jQuery.base64.decode(b64_encoded) ); | ||
} | ||
if ( resp.is_order_finalized ) { | ||
// console.log("invoice in final state, clearing interval!"); | ||
window.clearInterval(intervalId); | ||
} | ||
} | ||
); | ||
|
||
} | ||
|
||
|
||
// initial setup | ||
is_finalized = jQuery('#is_finalized').val(); | ||
instructions_hash = ''; | ||
|
||
if ( !is_finalized ) { | ||
var intervalId = window.setInterval(do_the_thing, 10000); | ||
} | ||
|
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,29 @@ | ||
/* global woocommerce_admin */ | ||
|
||
/** | ||
* WooCommerce Admin JS | ||
*/ | ||
jQuery( function ( $ ) { | ||
|
||
// Hidden options | ||
$( '.hide_options_if_checked' ).each( function() { | ||
$( this ).find( 'input:eq(0)' ).change( function() { | ||
if ( $( this ).is( ':checked' ) ) { | ||
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).hide(); | ||
} else { | ||
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).show(); | ||
} | ||
}).change(); | ||
}); | ||
|
||
|
||
// Demo store notice | ||
$( 'input#woocommerce_demo_store' ).change(function() { | ||
if ( $( this ).is( ':checked' ) ) { | ||
$( '#woocommerce_demo_store_notice' ).closest( 'tr' ).show(); | ||
} else { | ||
$( '#woocommerce_demo_store_notice' ).closest( 'tr' ).hide(); | ||
} | ||
}).change(); | ||
|
||
}); |
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,112 @@ | ||
;(function(jQuery) { | ||
|
||
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", | ||
a256 = '', | ||
r64 = [256], | ||
r256 = [256], | ||
i = 0; | ||
|
||
var UTF8 = { | ||
|
||
/** | ||
* Encode multi-byte Unicode string into utf-8 multiple single-byte characters | ||
* (BMP / basic multilingual plane only) | ||
* | ||
* Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars | ||
* | ||
* @param {String} strUni Unicode string to be encoded as UTF-8 | ||
* @returns {String} encoded string | ||
*/ | ||
encode: function(strUni) { | ||
// use regular expressions & String.replace callback function for better efficiency | ||
// than procedural approaches | ||
var strUtf = strUni.replace(/[\u0080-\u07ff]/g, // U+0080 - U+07FF => 2 bytes 110yyyyy, 10zzzzzz | ||
function(c) { | ||
var cc = c.charCodeAt(0); | ||
return String.fromCharCode(0xc0 | cc >> 6, 0x80 | cc & 0x3f); | ||
}) | ||
.replace(/[\u0800-\uffff]/g, // U+0800 - U+FFFF => 3 bytes 1110xxxx, 10yyyyyy, 10zzzzzz | ||
function(c) { | ||
var cc = c.charCodeAt(0); | ||
return String.fromCharCode(0xe0 | cc >> 12, 0x80 | cc >> 6 & 0x3F, 0x80 | cc & 0x3f); | ||
}); | ||
return strUtf; | ||
}, | ||
|
||
/** | ||
* Decode utf-8 encoded string back into multi-byte Unicode characters | ||
* | ||
* @param {String} strUtf UTF-8 string to be decoded back to Unicode | ||
* @returns {String} decoded string | ||
*/ | ||
decode: function(strUtf) { | ||
// note: decode 3-byte chars first as decoded 2-byte strings could appear to be 3-byte char! | ||
var strUni = strUtf.replace(/[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g, // 3-byte chars | ||
function(c) { // (note parentheses for precence) | ||
var cc = ((c.charCodeAt(0) & 0x0f) << 12) | ((c.charCodeAt(1) & 0x3f) << 6) | (c.charCodeAt(2) & 0x3f); | ||
return String.fromCharCode(cc); | ||
}) | ||
.replace(/[\u00c0-\u00df][\u0080-\u00bf]/g, // 2-byte chars | ||
function(c) { // (note parentheses for precence) | ||
var cc = (c.charCodeAt(0) & 0x1f) << 6 | c.charCodeAt(1) & 0x3f; | ||
return String.fromCharCode(cc); | ||
}); | ||
return strUni; | ||
} | ||
}; | ||
|
||
while(i < 256) { | ||
var c = String.fromCharCode(i); | ||
a256 += c; | ||
r256[i] = i; | ||
r64[i] = b64.indexOf(c); | ||
++i; | ||
} | ||
|
||
function code(s, discard, alpha, beta, w1, w2) { | ||
s = String(s); | ||
var buffer = 0, | ||
i = 0, | ||
length = s.length, | ||
result = '', | ||
bitsInBuffer = 0; | ||
|
||
while(i < length) { | ||
var c = s.charCodeAt(i); | ||
c = c < 256 ? alpha[c] : -1; | ||
|
||
buffer = (buffer << w1) + c; | ||
bitsInBuffer += w1; | ||
|
||
while(bitsInBuffer >= w2) { | ||
bitsInBuffer -= w2; | ||
var tmp = buffer >> bitsInBuffer; | ||
result += beta.charAt(tmp); | ||
buffer ^= tmp << bitsInBuffer; | ||
} | ||
++i; | ||
} | ||
if(!discard && bitsInBuffer > 0) result += beta.charAt(buffer << (w2 - bitsInBuffer)); | ||
return result; | ||
} | ||
|
||
var Plugin = jQuery.base64 = function(dir, input, encode) { | ||
return input ? Plugin[dir](input, encode) : dir ? null : this; | ||
}; | ||
|
||
Plugin.btoa = Plugin.encode = function(plain, utf8encode) { | ||
plain = Plugin.raw === false || Plugin.utf8encode || utf8encode ? UTF8.encode(plain) : plain; | ||
plain = code(plain, false, r256, b64, 8, 6); | ||
return plain + '===='.slice((plain.length % 4) || 4); | ||
}; | ||
|
||
Plugin.atob = Plugin.decode = function(coded, utf8decode) { | ||
coded = String(coded).split('='); | ||
var i = coded.length; | ||
do {--i; | ||
coded[i] = code(coded[i], true, r64, a256, 6, 8); | ||
} while (i > 0); | ||
coded = coded.join(''); | ||
return Plugin.raw === false || Plugin.utf8decode || utf8decode ? UTF8.decode(coded) : coded; | ||
}; | ||
}(jQuery)); |
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,4 @@ | ||
#! /usr/local/bin/bash | ||
for F in {*php,includes/*php,includes/*/*php}; do | ||
php -l "$F" | ||
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,36 @@ | ||
{ | ||
"name": "blackcarrot/dashpay-woocommerce", | ||
"description": "DashPayments for WooCommerce", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Black Carrot Ventures", | ||
"email": "nmarley@blackcarrot.be", | ||
"homepage": "http://blackcarrotventures.com" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.4.0", | ||
"ext-gd": "*", | ||
"ext-gmp": "*", | ||
"ext-json": "*", | ||
"ext-curl": "*", | ||
"ext-openssl": "*", | ||
"ext-mcrypt": "*", | ||
"mdanter/ecc": "~0.3", | ||
"pleonasm/merkle-tree": "1.0.0", | ||
"fguillot/json-rpc": "0.0.1", | ||
"rych/hash_pbkdf2-compat": "~1.0", | ||
"lastguest/murmurhash": "~1.1", | ||
"rgooding/protobuf-php": "~0.0", | ||
"react/react": "~0.4", | ||
"react/socket-client": "~0.4", | ||
"bitwasp/buffertools": "~0.1.16", | ||
"bitwasp/trait": "~0.0", | ||
"bitwasp/stratum": "~0.1", | ||
"bitwasp/secp256k1-php": "~0.0.6", | ||
"bitwasp/bitcoin": "^0.0.20", | ||
"bacon/bacon-qr-code": "^1.0", | ||
"twig/twig": "~1.0" | ||
} | ||
} |
Oops, something went wrong.