<commit_before><?php
/**
 * Minds Webhook: Stripe
 *
 * @version 1
 * @author <NAME>
 */
namespace Minds\Controllers\api\v1\webhooks;

use Minds\Core;
use Minds\Entities;
use Minds\Interfaces;
use Minds\Api\Factory;
use Minds\Helpers;
use Minds\Core\Payments;

class stripe implements Interfaces\Api, Interfaces\ApiIgnorePam
{
    /**
   * NOT AVAILABLE
   */
  public function get($pages)
  {
      return Factory::response(array('status'=>'error', 'message'=>'GET is not supported for this endpoint'));
  }

  /**
   */
  public function post($pages)
  {
      error_log("\n [webhooks][stripe]:: hit first entrace point");
      $input = @file_get_contents("php://input");


      $stripe = Core\Di\Di::_()->get('StripePayments');

      $config = Core\Di\Di::_()->get('Config');
      $signingKey = $config->payments['stripe']['webhook_keys']['default'];

      if ($pages[0] == 'connect') {
          $signingKey = $config->payments['stripe']['webhook_keys']['connect'];
      }

      $hooks = new Payments\Stripe\Webhooks((new Payments\Hooks())->loadDefaults(), $stripe);
      $hooks->setSignature($_SERVER["HTTP_STRIPE_SIGNATURE"])
        ->setSigningKey($signingKey)
        ->setPayload($input);

      $hooks->run();


      // Do something with $event_json

      http_response_code(400); // PHP 5.4 or greater
      exit;<commit_msg>(fix): return success<commit_after><?php
/**
 * Minds Webhook: Stripe
 *
 * @version 1
 * @author <NAME>
 */
namespace Minds\Controllers\api\v1\webhooks;

use Minds\Core;
use Minds\Entities;
use Minds\Interfaces;
use Minds\Api\Factory;
use Minds\Helpers;
use Minds\Core\Payments;

class stripe implements Interfaces\Api, Interfaces\ApiIgnorePam
{
    /**
   * NOT AVAILABLE
   */
  public function get($pages)
  {
      return Factory::response(array('status'=>'error', 'message'=>'GET is not supported for this endpoint'));
  }

  /**
   */
  public function post($pages)
  {
      error_log("\n [webhooks][stripe]:: hit first entrace point");
      $input = @file_get_contents("php://input");


      $stripe = Core\Di\Di::_()->get('StripePayments');

      $config = Core\Di\Di::_()->get('Config');
      $signingKey = $config->payments['stripe']['webhook_keys']['default'];

      if ($pages[0] == 'connect') {
          $signingKey = $config->payments['stripe']['webhook_keys']['connect'];
      }

      $hooks = new Payments\Stripe\Webhooks((new Payments\Hooks())->loadDefaults(), $stripe);
      $hooks->setSignature($_SERVER["HTTP_STRIPE_SIGNATURE"])
        ->setSigningKey($signingKey)
        ->setPayload($input);

      $hooks->run();


      // Do something with $event_json

      http_response_code(200); // PHP 5.4 or greater
      exit;
{'fraction_non_alphanumeric': 0.1765358993338268, 'fraction_numerical': 0.005921539600296077, 'mean_word_length': 3.438423645320197, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3208764', 'n_tokens_mistral': 902, 'n_tokens_neox': 894, 'n_words': 165}