Skip to content

Commit

Permalink
Init Xendit payment gateway module
Browse files Browse the repository at this point in the history
  • Loading branch information
andykimlong committed Mar 25, 2022
0 parents commit 46e5354
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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 `<root directory>/modules/gateways`
- Copy `modules/gateways/callback/xendit.php` to your `<root directory>/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`
116 changes: 116 additions & 0 deletions modules/gateways/xendit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?php

//autoload gateway functions
require_once __DIR__ . '/../../includes/gatewayfunctions.php';

require __DIR__ .'/xendit/autoload.php';
require __DIR__ .'/xendit/hooks.php';

use WHMCS\Billing\Invoice;

if (!defined("WHMCS")) {
die("This file cannot be accessed directly");
}

/**
* @return array
*/
function xendit_MetaData()
{
return array(
'DisplayName' => '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 <<<HTML
<div class="alert alert-info text-center">
Updating your card/bank is not possible. Please create a new Pay Method to make changes.
</div>
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)
{
}
15 changes: 15 additions & 0 deletions modules/gateways/xendit/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "xendit/xendit-whmcs",
"description": "Xendit Payment Gateway for WHMCS",
"license": "MIT",
"authors": [
{
"name": "TPI",
"email": "[email protected]"
}
],
"homepage": "https://xendit.co",
"require-dev": {
"phpunit/phpunit": "@stable"
}
}
Binary file added modules/gateways/xendit/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions modules/gateways/xendit/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="tests/_bootstrap.php">
<coverage/>
<testsuites>
<testsuite name="WHMCS Xendit Payment Gateway Tests">
<directory suffix=".php">tests/*</directory>
</testsuite>
</testsuites>
</phpunit>
20 changes: 20 additions & 0 deletions modules/gateways/xendit/whmcs.json
Original file line number Diff line number Diff line change
@@ -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\/"
}
]
}

0 comments on commit 46e5354

Please sign in to comment.