Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
0xBeycan committed Feb 29, 2024
0 parents commit bab5aec
Show file tree
Hide file tree
Showing 41 changed files with 3,450 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
38 changes: 38 additions & 0 deletions .github/workflows/create-auto-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Create auto release

on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'

jobs:
auto_release:
name: Auto release
permissions: write-all
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@master

- name: Check if release already exists
run: |
existing_release=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.ref_name }} 2>&1)
if [[ $existing_release == *"Not Found"* ]]; then
echo "RELEASE_EXISTS=false" >> $GITHUB_ENV
else
echo "RELEASE_EXISTS=true" >> $GITHUB_ENV
fi
- name: Create Release
id: create_release
if: ${{ env.RELEASE_EXISTS == 'false' }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Version ${{ github.ref_name }}
body: Version ${{ github.ref_name }}
draft: false
prerelease: false
34 changes: 34 additions & 0 deletions .github/workflows/phpcs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: PHPCS Check

on:
push:
branches:
- master

jobs:
phpcs:
name: PHPCS Check
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'

- name: Install PHPCS
run: |
composer config --global --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer require --dev squizlabs/php_codesniffer=* slevomat/coding-standard
- name: Run PHPCS
run: |
composer phpcs --standard=phpcs.xml .
exit_status=$?
if [ $exit_status -ne 0 ]; then
echo "PHPCS check failed. Please fix the issues before merging."
exit 1
fi
141 changes: 141 additions & 0 deletions app/Gateways/MS_Gateway_CryptoPay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?php

declare(strict_types=1);

// @phpcs:disable PSR1.Files.SideEffects
// @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps

use BeycanPress\CryptoPay\Helpers;

require_once MD_CRYPTOPAY_DIR . 'views/MS_Gateway_CryptoPay_View_Button.php';
require_once MD_CRYPTOPAY_DIR . 'views/MS_Gateway_CryptoPay_View_Settings.php';

// @phpcs:ignore
class MS_Gateway_CryptoPay extends \MS_Gateway
{
// @phpcs:ignore
const ID = 'cryptopay';

/**
* @var string $instance
*/
// @phpcs:ignore
public static $instance;

/**
* @var string $id
*/
// @phpcs:ignore
public $id = '';

/**
* @var string $theme
*/
// @phpcs:ignore
public $theme;

/**
* @var string $name
*/
// @phpcs:ignore
protected $name = '';

/**
* @var string $group
*/
// @phpcs:ignore
protected $group = '';

/**
* @var string $description
*/
// @phpcs:ignore
protected $description = '';

/**
* @var bool $active
*/
// @phpcs:ignore
protected $active = false;

/**
* @var bool $manual_payment
*/
// @phpcs:ignore
protected $manual_payment = true;

/**
* @var bool $pro_rate
*/
// @phpcs:ignore
protected $pro_rate = false;

/**
* @var string $mode
*/
// @phpcs:ignore
protected $mode = 'live';

/**
* @return void
*/
public function after_load(): void
{
parent::after_load();

$this->id = self::ID;
$this->group = 'cryptopay';
$this->name = __('CryptoPay', 'md-cryptopay');
$this->description = __('Cryptocurrency payments', 'md-cryptopay');

$this->manual_payment = true;
$this->pro_rate = true;
$this->mode = Helpers::getTestnetStatus() ? \MS_Gateway::MODE_LIVE : \MS_Gateway::MODE_SANDBOX;
}

/**
* @return bool
*/
public function is_configured(): bool
{
$isConfigured = true;
$required = [];

foreach ($required as $field) {
$value = $this->$field;
if (empty($value)) {
$isConfigured = false;
break;
}
}

return apply_filters(
'ms_gateway_' . self::ID . '_is_configured',
$isConfigured
);
}

/**
* @param string $property
* @param mixed $value
* @return void
*/
// @phpcs:ignore
public function __set($property, $value)
{
if (property_exists($this, $property)) {
switch ($property) {
default:
parent::__set($property, $value);
break;
}
}

do_action(
'ms_gateway_' . self::ID . '__set_after',
$property,
$value,
$this
);
}
}
141 changes: 141 additions & 0 deletions app/Gateways/MS_Gateway_CryptoPay_Lite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?php

declare(strict_types=1);

// @phpcs:disable PSR1.Files.SideEffects
// @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps

use BeycanPress\CryptoPayLite\Helpers;

require_once MD_CRYPTOPAY_DIR . 'views/MS_Gateway_CryptoPay_Lite_View_Button.php';
require_once MD_CRYPTOPAY_DIR . 'views/MS_Gateway_CryptoPay_Lite_View_Settings.php';

// @phpcs:ignore
class MS_Gateway_CryptoPay_Lite extends \MS_Gateway
{
// @phpcs:ignore
const ID = 'cryptopay_lite';

/**
* @var string $instance
*/
// @phpcs:ignore
public static $instance;

/**
* @var string $id
*/
// @phpcs:ignore
public $id = '';

/**
* @var string $theme
*/
// @phpcs:ignore
public $theme;

/**
* @var string $name
*/
// @phpcs:ignore
protected $name = '';

/**
* @var string $group
*/
// @phpcs:ignore
protected $group = '';

/**
* @var string $description
*/
// @phpcs:ignore
protected $description = '';

/**
* @var bool $active
*/
// @phpcs:ignore
protected $active = false;

/**
* @var bool $manual_payment
*/
// @phpcs:ignore
protected $manual_payment = true;

/**
* @var bool $pro_rate
*/
// @phpcs:ignore
protected $pro_rate = false;

/**
* @var string $mode
*/
// @phpcs:ignore
protected $mode = 'live';

/**
* @return void
*/
public function after_load(): void
{
parent::after_load();

$this->id = self::ID;
$this->group = 'cryptopay';
$this->name = __('CryptoPay Lite', 'md-cryptopay');
$this->description = __('Cryptocurrency payments', 'md-cryptopay');

$this->manual_payment = true;
$this->pro_rate = true;
$this->mode = Helpers::getTestnetStatus() ? \MS_Gateway::MODE_LIVE : \MS_Gateway::MODE_SANDBOX;
}

/**
* @return bool
*/
public function is_configured(): bool
{
$isConfigured = true;
$required = [];

foreach ($required as $field) {
$value = $this->$field;
if (empty($value)) {
$isConfigured = false;
break;
}
}

return apply_filters(
'ms_gateway_' . self::ID . '_is_configured',
$isConfigured
);
}

/**
* @param string $property
* @param mixed $value
* @return void
*/
// @phpcs:ignore
public function __set($property, $value)
{
if (property_exists($this, $property)) {
switch ($property) {
default:
parent::__set($property, $value);
break;
}
}

do_action(
'ms_gateway_' . self::ID . '__set_after',
$property,
$value,
$this
);
}
}
Loading

0 comments on commit bab5aec

Please sign in to comment.