diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4e3f01e --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +# Blacklist files/folders in same directory as the .gitignore file +/* +vendor + +# Whitelist some files +!.gitignore +!README.md + +!modules/ +modules/* +!modules/gateways/ +modules/gateways/* +!modules/gateways/xendit/ +!modules/gateways/xendit.php + +modules/gateways/callback +!modules/gateways/callback/xendit.php diff --git a/README.md b/README.md index f2d846d..f29a931 100644 --- a/README.md +++ b/README.md @@ -1 +1,41 @@ -# xendit-whmcs +# Xendit Payment Gateway Module for WHMCS # + +## Summary ## + +Xendit Payment Gateway allow you to enable the multi payment channels on WHMCS + +## System requirements +This module has been tested against the following tech stacks: + +| Requirement | Minimum | Recommended | +|------------------------|-------------------------------------------------------------|-------------------------------------------------------------------| +| PHP Version | 7.2 | Latest 7.3 or 7.4 Release | +| PHP Memory Limit | 64MB | 128MB** | +| PHP Database Extension | PDO | PDO | +| PHP Extensions | Curl with SSL*** , GD2 Image Library, JSON Support, XML | Iconv, MBString, GMP, OpenSSL***, BC Math, Intl, Fileinfo | +| MySQL Version | 5.2.0 | Latest 5.7 | +| Ioncube Loaders | 10.4.5 or later | The latest 11.x Ioncube for your PHP version | + +For the latest WHMCS minimum system requirements, please refer to +https://docs.whmcs.com/System_Requirements + +## Installation ## +- Clone this to your directory +- Copy `modules/gateways/xendit` to your `/modules/gateways` +- Copy `modules/gateways/callback/xendit.php` to your `/modules/gateways/callback` + +## Configuration ## +1. Access your WHMCS admin page. +2. Go to menu Setup -> Payments -> Payment Gateways. +3. There are will be `**Xendit Payment Gateway Module**` +4. Then choose Setup -> Payments -> Payment Gateways -> Manage Existing Gateways +5. Put the `secretKey` and `publicKey` (Open Xendit Dashboard > Settings > API Keys > Generate Secret Key > Copy SecretKey & PublicKey) +6. Click Save Changes + +## Ownership + +Team: [TPI Team](https://www.draw.io/?state=%7B%22ids%22:%5B%221Vk1zqYgX2YqjJYieQ6qDPh0PhB2yAd0j%22%5D,%22action%22:%22open%22,%22userId%22:%22104938211257040552218%22%7D) + +Slack Channel: [#integration-product](https://xendit.slack.com/messages/integration-product) + +Slack Mentions: `@troops-tpi` diff --git a/modules/gateways/xendit.php b/modules/gateways/xendit.php new file mode 100644 index 0000000..2e7af8d --- /dev/null +++ b/modules/gateways/xendit.php @@ -0,0 +1,116 @@ + 'Xendit Payment Gateway', + 'APIVersion' => '1.1' + ); +} + +function xendit_storeremote($params){} + +/** + * @return array + */ +function xendit_config() +{ + (new \Xendit\Lib\ActionBase())->createTable(); + return (new \Xendit\Lib\ActionBase())->createConfig(); +} + +/** + * @param $params + * @return string + * @throws Exception + */ +function xendit_link($params) +{ + return (new \Xendit\Lib\Link())->generatePaymentLink($params); +} + +/** + * No local credit card input. + * + * This is a required function declaration. Denotes that the module should + * not allow local card data input. + */ +function xendit_nolocalcc() {} + +/** + * Remote input. + * + * Called when a pay method is requested to be created or a payment is + * being attempted. + * + * New pay methods can be created or added without a payment being due. + * In these scenarios, the amount parameter will be empty and the workflow + * should be to create a token without performing a charge. + * + * @param array $params Payment Gateway Module Parameters + * + * @see https://developers.whmcs.com/payment-gateways/remote-input-gateway/ + * + * @return array + */ +function xendit_remoteinput($params) +{ + +} + +/** + * Remote update. + * + * Called when a pay method is requested to be updated. + * + * The expected return of this function is direct HTML output. It provides + * more flexibility than the remote input function by not restricting the + * return to a form that is posted into an iframe. We still recommend using + * an iframe where possible and this sample demonstrates use of an iframe, + * but the update can sometimes be handled by way of a modal, popup or + * other such facility. + * + * @param array $params Payment Gateway Module Parameters + * + * @see https://developers.whmcs.com/payment-gateways/remote-input-gateway/ + * + * @return array + */ +function xendit_remoteupdate($params) +{ + if(strpos($_REQUEST["rp"], "/admin/") !== FALSE){ + return << + Updating your card/bank is not possible. Please create a new Pay Method to make changes. + +HTML; + } +} + +/** + * Admin status message. + * + * Called when an invoice is viewed in the admin area. + * + * @param array $params Payment Gateway Module Parameters. + * + * @return array + */ +function xendit_adminstatusmsg($params) +{ +} diff --git a/modules/gateways/xendit/composer.json b/modules/gateways/xendit/composer.json new file mode 100644 index 0000000..c4aba68 --- /dev/null +++ b/modules/gateways/xendit/composer.json @@ -0,0 +1,15 @@ +{ + "name": "xendit/xendit-whmcs", + "description": "Xendit Payment Gateway for WHMCS", + "license": "MIT", + "authors": [ + { + "name": "TPI", + "email": "thirdpartyintegrations@xendit.co" + } + ], + "homepage": "https://xendit.co", + "require-dev": { + "phpunit/phpunit": "@stable" + } +} diff --git a/modules/gateways/xendit/logo.png b/modules/gateways/xendit/logo.png new file mode 100644 index 0000000..0023367 Binary files /dev/null and b/modules/gateways/xendit/logo.png differ diff --git a/modules/gateways/xendit/phpunit.xml.dist b/modules/gateways/xendit/phpunit.xml.dist new file mode 100644 index 0000000..5575376 --- /dev/null +++ b/modules/gateways/xendit/phpunit.xml.dist @@ -0,0 +1,9 @@ + + + + + + tests/* + + + diff --git a/modules/gateways/xendit/whmcs.json b/modules/gateways/xendit/whmcs.json new file mode 100644 index 0000000..f37f6c3 --- /dev/null +++ b/modules/gateways/xendit/whmcs.json @@ -0,0 +1,20 @@ +{ + "schema": "1.0", + "type": "whmcs-gateways", + "name": "xendit", + "license": "MIT", + "category": "payments", + "description": { + "name": "Xendit", + "tagline": "Xendit Payment Gateway for WHMCS" + }, + "logo": { + "filename": "logo.png" + }, + "authors": [ + { + "name": "TPI", + "homepage": "https:\/\/xendit.co\/" + } + ] +}