Skip to content

Commit

Permalink
phase 3 completed
Browse files Browse the repository at this point in the history
  • Loading branch information
BeycanDeveloper committed Mar 2, 2024
1 parent 141b60a commit fee30bc
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/Gateways/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ public function get_field_content($value, $forceFrontendLabel, $form): string
return $this->theme ?? 'light';
});

Hook::addFilter('theme', function () {
return $this->theme ?? 'light';
});

$tx = $this->get_tx_with_user_and_form_id(strval($formId));
$status = $this->is_this_form_needs_payment($form, $tx);

Expand Down
52 changes: 52 additions & 0 deletions app/Gateways/Gateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

namespace BeycanPress\CryptoPay\GravityForms\Gateways;

// @phpcs:disable Generic.Files.InlineHTML
// @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps

use BeycanPress\CryptoPay\Payment;

class Gateway extends AbstractGateway
{
/**
* @var string
*/
// @phpcs:ignore
public $type = 'cryptopay';

/**
* @param array<mixed> $properties
*/
public function __construct(array $properties = [])
{
parent::__construct($properties);
}

/**
* @return string
*/
public function get_form_editor_field_title(): string
{
return esc_attr__('CryptoPay', 'gf-cryptopay');
}

/**
* @return string
*/
public function get_form_editor_field_description(): string
{
return esc_attr__('Adds cryptocurrency payments to your form.', 'gf-cryptopay');
}

/**
* @param int $formId
* @return string
*/
public function run(int $formId): string
{
return (new Payment('gravityforms'))->html();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use BeycanPress\CryptoPayLite\Payment;

class CryptoPayLite extends AbstractGateway
class GatewayLite extends AbstractGateway
{
/**
* @var string
Expand Down
8 changes: 6 additions & 2 deletions app/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public function __construct()
10,
[
'orderId' => function ($tx) {
if (!isset($tx->orderId)) {
return esc_html__('Pending...', 'gf-cryptopay');
}

return Helpers::run('view', 'components/link', [
'url' => sprintf(admin_url('admin.php?page=gf_entries&view=entry&id=%d&lid=%d&order=ASC&filter&paged=1&pos=0&field_id&operator'), $tx->params->formId, $tx->orderId), // @phpcs:ignore
'text' => sprintf(esc_html__('View entry #%d', 'gf-cryptopay'), $tx->orderId)
Expand Down Expand Up @@ -55,9 +59,9 @@ public function paymentRedirectUrls(object $data): array
public function register(): void
{
if (Helpers::exists()) {
\GF_Fields::register(new Gateways\CryptoPayLite());
\GF_Fields::register(new Gateways\Gateway());
} else {
\GF_Fields::register(new Gateways\CryptoPayLite());
\GF_Fields::register(new Gateways\GatewayLite());
}
}
}

0 comments on commit fee30bc

Please sign in to comment.