/**
  * Process bill_paid event from webhook
  * @param $data array
  **/
 private function bill_paid($data)
 {
     if (empty($data->bill->subscription)) {
         $order = $this->find_order_by_id($data->bill->code);
     } else {
         $wc_subscription_id = $data->bill->subscription->code;
         $vindi_subscription_id = $data->bill->subscription->id;
         $cycle = $data->bill->period->cycle;
         $subscription = $this->find_subscription_by_id($wc_subscription_id);
         $order = $this->find_order_by_subscription_and_cycle($vindi_subscription_id, $cycle);
     }
     $new_status = $this->container->get_return_status();
     $order->update_status($new_status, __('O Pagamento foi realizado com sucesso pela Vindi.', 'woocommerce-vindi'));
 }
 /**
  * Validate plugin settings
  * @return bool
  */
 public function validate_settings()
 {
     $currency = get_option('woocommerce_currency');
     $api_key = $this->container->get_api_key();
     return in_array($currency, ['BRL']) && !empty($api_key);
 }
 /**
  */
 public function add_admin_scripts()
 {
     return $this->settings->add_script('js/simple-subscription-fields.js', array('jquery'));
 }