-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from thejoshualewis/master
BitPay QuickPay setup
- Loading branch information
Showing
25 changed files
with
962 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 @@ | ||
.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,24 @@ | ||
<?php | ||
|
||
class BPC_Buttons { | ||
function __construct() { | ||
} | ||
|
||
function BPC_getButtons(){ | ||
|
||
|
||
$button_url = 'https://bitpay.com/resources/paymentButtons'; | ||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, $button_url); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
$result = curl_exec($ch); | ||
curl_close ($ch); | ||
return $result; | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
?> |
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,11 @@ | ||
<?php | ||
|
||
class BPC_Client { | ||
private $network; | ||
|
||
function __construct() { | ||
|
||
} | ||
} | ||
|
||
?> |
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,56 @@ | ||
<?php | ||
|
||
class BPC_Configuration { | ||
private $apiToken; | ||
private $network; | ||
|
||
function __construct( $apiToken, $network = null) { | ||
$this->apiToken = $apiToken; | ||
if($network == 'test' || $network == null): | ||
$this->network = $this->BPC_getApiHostDev(); | ||
else: | ||
$this->network = $this->BPC_getApiHostProd(); | ||
endif; | ||
} | ||
|
||
function BPC_generateHash($data) { | ||
return hash_hmac('sha256', $data, sha1($this->BPC_getAPIToken())); | ||
} | ||
|
||
function BPC_checkHash($data,$hash_key) { | ||
if(hash_equals($hash_key,hash_hmac('sha256', $data, sha1($this->BPC_getAPIToken())))){ | ||
return true; | ||
}; | ||
return false; | ||
} | ||
|
||
function BPC_getAPIToken() { | ||
return $this->apiToken; | ||
} | ||
|
||
function BPC_getNetwork() { | ||
return $this->network; | ||
} | ||
|
||
public function BPC_getApiHostDev() | ||
{ | ||
return 'test.bitpay.com'; | ||
} | ||
|
||
public function BPC_getApiHostProd() | ||
{ | ||
return 'bitpay.com'; | ||
} | ||
|
||
public function BPC_getApiPort() | ||
{ | ||
return 443; | ||
} | ||
|
||
public function BPC_getInvoiceURL(){ | ||
return $this->network.'/invoices'; | ||
} | ||
|
||
|
||
} | ||
?> |
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,106 @@ | ||
<?php | ||
|
||
class BPC_Invoice | ||
{ | ||
|
||
public function __construct($item) | ||
{ | ||
$this->item = $item; | ||
|
||
} | ||
|
||
public function BPC_checkInvoiceStatus($orderID) | ||
{ | ||
|
||
$post_fields = ($this->item->item_params); | ||
|
||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, 'https://' . $this->item->invoice_endpoint . '/' . $post_fields->invoiceID); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
$result = curl_exec($ch); | ||
curl_close($ch); | ||
return $result; | ||
} | ||
|
||
public function BPC_createInvoice() | ||
{ | ||
|
||
|
||
$post_fields = json_encode($this->item->item_params); | ||
|
||
$pluginInfo = $this->item->item_params->extension_version; | ||
$request_headers = array(); | ||
$request_headers[] = 'X-BitPay-Plugin-Info: ' . $pluginInfo; | ||
$request_headers[] = 'Content-Type: application/json'; | ||
|
||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, 'https://' . $this->item->invoice_endpoint); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers); | ||
curl_setopt($ch, CURLOPT_POST, 1); | ||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
$result = curl_exec($ch); | ||
|
||
$this->invoiceData = $result; | ||
|
||
curl_close($ch); | ||
|
||
} | ||
|
||
public function BPC_getInvoiceData() | ||
{ | ||
return $this->invoiceData; | ||
} | ||
|
||
public function BPC_getInvoiceURL() | ||
{ | ||
$data = json_decode($this->invoiceData); | ||
return $data->data->url; | ||
} | ||
|
||
public function BPC_updateBuyersEmail($invoice_result, $buyers_email) | ||
{ | ||
$invoice_result = json_decode($invoice_result); | ||
|
||
$update_fields = new stdClass(); | ||
$update_fields->token = $this->item->item_params->token; | ||
$update_fields->buyerProvidedEmail = $buyers_email; | ||
$update_fields->invoiceId = $invoice_result->data->id; | ||
$update_fields = json_encode($update_fields); | ||
|
||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, 'https://' . $this->item->buyers_email_endpoint); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | ||
curl_setopt($ch, CURLOPT_POST, 1); | ||
curl_setopt($ch, CURLOPT_POSTFIELDS, $update_fields); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
$result = curl_exec($ch); | ||
curl_close($ch); | ||
return $result; | ||
|
||
} | ||
|
||
public function BPC_updateBuyerCurrency($invoice_result, $buyer_currency) | ||
{ | ||
$invoice_result = json_decode($invoice_result); | ||
|
||
$update_fields = new stdClass(); | ||
$update_fields->token = $this->item->item_params->token; | ||
$update_fields->buyerSelectedTransactionCurrency = $buyer_currency; | ||
$update_fields->invoiceId = $invoice_result->data->id; | ||
$update_fields = json_encode($update_fields); | ||
|
||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, 'https://' . $this->item->buyer_transaction_endpoint); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | ||
curl_setopt($ch, CURLOPT_POST, 1); | ||
curl_setopt($ch, CURLOPT_POSTFIELDS, $update_fields); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
$result = curl_exec($ch); | ||
curl_close($ch); | ||
return $result; | ||
|
||
} | ||
|
||
} |
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 @@ | ||
<?php | ||
|
||
class BPC_Item { | ||
function __construct($config,$item_params) { | ||
$this->token = $config->BPC_getAPIToken(); | ||
$this->endpoint = $config->BPC_getNetwork(); | ||
$this->item_params = $item_params; | ||
return $this->BPC_getItem(); | ||
} | ||
|
||
|
||
function BPC_getItem(){ | ||
$this->invoice_endpoint = $this->endpoint.'/invoices'; | ||
$this->buyer_transaction_endpoint = $this->endpoint.'/invoiceData/setBuyerSelectedTransactionCurrency'; | ||
$this->item_params->token = $this->token; | ||
return ($this->item_params); | ||
} | ||
|
||
} | ||
|
||
?> |
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) 2014-2019 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 |
---|---|---|
@@ -1 +1,43 @@ | ||
# Notice | ||
|
||
This is a Community-supported project. | ||
|
||
If you are interested in becoming a maintainer of this project, please contact us at [email protected]. Developers at BitPay will attempt to work along the new maintainers to ensure the project remains viable for the foreseeable future. | ||
|
||
# Description | ||
|
||
Embed a shortcode on any page or post to instantly accept Bitcoin payments. | ||
|
||
# Quick Setup | ||
|
||
This version requires the following | ||
|
||
* A BitPay merchant account ([Test](http://test.bitpay.com) or [Production](http://www.bitpay.com)) | ||
* An API Token ([Test](https://test.bitpay.com/dashboard/merchant/api-tokens) or [Production](https://bitpay.com/dashboard/merchant/api-tokens) | ||
* When setting up your token, **uncheck** the *Require Authentication button* | ||
|
||
|
||
# Plugin Fields | ||
|
||
After the plugin is activated, BitPay QuickPay will appear in the left navigation of Wordpress | ||
|
||
|
||
* **Merchant Tokens** | ||
* A ***development*** or ***production*** token will need to be set | ||
* **Endpoint** | ||
* Choose **Test** or **Production**, depending on your current setup. Your matching API Token must be set. | ||
|
||
* **Currency** | ||
* Choose the currency to accept. If no currency is set, **USD** will be the default. | ||
|
||
# How to use | ||
|
||
In the settings page, there is a list of buttons to display. Simply adjust the price for any button, and your code will automatically be generated. | ||
|
||
Example: `[bitpayquickpay name ="paywithbitpaysupportedcurrencies" price="1.50"]` | ||
|
||
Copy and paste this code into a post/page/widget to generate a button. | ||
|
||
|
||
|
||
![](https://bitpay.com/cdn/en_US/bp-btn-pay-currencies.svg) |
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.
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,15 @@ | ||
|
||
.bpqpButton{ | ||
background-color: transparent; | ||
} | ||
.bpqpButton:hover {opacity:.5; background-color: transparent;} | ||
.bpqpButton:active { | ||
background-color: transparent; | ||
} | ||
|
||
.bpqpMsg{ | ||
background-color: transparent; | ||
display:none; | ||
} | ||
|
||
.bpqpButtonClicked {opacity:.5; background-color: transparent;} |
Oops, something went wrong.