Advertisement
Guest User

Untitled

a guest
Jan 19th, 2021
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.96 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.1.0.1
  8. * @ Author : DeZender
  9. * @ Release on : 29.08.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. function gocardless_MetaData()
  15. {
  16. 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];
  17. }
  18.  
  19. function gocardless_config(array $params)
  20. {
  21. $return = [
  22. 'FriendlyName' => ['Type' => 'System', 'Value' => 'GoCardless'],
  23. 'verificationStatus' => NULL,
  24. 'accessToken' => ['FriendlyName' => 'OAuth Access Token', 'Type' => 'password', 'Description' => 'To modify these values, click the Configure button below.', 'ReadOnly' => true],
  25. 'callbackToken' => ['FriendlyName' => 'Callback Token', 'Type' => 'password', 'ReadOnly' => true],
  26. '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')]
  27. ];
  28. if (array_key_exists('accessToken', $params) && $params['accessToken']) {
  29. try {
  30. $client = WHMCS\Module\Gateway\GoCardless\Client::factory($params['accessToken']);
  31. $response = json_decode($client->get('creditors'));
  32. $creditor = (isset($response->creditors[0]) ? $response->creditors[0] : '');
  33. if ($creditor && ($creditor->verification_status == 'action_required')) {
  34. $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>';
  35. $return['verificationStatus'] = ['FriendlyName' => '', 'Type' => 'none', 'Description' => '<div class="alert alert-warning" style="margin:0;">' . $description . '</div>'];
  36. }
  37. else if ($creditor && ($creditor->verification_status == 'in_review')) {
  38. $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.';
  39. $return['verificationStatus'] = ['FriendlyName' => '', 'Type' => 'none', 'Description' => '<div class="alert alert-info" style="margin:0;">' . $description . '</div>'];
  40. }
  41. else if ($creditor && ($creditor->verification_status == 'successful')) {
  42. $description = '<strong>Verification Status: Successful</strong><br>Verification has been completed by GoCardless and your account is active and ready for use.';
  43. $return['verificationStatus'] = ['FriendlyName' => '', 'Type' => 'none', 'Description' => '<div class="alert alert-success" style="margin:0;">' . $description . '</div>'];
  44. }
  45. }
  46. catch (Exception $e) {
  47. }
  48. }
  49.  
  50. if (is_null($return['verificationStatus'])) {
  51. unset($return['verificationStatus']);
  52. }
  53.  
  54. $currencies = WHMCS\Billing\Currency::all()->pluck('code');
  55.  
  56. foreach ($currencies as $currencyCode) {
  57. if (in_array($currencyCode, WHMCS\Module\Gateway\GoCardless\GoCardless::SUPPORTED_CURRENCIES)) {
  58. $scheme = WHMCS\Module\Gateway\GoCardless\GoCardless::SCHEMES[$currencyCode];
  59. $schemeName = WHMCS\Module\Gateway\GoCardless\GoCardless::SCHEME_NAMES[$scheme];
  60. $return['name_' . $scheme] = ['FriendlyName' => 'Display Name for ' . $schemeName, 'Type' => 'text', 'Placeholder' => 'Leave blank to use default'];
  61. }
  62. }
  63.  
  64. $usageNotes = [];
  65.  
  66. foreach ($currencies as $currencyCode) {
  67. if (!in_array($currencyCode, WHMCS\Module\Gateway\GoCardless\GoCardless::SUPPORTED_CURRENCIES)) {
  68. $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>';
  69. break;
  70. }
  71. }
  72.  
  73. $systemUrl = App::getSystemURL();
  74.  
  75. if (substr($systemUrl, 0, 5) != 'https') {
  76. $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>';
  77. }
  78.  
  79. if ($usageNotes) {
  80. $return['UsageNotes'] = ['Type' => 'System', 'Value' => implode('<br>', $usageNotes)];
  81. ....................................................................
  82. .........................................
  83. .................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement