Changeset 2038229
- Timestamp:
- 02/24/2019 02:10:25 PM (7 years ago)
- File:
-
- 1 edited
-
coltpay-commerce/trunk/coltpay-commerce.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
coltpay-commerce/trunk/coltpay-commerce.php
r2035450 r2038229 4 4 * Plugin Name: Coltpay Commerce 5 5 * Description: A payment gateway that allows your customers to pay with cryptocurrency via Coltpay Commerce 6 * Author: Leaping Logic LLC6 * Author: ColtPay 7 7 * Version: 1.0 8 * Author URI: https:// leapinglogic.com8 * Author URI: https://coltpay.com 9 9 * Copyright: 2019 Coltpay 10 10 */ 11 11 12 12 13 add_action( 'plugins_loaded', 'rsm_init_coltpay_gateway_class' ); 13 14 function 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 ); 21 22 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 } 24 25 } 25 26 26 27 function rsm_add_coltpay_gateway_class( $methods ) { 27 $methods[] = 'WC_Gateway_ColtPay'; 28 $methods[] = 'WC_Gateway_ColtPay'; 28 29 return $methods; 29 30 } 30 31 31 function rsm_coltpay_order_meta_general( $order ) { 32 $invoice = $order->get_meta( '_coltpay_invoice' );32 function rsm_coltpay_order_meta_general( $order ) { 33 $invoice = $order->get_meta( '_coltpay_invoice' ); 33 34 34 if ( empty( $invoice ) ) return;35 ?>35 if ( empty( $invoice ) ) return; 36 ?> 36 37 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> 46 47 47 <?php48 <?php 48 49 } 49 50 50 51 function rsm_custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) { 51 52 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; 54 55 55 56 $fields['coinbase_commerce_reference'] = array( … … 63 64 function rsm_coltpay_webhook_callback2() { 64 65 65 // validation66 $coltpay_setting = get_option('woocommerce_coltpay_settings');67 $result = '';66 // validation 67 $coltpay_setting = get_option('woocommerce_coltpay_settings'); 68 $result = ''; 68 69 if ( ! isset( $_POST['api_key'] ) || $_POST['api_key'] != $coltpay_setting['api_key'] ) { 69 exit;70 exit; 70 71 } 71 72 72 if ( ! isset( $_POST['order_id'] ) ) {73 exit;73 if ( ! isset( $_POST['order_id'] ) ) { 74 exit; 74 75 } 75 76 76 77 $order_id = intval($_POST['order_id']); 77 78 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; 81 82 } 82 83 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'; 86 87 exit; 87 88 }
Note: See TracChangeset
for help on using the changeset viewer.