Changeset 1796742
- Timestamp:
- 01/03/2018 11:01:39 PM (8 years ago)
- Location:
- spicepay/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (1 diff)
-
spicepay.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
spicepay/trunk/readme.txt
r1794215 r1796742 13 13 == Description == 14 14 15 Use SpicePay's plugin to accept Bitcoin payments. 15 The more online payment options your customers have, the better – and revolutionary blockchain technology empowers you to connect with customers in a new way, with a world of benefits. SpicePay’s blockchain payment platform provides an easy, low-cost way to accept online payments in bitcoin and other cryptocurrencies, and transact with anyone, anywhere. 16 17 Our Wordpress plugin, compatible with all Woocommerce stores was uniquely designed to meet the needs of online businesses. You can now easily install our plugin to begin accepting cryptocurrency payments right away. Set up is easy and our support staff is reachable 24/7 to help out with any questions or concerns you might have! 18 16 19 Key features 20 * NEW! Accept online payments in bitcoin and other cryptocurrencies 17 21 * Support all bitcoin wallets by offering QR code scanning, a clickable bitcoin URI and a bitcoin address/amount that can be copy/pasted 18 * Price in your local currency, let customers pay with bitcoin 22 * Price in your local currency, let customers pay with bitcoin and other cryptocurrencies 19 23 * Receive instant payment confirmation (e.g. for virtual goods) 20 * Have an overview of all your bitcoinpayments in your SpicePay merchant dashboard at https://www.spicepay.com/dashboard.php24 * Have an overview of all your cryptocurrency payments in your SpicePay merchant dashboard at https://www.spicepay.com/dashboard.php 21 25 * Refund your customers in bitcoin in your SpicePay merchant dashboard at https://www.spicepay.com/dashboard.php 22 26 -
spicepay/trunk/spicepay.php
r1794310 r1796742 4 4 Plugin URI: https://www.spicepay.com/ 5 5 Description: SpicePay Plugin for WooCommerce 6 Version: 1.0. 06 Version: 1.0.1 7 7 Author: SpicePay 8 8 Author URI: https://www.spicepay.com … … 37 37 $this->public_key = $this->get_option('public_key'); 38 38 $this->secret_key = $this->get_option('secret_key'); 39 $this->title = ' spicepay';40 $this->description = 'Pay ment with Spicepay';39 $this->title = 'Cryptocurrency payments'; 40 $this->description = 'Pay with Bitcoin or Litecoin or Bitcoin Cash or other cryptocurrencies via SpicePay'; 41 41 42 42 // Actions … … 96 96 **/ 97 97 public function generate_form($order_id){ 98 $order = new WC_Order( $order_id );99 100 $sum = number_format($order-> order_total, 2, '.', '');98 $order = wc_get_order( $order_id ); 99 100 $sum = number_format($order->get_total(), 2, '.', ''); 101 101 $account = $order_id; 102 102 103 103 104 $code = '<form action="https://www.spicepay.com/pay.php" method="POST" target="_blank">' 105 . '<input type="hidden" name="amountUSD" value="' . $sum . '" />' 104 $code = '<form id="spicepaypaymentmethod" name="spicepaypaymentmethod" action="https://www.spicepay.com/p.php" method="POST">' 105 . '<input type="hidden" name="amount" value="' . $sum . '" />' 106 . '<input type="hidden" name="currency" value="USD" />' 106 107 . '<input type="hidden" name="orderId" value="' . $order_id . '"/>' 107 108 . '<input type="hidden" name="siteId" value="' . $this->public_key . '"/>' 108 109 . '<input type="hidden" name="language" value="en"/>' 109 110 . '<input type="submit" value="'.__('Pay', 'woocommerce').'"/>' 110 . '</form>'; 111 . '</form>' 112 . '<script>document.getElementById("spicepaypaymentmethod").submit();</script>' 113 ; 111 114 112 115 return $code; … … 117 120 **/ 118 121 function process_payment($order_id){ 119 $order = new WC_Order($order_id);122 $order = wc_get_order($order_id); 120 123 121 124 return array( 122 125 'result' => 'success', 123 'redirect' => add_query_arg('order ', $order->id, add_query_arg('key', $order->order_key, get_permalink(woocommerce_get_page_id('pay'))))126 'redirect' => add_query_arg('order-pay', $order->get_id(), add_query_arg('key', $order->get_order_key(), get_permalink(woocommerce_get_page_id('pay')))) 124 127 ); 125 128 } … … 131 134 132 135 function callback(){ 133 136 write_log('IPN Call'.json_encode($_POST)); 134 137 135 138 if (isset($_POST['paymentId']) && isset($_POST['orderId']) && isset($_POST['hash']) 136 && isset($_POST['paymentAmountBTC']) && isset($_POST['paymentAmountUSD']) 137 && isset($_POST['receivedAmountBTC']) && isset($_POST['receivedAmountUSD'])) { 138 139 139 && isset($_POST['paymentCryptoAmount']) && isset($_POST['paymentAmountUSD']) 140 && isset($_POST['receivedCryptoAmount']) && isset($_POST['receivedAmountUSD'])) { 141 140 142 $paymentId = addslashes(filter_input(INPUT_POST, 'paymentId', FILTER_SANITIZE_STRING)); 141 143 $orderId = addslashes(filter_input(INPUT_POST, 'orderId', FILTER_SANITIZE_STRING)); … … 158 160 159 161 $secretCode = $this->secret_key; 160 $order = new WC_Order( $orderId ); 161 162 if (!empty($order->ID)) { 162 $order = wc_get_order( $orderId ); 163 $hashString = $secretCode . $paymentId . $orderId . $clientId . $paymentCryptoAmount . $paymentAmountUSD . $receivedCryptoAmount . $receivedAmountUSD . $status; 164 write_log('Order ID '.$order->get_id()); 165 if (!empty($order->get_id())) { 166 write_log('Hash compare '.md5($hashString).' - '.$hash); 163 167 164 if (0 == strcmp(md5($ secretCode . $paymentId . $orderId . $clientId . $paymentAmountBTC . $paymentAmountUSD . $receivedAmountBTC . $receivedAmountUSD . $status), $hash)) {168 if (0 == strcmp(md5($hashString), $hash)) { 165 169 166 170 167 $sum = number_format($order-> order_total, 2, '.', '');171 $sum = number_format($order->get_total(), 2, '.', ''); 168 172 if ((float)$sum != $receivedAmountUSD) { 169 173 echo 'bad amount'; 174 write_log('bad amount'); 170 175 } else { 171 176 $order->payment_complete(); 172 177 echo 'OK'; 178 write_log('OK'); 173 179 174 180 } … … 176 182 } 177 183 184 }else{ 185 echo 'fail'; 186 write_log('fail'); 178 187 } 179 188 … … 181 190 } else { 182 191 echo 'fail'; 192 write_log('fail'); 183 193 } 184 194 … … 190 200 191 201 202 203 } 204 205 206 if (!function_exists('write_log')) { 207 208 function write_log($log) { 209 if (true === WP_DEBUG) { 210 if (is_array($log) || is_object($log)) { 211 error_log(print_r($log, true)); 212 } else { 213 error_log($log); 214 } 215 } 216 } 192 217 193 218 } … … 203 228 add_filter('woocommerce_payment_gateways', 'add_spicepay_gateway'); 204 229 } 205 ?>
Note: See TracChangeset
for help on using the changeset viewer.