|
| 1 | +# Anypay |
| 2 | + |
| 3 | +# Anypay |
| 4 | + |
| 5 | +## Introduction |
| 6 | +Anypay is a PHP library for conducting online payment transactions. This library provides the ability to connect to various payment gateways and offers a simple and uniform experience for developers through a unified API. |
| 7 | +## Features |
| 8 | +- Support for multiple payment gateways |
| 9 | +- Error and exception management |
| 10 | +- Dynamic payment settings configuration |
| 11 | +- Trackable events for each stage of the payment process |
| 12 | +## Active Gateways in This Package |
| 13 | + |
| 14 | + |
| 15 | +``` |
| 16 | +$gateways = [ |
| 17 | + 'asanpardakht', |
| 18 | + 'aqayepardakht', |
| 19 | + 'atipay', |
| 20 | + 'azkiVam', // Installment Anypay |
| 21 | + 'behpardakht', // mellat |
| 22 | + 'bitpay', |
| 23 | + 'digipay', |
| 24 | + 'etebarino', // Installment Anypay |
| 25 | + 'fanavacard', |
| 26 | + 'idpay', |
| 27 | + 'irankish', |
| 28 | + 'local', |
| 29 | + 'jibit', |
| 30 | + 'nextpay', |
| 31 | + 'omidpay', |
| 32 | + 'parsian', |
| 33 | + 'pasargad', |
| 34 | + 'payir', |
| 35 | + 'payfa', |
| 36 | + 'paypal', // will be added soon in next version |
| 37 | + 'payping', |
| 38 | + 'paystar', |
| 39 | + 'poolam', |
| 40 | + 'rayanpay', |
| 41 | + 'sadad', // melli |
| 42 | + 'saman', |
| 43 | + 'sep', // saman electronic Anypay, Keshavarzi & Saderat |
| 44 | + 'sepehr', // saderat |
| 45 | + 'sepordeh', |
| 46 | + 'sizpay', |
| 47 | + 'toman', |
| 48 | + 'vandar', |
| 49 | + 'walleta', // Installment Anypay |
| 50 | + 'yekpay', |
| 51 | + 'zarinpal', |
| 52 | + 'zibal' |
| 53 | +]; |
| 54 | +
|
| 55 | +این درگاهها به شما امکان میدهند تا با استفاده از تنظیمات مختلف، پرداختهای خود را از طریق درگاههای متنوع انجام دهید. |
| 56 | +
|
| 57 | +``` |
| 58 | +## How to Use |
| 59 | +To use Anypay, you first need to add it to your PHP project. Then, you can manage your payment transactions via the API methods. |
| 60 | + |
| 61 | +### Example |
| 62 | +Below is a sample code for creating a payment transaction: |
| 63 | + |
| 64 | +### php |
| 65 | + |
| 66 | +```php |
| 67 | +$config = ['driver' => 'gatewayName', 'api_key' => 'your_api_key']; |
| 68 | +$anypay = new Samgeeksdev\Anypay\Anypay($config); |
| 69 | +$invoice = new Samgeeksdev\Anypay\Invoice(); |
| 70 | +$invoice->amount(1000); // amount in Rials |
| 71 | +$anypay->via('gatewayName')->purchase($invoice)->pay(); |
| 72 | +``` |
| 73 | + |
| 74 | + |
| 75 | +### Using the payWith function |
| 76 | + |
| 77 | +```php |
| 78 | +$config = ['api_key' => 'your_api_key']; |
| 79 | +$gateway = 'gatewayName'; |
| 80 | +$amount = 1000; // amount in Rials |
| 81 | +try { |
| 82 | +$anypay = new Samgeeksdev\Anypay\Anypay($config); |
| 83 | +$response = $anypay->payWith($gateway, $amount, $config); |
| 84 | +echo $response->getContent(); // Display response details |
| 85 | +} catch (Exception $e) { |
| 86 | +echo 'Error in payment: ' . $e->getMessage(); |
| 87 | + |
| 88 | + |
| 89 | +``` |
| 90 | + |
| 91 | +### verify |
| 92 | + |
| 93 | +```php |
| 94 | + |
| 95 | + |
| 96 | +php |
| 97 | +try { |
| 98 | +$anypay = new Samgeeksdev\Anypay\Anypay($config); |
| 99 | +$receipt = $anypay->verify(); |
| 100 | +echo 'Payment confirmed. Transaction number: ' . $receipt->getTransactionId(); |
| 101 | +} catch (Exception $e) { |
| 102 | +echo 'Error in payment confirmation: ' . $e->getMessage(); |
| 103 | +} |
| 104 | + |
| 105 | +``` |
| 106 | +### If you want to call information via the config file |
| 107 | + |
| 108 | +```php |
| 109 | + |
| 110 | +$invoice = (new Invoice)->amount(1000); |
| 111 | + |
| 112 | + Anypay::via('driverName')->purchase( |
| 113 | + $invoice, |
| 114 | + function($driver, $transactionId) { |
| 115 | + } |
| 116 | +); |
| 117 | + |
| 118 | +``` |
| 119 | + |
| 120 | +## Support |
| 121 | +For further support and troubleshooting, you can visit the Issues section on GitHub or contact the support team. |
| 122 | + |
| 123 | +## License |
| 124 | +This project is published under the MIT license. You can view the full version of the license in the LICENSE file available in the code repository. |
0 commit comments