WordPress.org

Plugin Directory

Changeset 1796742


Ignore:
Timestamp:
01/03/18 23:01:39 (2 weeks ago)
Author:
spicepay1
Message:

Update: added cryptocurrencies

Location:
spicepay/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • spicepay/trunk/readme.txt

    r1794215 r1796742  
    1313== Description == 
    1414  
    15 Use SpicePay's plugin to accept Bitcoin payments.  
     15The 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 
     17Our 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  
    1619Key features 
     20* NEW! Accept online payments in bitcoin and other cryptocurrencies 
    1721* 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 
    1923* Receive instant payment confirmation (e.g. for virtual goods) 
    20 * Have an overview of all your bitcoin payments in your SpicePay merchant dashboard at https://www.spicepay.com/dashboard.php 
     24* Have an overview of all your cryptocurrency payments in your SpicePay merchant dashboard at https://www.spicepay.com/dashboard.php 
    2125* Refund your customers in bitcoin in your SpicePay merchant dashboard at https://www.spicepay.com/dashboard.php 
    2226  
  • spicepay/trunk/spicepay.php

    r1794310 r1796742  
    44Plugin URI:  https://www.spicepay.com/ 
    55Description: SpicePay Plugin for WooCommerce 
    6 Version: 1.0.0 
     6Version: 1.0.1 
    77Author: SpicePay 
    88Author URI: https://www.spicepay.com 
     
    3737    $this->public_key = $this->get_option('public_key'); 
    3838    $this->secret_key = $this->get_option('secret_key'); 
    39     $this->title = 'spicepay'; 
    40     $this->description = 'Payment with Spicepay'; 
     39    $this->title = 'Cryptocurrency payments'; 
     40    $this->description = 'Pay with Bitcoin or Litecoin or Bitcoin Cash or other cryptocurrencies via SpicePay'; 
    4141 
    4242    // Actions 
     
    9696 **/ 
    9797public 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, '.', ''); 
    101101    $account = $order_id; 
    102102     
    103103     
    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" />' 
    106107    . '<input type="hidden" name="orderId" value="' . $order_id . '"/>' 
    107108    . '<input type="hidden" name="siteId" value="' . $this->public_key . '"/>' 
    108109    . '<input type="hidden" name="language" value="en"/>' 
    109110    . '<input type="submit" value="'.__('Pay', 'woocommerce').'"/>' 
    110     . '</form>'; 
     111    . '</form>' 
     112    . '<script>document.getElementById("spicepaypaymentmethod").submit();</script>' 
     113    ; 
    111114 
    112115    return $code; 
     
    117120 **/ 
    118121function process_payment($order_id){ 
    119     $order = new WC_Order($order_id); 
     122    $order =  wc_get_order($order_id); 
    120123 
    121124    return array( 
    122125        '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')))) 
    124127    ); 
    125128} 
     
    131134 
    132135function callback(){ 
    133     
     136   write_log('IPN Call'.json_encode($_POST)); 
    134137 
    135138    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         
    140142        $paymentId = addslashes(filter_input(INPUT_POST, 'paymentId', FILTER_SANITIZE_STRING)); 
    141143        $orderId = addslashes(filter_input(INPUT_POST, 'orderId', FILTER_SANITIZE_STRING)); 
     
    158160         
    159161        $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); 
    163167                             
    164             if (0 == strcmp(md5($secretCode . $paymentId . $orderId . $clientId . $paymentAmountBTC . $paymentAmountUSD . $receivedAmountBTC . $receivedAmountUSD . $status), $hash)) { 
     168            if (0 == strcmp(md5($hashString), $hash)) { 
    165169                 
    166170             
    167                 $sum = number_format($order->order_total, 2, '.', '');  
     171                $sum = number_format($order->get_total(), 2, '.', '');  
    168172                  if ((float)$sum != $receivedAmountUSD) { 
    169173                            echo  'bad amount'; 
     174                            write_log('bad amount'); 
    170175                  } else { 
    171176                        $order->payment_complete(); 
    172177                      echo 'OK'; 
     178                      write_log('OK'); 
    173179                   
    174180                  } 
     
    176182            } 
    177183             
     184        }else{ 
     185           echo 'fail';  
     186           write_log('fail'); 
    178187        } 
    179188         
     
    181190    } else { 
    182191        echo 'fail'; 
     192        write_log('fail'); 
    183193    } 
    184194 
     
    190200 
    191201   
     202 
     203} 
     204 
     205 
     206if (!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    } 
    192217 
    193218} 
     
    203228add_filter('woocommerce_payment_gateways', 'add_spicepay_gateway'); 
    204229} 
    205 ?> 
Note: See TracChangeset for help on using the changeset viewer.