Skip to content

Commit

Permalink
First stable release
Browse files Browse the repository at this point in the history
  • Loading branch information
victorybiz committed Aug 22, 2021
1 parent 21a205a commit 48a9ac6
Show file tree
Hide file tree
Showing 14 changed files with 188 additions and 92 deletions.
Binary file modified .DS_Store
Binary file not shown.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `laravel-crypto-payment-gateway` will be documented in this file

## 0.0.1 - 2021-08-21
## v1.0.0 - 2021-08-22

- First stable release

## v0.0.1 - 2021-08-21

- initial release
28 changes: 9 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,11 @@
[![Total Downloads](https://img.shields.io/packagist/dt/victorybiz/laravel-crypto-payment-gateway.svg?style=flat-square)](https://packagist.org/packages/victorybiz/laravel-crypto-payment-gateway)
![GitHub Actions](https://github.com/victorybiz/laravel-crypto-payment-gateway/actions/workflows/main.yml/badge.svg)

### DEMO PREVIEW
1. Payment Not Received (Awaiting Payment)

![preview](https://github.com/victorybiz/laravel-crypto-payment-gateway/raw/main/demo.gif)

2. Payment Received (Correct Amount)

![preview](https://github.com/victorybiz/laravel-crypto-payment-gateway/raw/main/demo2.gif)

3. Payment Received (Unrecognized)

![preview](https://github.com/victorybiz/laravel-crypto-payment-gateway/raw/main/demo3.gif)
![preview](https://github.com/victorybiz/laravel-crypto-payment-gateway/raw/main/demo.png)

## Table of Contents
- [Laravel Crypto Payment Gateway](#laravel-crypto-payment-gateway)
- [DEMO PREVIEW](#demo-preview)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
- [Requirements](#requirements)
Expand Down Expand Up @@ -81,7 +70,7 @@ This package is create a laravel wrapper on the [GoUrl.io](https://gourl.io)'s [
<a name="core-dependencies"></a>

### Dependencies
The `compact` and `standard` box style uses **Alpinejs** and **TailwindCSS**. While the `gourl-boostrap` uses assets provided by [GoUrl.io](https://gourl.io). You do not need to install any of the dependencies, the package uses the CDN version of dependencies.
The `compact` and `standard` box template uses **Alpinejs** and **TailwindCSS**. While the `gourl-cryptobox-iframe` and `gourl-cryptobox-boostrap` uses assets provided by [GoUrl.io](https://gourl.io). You do not need to install any of the dependencies, the package uses the CDN version of dependencies.

<a name="configuration"></a>

Expand Down Expand Up @@ -120,7 +109,7 @@ GOURL_PAYMENTBOX_BITCOINCASH_PRIVATE_KEY
```

#### Config Options
See the published `config/laravel-crypto-payment-gateway.php` for available options to customize the payment box like changing logo and box style.
See the published `config/laravel-crypto-payment-gateway.php` for available options to customize the payment box like changing `logo`, `box_template`, `box_template_options` and other configuration options.

<a name="usage"></a>

Expand Down Expand Up @@ -381,14 +370,15 @@ $payment_history = $cryptobox->payment_history($boxID = "", $orderID = "", $user
<a name="testing"></a>

## Resources
The following packages was put together to makeup this seamless package.
* [GoUrl.io Website](https://gourl.io)
* [GoUrl.io's CryptoAPI Payment Gateway Repository](https://github.com/cryptoapi/Payment-Gateway)
* [PHP Class API Doc](https://gourl.io/api-php.html)
* [TailwindCSS](tailwindcss.com/) used on `compact` and `standard` box style.
* [AlpineJS](https://alpinejs.dev) used on `compact` and `standard` box style.
* [Alpine Clipboard](https://github.com/ryangjchandler/alpine-clipboard) used on `compact` and `standard` box style.
* [Alpine Tooltip](https://github.com/ryangjchandler/alpine-tooltip) used on `compact` and `standard` box style.
* [tc-lib-barcode](https://github.com/tecnickcom/tc-lib-barcode) used on `compact` and `standard` box style.
* [TailwindCSS](tailwindcss.com/)
* [AlpineJS](https://alpinejs.dev)
* [Alpine Clipboard](https://github.com/ryangjchandler/alpine-clipboard)
* [Alpine Tooltip](https://github.com/ryangjchandler/alpine-tooltip)
* [tc-lib-barcode](https://github.com/tecnickcom/tc-lib-barcode)


<a name="resources"></a>
Expand Down
42 changes: 37 additions & 5 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
*/
return [
/**
* Box Style
* Box Template
*
* 1. 'compact' (default)
* 2. 'standard'
* 3. 'gourl-bootstrap'
* 3. 'gourl-cryptobox-iframe'
* 4. 'gourl-cryptobox-bootstrap'
*/
'box_style' => 'compact',
'box_template' => 'compact',

/**
* Hook IPN (Instant payment notification) to the following static class method.
Expand Down Expand Up @@ -135,7 +137,7 @@
/**
* Relative logo path
*/
'logo' => 'vendor/laravel-crypto-payment-gateway/images/logo.png',
'logo' => 'vendor/laravel-crypto-payment-gateway/images/your_logo.png',

/**
* Show logo on payment page
Expand All @@ -147,9 +149,39 @@
*/
'show_language_box' => true,

/**
* Box template configurable options
*/
'box_template_options' => [
'compact' => [
// no configurable options
],
'standard' => [
// no configurable options
],
'gourl_cryptobox_iframe' => [
'submit_btn' => true,
'width' => '540',
'height' => '230',
'box_style' => '',
'message_style' => '',
'anchor' => '',
// See display_cryptobox() in https://github.com/cryptoapi/Payment-Gateway/blob/master/lib/cryptobox.class.php for details
],
'gourl_cryptobox_bootstrap' => [
'custom_text' => null,
'coin_image_size' => 70,
'qrcode_size' => 200,
'result_img_path' => 'default',
'result_img_size' => 250,
'method' => 'curl', // curl or ajax
'debug' => false,
// See display_cryptobox_bootstrap() in https://github.com/cryptoapi/Payment-Gateway/blob/master/lib/cryptobox.class.php for details
],
],

/**
* optional, gourl affiliate key
* GoUrl affiliate key
*/
'webdev_key' => env('GOURL_WEBDEV_KEY', ''),
];
Binary file added demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/.DS_Store
Binary file not shown.
Binary file added resources/views/.DS_Store
Binary file not shown.
36 changes: 19 additions & 17 deletions resources/views/paymentbox-compact.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,25 @@
@if($laravelCryptoPaymentGateway->showLogo)
<img class="w-auto h-12 mx-auto" src="{{ asset($laravelCryptoPaymentGateway->logo) }}" alt="{{ asset($laravelCryptoPaymentGateway->logo) }}">
@endif

<div class="mt-4 text-center">
{{-- Custim currency box --}}
<span class="block mt-1 mb-2 font-bold">{!! $localisation["payment"] !!}</span>
@if(is_array($laravelCryptoPaymentGateway->enabledCoinImages) && count($laravelCryptoPaymentGateway->enabledCoinImages) > 1)
@foreach($laravelCryptoPaymentGateway->enabledCoinImages as $coin => $imageData)
<a
href="?{{ $queryStrings ? $queryStrings.'&' : '' }}coin={{ $coin }}"
x-data="{ tooltip: '{{ addslashes(str_replace("%coinName%", ucfirst($coin), $localisation["pay_in"])) }}' }"
x-tooltip="tooltip"
class="inline-block p-1 border hover:border-gray-400 {{ request()->query('coin') == $coin ? 'border rounded border-gray-800' : '' }}"
>
<img class="h-14" src="data:image/png;base64,{{ $imageData }}" alt="{{ addslashes(str_replace("%coinName%", ucfirst($coin), $localisation["pay_in"])) }}">
</a>
@endforeach
@endif
</div>

@if(!$boxIsPaid)
<div class="mt-4 text-center">
{{-- Custim currency box --}}
<span class="block mt-1 mb-2 font-bold">{!! $localisation["payment"] !!}</span>
@if(is_array($laravelCryptoPaymentGateway->enabledCoinImages) && count($laravelCryptoPaymentGateway->enabledCoinImages) > 1)
@foreach($laravelCryptoPaymentGateway->enabledCoinImages as $coin => $imageData)
<a
href="?{{ $queryStrings ? $queryStrings.'&' : '' }}coin={{ $coin }}"
x-data="{ tooltip: '{{ addslashes(str_replace("%coinName%", ucfirst($coin), $localisation["pay_in"])) }}' }"
x-tooltip="tooltip"
class="inline-block p-1 border hover:border-gray-400 {{ request()->query('coin') == $coin ? 'border rounded border-gray-800' : '' }}"
>
<img class="h-14" src="data:image/png;base64,{{ $imageData }}" alt="{{ addslashes(str_replace("%coinName%", ucfirst($coin), $localisation["pay_in"])) }}">
</a>
@endforeach
@endif
</div>
@endif

<h2 class="mt-6 text-3xl font-medium text-center text-gray-900">
{{ $boxJsonValues['texts']['title'] }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" crossorigin="anonymous"></script>
<script defer src="https://use.fontawesome.com/releases/v5.12.0/js/all.js" crossorigin="anonymous"></script>
@isset($jsPath)
@isset($supportJsPath)
<script>
{!! file_get_contents($jsPath) !!}
{!! file_get_contents($supportJsPath) !!}
</script>
@endisset

Expand All @@ -41,33 +41,22 @@
<body>

@php
// Text above payment box
// $custom_text = "<p class='lead'>";
// $custom_text .= __('Please contact support for resolution.');
// $custom_text .= "</p>";
$custom_text = "";
$coins = $laravelCryptoPaymentGateway->enabledCoins;
$def_coin = $laravelCryptoPaymentGateway->defaultCoin;
$def_language = $laravelCryptoPaymentGateway->defaultLanguage;
$custom_text = $custom_text;
$coinImageSize = 70;
$qrcodeSize = 200;
$custom_text = $box_template_options['custom_text'] ?? "";
$coinImageSize = $box_template_options['coin_image_size'] ?? 70;
$qrcodeSize = $box_template_options['qrcode_size'] ?? 200;
$show_languages = $laravelCryptoPaymentGateway->showLanguageBox;
$logoimg_path = $laravelCryptoPaymentGateway->showLogo ? asset($laravelCryptoPaymentGateway->logo) : '';
$resultimg_path = "default";
$resultimgSize = 250;
$resultimg_path = $box_template_options['result_img_path'] ?? "default";
$resultimgSize = $box_template_options['result_img_size'] ?? 250;
$redirect = $laravelCryptoPaymentGateway->redirect;
$method = "curl";
$debug = false;
$method = $box_template_options['method'] ?? "curl";
$debug = $box_template_options['debug'] ?? false;
// Display payment box
echo $box->display_cryptobox_bootstrap($coins, $def_coin, $def_language, $custom_text, $coinImageSize, $qrcodeSize, $show_languages, $logoimg_path, $resultimg_path, $resultimgSize, $redirect, $method, $debug);
// You can setup method='curl' in function above and use code below on this webpage -
// if successful bitcoin payment received .... allow user to access your premium data/files/products, etc.
// if ($box->is_paid()) { ... your code here ... }
@endphp

</body>
Expand Down
55 changes: 55 additions & 0 deletions resources/views/paymentbox-gourl-cryptobox-iframe.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<title>{{ $boxJsonValues['texts']['title'] }}</title>

<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
@isset($cryptoboxJsPath)
<script>
{!! file_get_contents($cryptoboxJsPath) !!}
</script>
@endisset

</head>

<body class="pt-4">

@if($laravelCryptoPaymentGateway->showLanguageBox)
<div class='mb-4 text-center'>
{!! display_language_box($laravelCryptoPaymentGateway->defaultLanguage) !!}
</div>
@endif

@if(!$boxIsPaid)
<div class='mb-2 text-center'>
@php
$coins = $laravelCryptoPaymentGateway->enabledCoins;
$def_coin = $laravelCryptoPaymentGateway->defaultCoin;
$def_language = $laravelCryptoPaymentGateway->defaultLanguage;
$iconWidth = 50;
$style = ""; //margin: 80px 0 0
$directory = CRYPTOBOX_IMG_FILES_PATH;
echo display_currency_box($coins, $def_coin, $def_language, $iconWidth, $style, $directory);
@endphp
</div>
@endif

@php
$submit_btn = $box_template_options['submit_btn'] ?? true;
$width = $box_template_options['width'] ?? '540';
$height = $box_template_options['height'] ?? '230';
$box_style = $box_template_options['box_style'] ?? '';
$message_style = $box_template_options['message_style'] ?? '';
$anchor = $box_template_options['anchor'] ?? '';
// Display payment box
echo $box->display_cryptobox($submit_btn, $width, $height, $box_style, $message_style, $anchor);
@endphp

</body>
</html>
34 changes: 18 additions & 16 deletions resources/views/paymentbox-standard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,24 @@
<img class="w-auto h-12 mx-auto" src="{{ asset($laravelCryptoPaymentGateway->logo) }}" alt="{{ asset($laravelCryptoPaymentGateway->logo) }}">
@endif

<div class="mt-4 text-center">
{{-- Custim currency box --}}
<span class="block mt-1 mb-2 font-bold">{!! $localisation["payment"] !!}</span>
@if(is_array($laravelCryptoPaymentGateway->enabledCoinImages) && count($laravelCryptoPaymentGateway->enabledCoinImages) > 1)
@foreach($laravelCryptoPaymentGateway->enabledCoinImages as $coin => $imageData)
<a
href="?{{ $queryStrings ? $queryStrings.'&' : '' }}coin={{ $coin }}"
x-data="{ tooltip: '{{ addslashes(str_replace("%coinName%", ucfirst($coin), $localisation["pay_in"])) }}' }"
x-tooltip="tooltip"
class="inline-block p-1 border hover:border-gray-400 {{ request()->query('coin') == $coin ? 'border rounded border-gray-800' : '' }}"
>
<img class="h-14" src="data:image/png;base64,{{ $imageData }}" alt="{{ addslashes(str_replace("%coinName%", ucfirst($coin), $localisation["pay_in"])) }}">
</a>
@endforeach
@endif
</div>
@if(!$boxIsPaid)
<div class="mt-4 text-center">
{{-- Custim currency box --}}
<span class="block mt-1 mb-2 font-bold">{!! $localisation["payment"] !!}</span>
@if(is_array($laravelCryptoPaymentGateway->enabledCoinImages) && count($laravelCryptoPaymentGateway->enabledCoinImages) > 1)
@foreach($laravelCryptoPaymentGateway->enabledCoinImages as $coin => $imageData)
<a
href="?{{ $queryStrings ? $queryStrings.'&' : '' }}coin={{ $coin }}"
x-data="{ tooltip: '{{ addslashes(str_replace("%coinName%", ucfirst($coin), $localisation["pay_in"])) }}' }"
x-tooltip="tooltip"
class="inline-block p-1 border hover:border-gray-400 {{ request()->query('coin') == $coin ? 'border rounded border-gray-800' : '' }}"
>
<img class="h-14" src="data:image/png;base64,{{ $imageData }}" alt="{{ addslashes(str_replace("%coinName%", ucfirst($coin), $localisation["pay_in"])) }}">
</a>
@endforeach
@endif
</div>
@endif

<h2 class="mt-6 text-3xl font-medium text-center text-gray-900">
{{ $boxJsonValues['texts']['title'] }}
Expand Down
30 changes: 22 additions & 8 deletions src/Http/Controllers/CryptoPaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public function paymentbox(Request $request)

// instantiate the barcode class
$barcode = new \Com\Tecnick\Barcode\Barcode();
$bar_width = $laravelCryptoPaymentGateway->boxStyle == 'compact' || $laravelCryptoPaymentGateway->boxStyle == '' ? -2 : -4;
$bar_height = $laravelCryptoPaymentGateway->boxStyle == 'compact' || $laravelCryptoPaymentGateway->boxStyle == '' ? -2 : -4;
$bar_width = $laravelCryptoPaymentGateway->boxTemplate == 'compact' || $laravelCryptoPaymentGateway->boxTemplate == '' ? -2 : -4;
$bar_height = $laravelCryptoPaymentGateway->boxTemplate == 'compact' || $laravelCryptoPaymentGateway->boxTemplate == '' ? -2 : -4;
$barcodeObj = $barcode->getBarcodeObj(
'QRCODE,H', // barcode type and additional comma-separated parameters
$boxJsonValues['wallet_url'], // data string to encode
Expand All @@ -108,17 +108,31 @@ public function paymentbox(Request $request)
$walletQRCode = $barcodeObj->getHtmlDiv(); // SOURCE OUTPUT:: getHtmlDiv(), getSvgCode() | IMAGE OUTPUT:: getPng(), getSvg(), getPngData


// Switch to the view based on the box style
if($laravelCryptoPaymentGateway->boxStyle == 'gourl-bootstrap') {
$view = 'paymentbox-gourl-bootstrap';
} elseif($laravelCryptoPaymentGateway->boxStyle == 'standard') {
// Switch to the view based on the box template
if($laravelCryptoPaymentGateway->boxTemplate == 'gourl-cryptobox-iframe') {
$view = 'paymentbox-gourl-cryptobox-iframe';
$box_template_options = $laravelCryptoPaymentGateway->boxTemplateOptions['gourl_cryptobox_iframe'];

} elseif($laravelCryptoPaymentGateway->boxTemplate == 'gourl-cryptobox-bootstrap') {
$view = 'paymentbox-gourl-cryptobox-bootstrap';
$box_template_options = $laravelCryptoPaymentGateway->boxTemplateOptions['gourl_cryptobox_bootstrap'];

} elseif($laravelCryptoPaymentGateway->boxTemplate == 'standard') {
$view = 'paymentbox-standard';
$box_template_options = $laravelCryptoPaymentGateway->boxTemplateOptions['standard'];

} else {
$view = 'paymentbox-compact';
$box_template_options = $laravelCryptoPaymentGateway->boxTemplateOptions['compact'];
}

return view("laravel-crypto-payment-gateway::{$view}")
->with( compact('laravelCryptoPaymentGateway', 'box', 'boxJsonValues', 'boxIsPaid', 'walletQRCode', 'queryStrings', 'localisation') );
->with(
compact(
'laravelCryptoPaymentGateway', 'box', 'boxJsonValues', 'boxIsPaid',
'walletQRCode', 'queryStrings', 'localisation', 'box_template_options'
)
);
}

/**
Expand Down
Loading

0 comments on commit 48a9ac6

Please sign in to comment.