Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for ionCube Encoder)
- *
- * @ Version : 4.1.0.1
- * @ Author : DeZender
- * @ Release on : 29.08.2020
- * @ Official site : http://DeZender.Net
- *
- */
- function gocardless_MetaData()
- {
- return ['apiOnboarding' => true, 'apiOnboardingRedirectUrl' => 'https://api1.whmcs.com/gocardless/auth/initiate', 'apiOnboardingCallbackPath' => 'modules/gateways/callback/gocardless.php', 'failedEmail' => 'Direct Debit Payment Failed', 'successEmail' => 'Direct Debit Payment Confirmation', 'pendingEmail' => 'Direct Debit Payment Pending', 'noCurrencyConversion' => true, 'supportedCurrencies' => WHMCS\Module\Gateway\GoCardless\GoCardless::SUPPORTED_CURRENCIES];
- }
- function gocardless_config(array $params)
- {
- $return = [
- 'FriendlyName' => ['Type' => 'System', 'Value' => 'GoCardless'],
- 'verificationStatus' => NULL,
- 'accessToken' => ['FriendlyName' => 'OAuth Access Token', 'Type' => 'password', 'Description' => 'To modify these values, click the Configure button below.', 'ReadOnly' => true],
- 'callbackToken' => ['FriendlyName' => 'Callback Token', 'Type' => 'password', 'ReadOnly' => true],
- 'reconnectAccount' => ['FriendlyName' => '', 'Type' => 'button', 'Description' => sprintf('<a href="%s" class="btn btn-sm btn-default">%s</a>', 'configgateways.php?action=onboarding&gateway=gocardless', 'Configure GoCardless Account Connection')]
- ];
- if (array_key_exists('accessToken', $params) && $params['accessToken']) {
- try {
- $client = WHMCS\Module\Gateway\GoCardless\Client::factory($params['accessToken']);
- $response = json_decode($client->get('creditors'));
- $creditor = (isset($response->creditors[0]) ? $response->creditors[0] : '');
- if ($creditor && ($creditor->verification_status == 'action_required')) {
- $description = '<strong>Verification Status: Action Required</strong><br>Please login to your GoCardless account to complete account verification. <a href="https://manage.gocardless.com/sign-in" target="_blank" class="alert-link">Login</a>';
- $return['verificationStatus'] = ['FriendlyName' => '', 'Type' => 'none', 'Description' => '<div class="alert alert-warning" style="margin:0;">' . $description . '</div>'];
- }
- else if ($creditor && ($creditor->verification_status == 'in_review')) {
- $description = '<strong>Verification Status: In Review</strong><br>Your account is awaiting review by GoCardless. This message will update once account verification has been performed.';
- $return['verificationStatus'] = ['FriendlyName' => '', 'Type' => 'none', 'Description' => '<div class="alert alert-info" style="margin:0;">' . $description . '</div>'];
- }
- else if ($creditor && ($creditor->verification_status == 'successful')) {
- $description = '<strong>Verification Status: Successful</strong><br>Verification has been completed by GoCardless and your account is active and ready for use.';
- $return['verificationStatus'] = ['FriendlyName' => '', 'Type' => 'none', 'Description' => '<div class="alert alert-success" style="margin:0;">' . $description . '</div>'];
- }
- }
- catch (Exception $e) {
- }
- }
- if (is_null($return['verificationStatus'])) {
- unset($return['verificationStatus']);
- }
- $currencies = WHMCS\Billing\Currency::all()->pluck('code');
- foreach ($currencies as $currencyCode) {
- if (in_array($currencyCode, WHMCS\Module\Gateway\GoCardless\GoCardless::SUPPORTED_CURRENCIES)) {
- $scheme = WHMCS\Module\Gateway\GoCardless\GoCardless::SCHEMES[$currencyCode];
- $schemeName = WHMCS\Module\Gateway\GoCardless\GoCardless::SCHEME_NAMES[$scheme];
- $return['name_' . $scheme] = ['FriendlyName' => 'Display Name for ' . $schemeName, 'Type' => 'text', 'Placeholder' => 'Leave blank to use default'];
- }
- }
- $usageNotes = [];
- foreach ($currencies as $currencyCode) {
- if (!in_array($currencyCode, WHMCS\Module\Gateway\GoCardless\GoCardless::SUPPORTED_CURRENCIES)) {
- $usageNotes[] = '<strong>Unsupported Currencies.</strong> You have one or more currencies configured that are not supported by GoCardless. Invoices using currencies GoCardless does not support will be unable to be paid using GoCardless. <a href="https://docs.whmcs.com/GoCardless#Supported_Currencies" target="_blank">Learn more</a>';
- break;
- }
- }
- $systemUrl = App::getSystemURL();
- if (substr($systemUrl, 0, 5) != 'https') {
- $usageNotes[] = '<strong>GoCardless requires an HTTPS secured connection for API requests.</strong> Your current WHMCS System URL setting does not begin with https and will be rejected.<br>Please add SSL to the domain WHMCS is installed on and update your WHMCS System URL setting. <a href="https://docs.whmcs.com/GoCardless#SSL_Requirement" target="_blank">Learn more</a>';
- }
- if ($usageNotes) {
- $return['UsageNotes'] = ['Type' => 'System', 'Value' => implode('<br>', $usageNotes)];
- ....................................................................
- .........................................
- .................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement