Plugin Directory

Changeset 2038229


Ignore:
Timestamp:
02/24/2019 02:10:25 PM (7 years ago)
Author:
coltpay01stan
Message:

change author name

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coltpay-commerce/trunk/coltpay-commerce.php

    r2035450 r2038229  
    44 * Plugin Name: Coltpay Commerce
    55 * Description: A payment gateway that allows your customers to pay with cryptocurrency via Coltpay Commerce
    6  * Author: Leaping Logic LLC
     6 * Author: ColtPay
    77 * Version: 1.0
    8  * Author URI: https://leapinglogic.com
     8 * Author URI: https://coltpay.com
    99 * Copyright: 2019 Coltpay
    1010 */
    1111
     12
    1213add_action( 'plugins_loaded', 'rsm_init_coltpay_gateway_class' );
    1314function rsm_init_coltpay_gateway_class() {
    14     if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
    15         require_once 'class-wc-gateway-coltpay.php';
    16         require_once 'class-shortcode-coltpay.php';
    17         add_filter( 'woocommerce_payment_gateways', 'rsm_add_coltpay_gateway_class' );
    18         add_action( 'woocommerce_admin_order_data_after_order_details', 'rsm_coltpay_order_meta_general' );
    19         add_action( 'woocommerce_order_details_after_order_table', 'rsm_coltpay_order_meta_general' );
    20         add_filter( 'woocommerce_email_order_meta_fields', 'rsm_custom_woocommerce_email_order_meta_fields', 10, 3 );
     15    if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
     16        require_once 'class-wc-gateway-coltpay.php';
     17        require_once 'class-shortcode-coltpay.php';
     18        add_filter( 'woocommerce_payment_gateways', 'rsm_add_coltpay_gateway_class' );
     19        add_action( 'woocommerce_admin_order_data_after_order_details', 'rsm_coltpay_order_meta_general' );
     20        add_action( 'woocommerce_order_details_after_order_table', 'rsm_coltpay_order_meta_general' );
     21        add_filter( 'woocommerce_email_order_meta_fields', 'rsm_custom_woocommerce_email_order_meta_fields', 10, 3 );
    2122
    22         add_action( 'woocommerce_api_wc_gateway_coltpay', 'rsm_coltpay_webhook_callback2' );
    23     }
     23        add_action( 'woocommerce_api_wc_gateway_coltpay', 'rsm_coltpay_webhook_callback2' );
     24    }
    2425}
    2526
    2627function rsm_add_coltpay_gateway_class( $methods ) {
    27     $methods[] = 'WC_Gateway_ColtPay'; 
     28    $methods[] = 'WC_Gateway_ColtPay';
    2829    return $methods;
    2930}
    3031
    31 function rsm_coltpay_order_meta_general( $order ) { 
    32     $invoice = $order->get_meta( '_coltpay_invoice' );
     32function rsm_coltpay_order_meta_general( $order ) {
     33    $invoice = $order->get_meta( '_coltpay_invoice' );
    3334
    34     if ( empty( $invoice ) ) return;
    35     ?>
     35    if ( empty( $invoice ) ) return;
     36    ?>
    3637
    37     <br class="clear" />
    38     <h3>ColtPay Data</h3>
    39     <div class="">
    40         <p>ColtPay Commerce Reference #<br>
    41             <?php echo __("Invoice: #", 'coltpay') . $invoice['code'] ?><br>
    42             <?php echo __("Bitcoin address  : ", 'coltpay') . $invoice['address'] ?><br>
    43             <?php echo __("total   : ", 'coltpay') . $invoice['total'] . __(' BTC', 'coltpay') ?><br>
    44         </p>
    45     </div>
     38    <br class="clear" />
     39    <h3>ColtPay Data</h3>
     40    <div class="">
     41        <p>ColtPay Commerce Reference #<br>
     42            <?php echo __("Invoice: #", 'coltpay') . $invoice['code'] ?><br>
     43            <?php echo __("Bitcoin address  : ", 'coltpay') . $invoice['address'] ?><br>
     44            <?php echo __("total   : ", 'coltpay') . $invoice['total'] . __(' BTC', 'coltpay') ?><br>
     45        </p>
     46    </div>
    4647
    47     <?php
     48    <?php
    4849}
    4950
    5051function rsm_custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) {
    5152
    52     $invoice = $order->get_meta( '_coltpay_invoice' );
    53     if ( empty( $invoice ) ) return $fields;
     53    $invoice = $order->get_meta( '_coltpay_invoice' );
     54    if ( empty( $invoice ) ) return $fields;
    5455
    5556    $fields['coinbase_commerce_reference'] = array(
     
    6364function rsm_coltpay_webhook_callback2() {
    6465
    65     // validation
    66     $coltpay_setting = get_option('woocommerce_coltpay_settings');
    67     $result = '';
     66    // validation
     67    $coltpay_setting = get_option('woocommerce_coltpay_settings');
     68    $result = '';
    6869    if ( ! isset( $_POST['api_key'] ) || $_POST['api_key'] != $coltpay_setting['api_key'] ) {
    69         exit;
     70        exit;
    7071    }
    7172
    72     if ( ! isset( $_POST['order_id'] ) ) {
    73         exit;
     73    if ( ! isset( $_POST['order_id'] ) ) {
     74        exit;
    7475    }
    7576
    7677    $order_id = intval($_POST['order_id']);
    7778
    78     $order = wc_get_order( $order_id );
    79     if ( $order === false ) {
    80         exit;
     79    $order = wc_get_order( $order_id );
     80    if ( $order === false ) {
     81        exit;
    8182    }
    8283
    83     $order->payment_complete( $order->get_id() );
    84     WC()->cart->empty_cart();
    85     echo 'OK';
     84    $order->payment_complete( $order->get_id() );
     85    WC()->cart->empty_cart();
     86    echo 'OK';
    8687    exit;
    8788}
Note: See TracChangeset for help on using the changeset viewer.