Add all files
This commit is contained in:
61
Disabled/FreeTrial/FreeTrial.php
Normal file
61
Disabled/FreeTrial/FreeTrial.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Paymenter\Extensions\Gateways\FreeTrial;
|
||||
|
||||
use App\Classes\Extension\Gateway;
|
||||
use App\Helpers\ExtensionHelper;
|
||||
use App\Models\Invoice;
|
||||
|
||||
class FreeTrial extends Gateway
|
||||
{
|
||||
|
||||
/**
|
||||
* Get all the configuration for the extension
|
||||
*
|
||||
* @param array $values
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig($values = [])
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name' => 'max_order_value',
|
||||
'label' => 'Max Order Value',
|
||||
'type' => 'number',
|
||||
'required' => true,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a view or a url to redirect to
|
||||
*
|
||||
* @param Invoice $invoice
|
||||
* @param float $total
|
||||
* @return string
|
||||
*/
|
||||
public function pay(Invoice $invoice, $total)
|
||||
{
|
||||
$items = $invoice->items;
|
||||
$maxOrderValue = $this->config('max_order_value');
|
||||
|
||||
// Make sure that the invoice is not for adding credits
|
||||
foreach ($items as $item) {
|
||||
if ($item->reference_type == 'App\\Models\\Credit') {
|
||||
return redirect()->route('invoices.show', ['invoice' => $invoice->id])
|
||||
->with('notification', ['message' => 'Cannot be used on Credits', 'type' => 'error']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($total > $maxOrderValue) {
|
||||
return redirect()->route('invoices.show', ['invoice' => $invoice->id])
|
||||
->with('notification', ['message' => 'Item not eligible', 'type' => 'error']);
|
||||
}
|
||||
|
||||
ExtensionHelper::addPayment($invoice->id, 'FreeTrial', $total);
|
||||
return redirect()->route('invoices.show', ['invoice' => $invoice->id])->with('notification', [
|
||||
'message' => 'Trial Activated',
|
||||
'type' => 'success'
|
||||
]);
|
||||
}
|
||||
}
|
||||
21
Disabled/FreeTrial/LICENSE
Normal file
21
Disabled/FreeTrial/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Vaibhav Dhiman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
60
Disabled/FreeTrial/README.md
Normal file
60
Disabled/FreeTrial/README.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# Free Trial Payment Gateway for Paymenter
|
||||
|
||||
A simple extension for [Paymenter](https://paymenter.org) that allows automatic invoice approval for orders under a configurable maximum value. Ideal for offering **free trials** or promotional services with zero friction.
|
||||
|
||||
## Supported Versions
|
||||
> The last version which supported Paymenter v0.9.5 is [v1.0.0](https://github.com/VaibhavSys/FreeTrial-Paymenter-Extension/releases/tag/v1.0.0)
|
||||
- **Supported Version:** Paymenter v1.0.4
|
||||
- **Extension Version:** v2.0.0
|
||||
|
||||
## Features
|
||||
- Automatically approves invoices if the total is under a configured maximum value.
|
||||
- Seamless free trial support — no real payment is processed.
|
||||
- Lightweight and easy to configure.
|
||||
|
||||
> ⚠️ **Note:** This gateway cannot be used to credit user accounts. It only applies to invoices which do not add credits to a user account.
|
||||
|
||||
## How It Works
|
||||
|
||||
Once enabled, if a user attempts to pay an invoice and the total amount is **less than or equal to** the configured **Max Order Value**, the payment is **automatically marked as paid**. If the amount exceeds the limit, the payment is **rejected**.
|
||||
|
||||
This gives you full flexibility to:
|
||||
- Create promotional plans priced under the trial limit.
|
||||
- Use one-time coupons and products to offer free trials.
|
||||
- Test services internally without actual transactions.
|
||||
|
||||
## Getting Started
|
||||
|
||||
1. **Install the extension**
|
||||
- Replace `/var/www/paymenter` with your actual Paymenter installation path.
|
||||
- **One-liner Install:**
|
||||
```sh
|
||||
git clone https://github.com/VaibhavSys/FreeTrial-Paymenter-Extension.git /var/www/paymenter/extensions/Gateways/FreeTrial
|
||||
```
|
||||
- **Manual Install:**
|
||||
[Download](https://github.com/VaibhavSys/FreeTrial-Paymenter-Extension/releases/latest/download/FreeTrial.zip) the extension and extract it to:
|
||||
```
|
||||
/var/www/paymenter/extensions/Gateways
|
||||
```
|
||||
1. **Enable the extension** from the Paymenter admin panel.
|
||||
1. **Configure the Max Order Value** in the admin panel (e.g., `0.5` to allow automatic approval for invoices ≤ $0.5).
|
||||
|
||||
That’s it — you’re ready to offer free trials!
|
||||
|
||||
## Configuration
|
||||
|
||||
- **Max Order Value (number):** The maximum invoice amount (in your invoice currency) that can be auto-approved. Any invoice above this value will be rejected.
|
||||
|
||||

|
||||
|
||||
> 💡 If you want to use this with a one-time promotional coupon/product, ensure the final payable invoice amount (after discount) is within the Max Order Value.
|
||||
|
||||
## Support
|
||||
|
||||
For questions, suggestions, or issues:
|
||||
- **Discord:** [@vaibhavd](https://discord.com/users/914452175839723550)
|
||||
- **GitHub Issues:** [FreeTrial-Paymenter Issues](https://github.com/VaibhavSys/FreeTrial-Paymenter-Extension/issues)
|
||||
|
||||
## Additional Information
|
||||
|
||||
- **License:** MIT — see [LICENSE](LICENSE) for details.
|
||||
BIN
Disabled/FreeTrial/Settings.png
Normal file
BIN
Disabled/FreeTrial/Settings.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 77 KiB |
BIN
Disabled/FreeTrial/cover.png
Normal file
BIN
Disabled/FreeTrial/cover.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
BIN
Disabled/FreeTrial/logo.png
Normal file
BIN
Disabled/FreeTrial/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Reference in New Issue
Block a user