/** * Updates the status of the order. * Webhook needs to be added to Conekta account tusitio.com/wc-api/WC_Conekta_Cash_Gateway */ public function webhook_handler() { header('HTTP/1.1 200 OK'); $body = @file_get_contents('php://input'); $event = json_decode($body); $charge = $event->data->object; $order_id = $charge->reference_id; $paid_at = date("Y-m-d", $charge->paid_at); $order = new WC_Order($order_id); if (strpos($event->type, "charge.paid") !== false) { update_post_meta($order->id, 'conekta-paid-at', $paid_at); $order->payment_complete(); $order->add_order_note(sprintf("Payment completed in Oxxo and notification of payment received")); parent::offline_payment_notification($order_id, $charge->details->name); } }
public function __construct() { $this->id = 'conektacard'; $this->method_title = __('Conekta Card', 'woocommerce'); $this->has_fields = true; $this->init_form_fields(); $this->init_settings(); $this->title = $this->settings['title']; $this->description = ''; $this->icon = $this->settings['alternate_imageurl'] ? $this->settings['alternate_imageurl'] : WP_PLUGIN_URL . "/" . plugin_basename(dirname(__FILE__)) . '/images/credits.png'; $this->usesandboxapi = strcmp($this->settings['debug'], 'yes') == 0; $this->enablemeses = strcmp($this->settings['meses'], 'yes') == 0; $this->testApiKey = $this->settings['test_api_key']; $this->liveApiKey = $this->settings['live_api_key']; $this->testPublishableKey = $this->settings['test_publishable_key']; $this->livePublishableKey = $this->settings['live_publishable_key']; //$this->useUniquePaymentProfile = strcmp($this->settings['enable_unique_profile'], 'yes') == 0; $this->publishable_key = $this->usesandboxapi ? $this->testPublishableKey : $this->livePublishableKey; $this->secret_key = $this->usesandboxapi ? $this->testApiKey : $this->liveApiKey; $this->lang_options = parent::set_locale_options()->get_lang_options(); add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); add_action('admin_notices', array(&$this, 'perform_ssl_check')); }