This repository has been archived by the owner on Aug 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpaysubs.php
executable file
·103 lines (85 loc) · 2.95 KB
/
paysubs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/**
* Plugin Name: Gravity Forms PaySubs Add-On
* Plugin URI: https://github.com/PayGate/PaySubs_Gravity_Forms
* Description: Integrates Gravity Forms with PaySubs, a South African payment gateway.
* Version: 1.0.1
* Tested: 5.9.0
* Author: PayGate (Pty) Ltd
* Author URI: https://www.paygate.co.za/
* Developer: App Inlet (Pty) Ltd
* Developer URI: https://www.appinlet.com/
* Text Domain: gravityformspaysubs
* Domain Path: /languages
*
* Copyright: © 2022 PayGate (Pty) Ltd.
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
add_action( 'plugins_loaded', 'paysubs_init' );
/**
* Initialize the gateway.
*
* @since 1.0.0
*/
function paysubs_init()
{
/**
* Auto updates from GIT
*
* @since 2.2.9
*
*/
require_once 'updater.class.php';
if ( is_admin() ) {
// note the use of is_admin() to double check that this is happening in the admin
$config = array(
'slug' => plugin_basename( __FILE__ ),
'proper_folder_name' => 'gravityformspaysubs',
'api_url' => 'https://api.github.com/repos/PayGate/PaySubs_Gravity_Forms',
'raw_url' => 'https://raw.github.com/PayGate/PaySubs_Gravity_Forms/master',
'github_url' => 'https://github.com/PayGate/PaySubs_Gravity_Forms',
'zip_url' => 'https://github.com/PayGate/PaySubs_Gravity_Forms/archive/master.zip',
'homepage' => 'https://github.com/PayGate/PaySubs_Gravity_Forms',
'sslverify' => true,
'requires' => '4.0',
'tested' => '5.3.0',
'readme' => 'README.md',
'access_token' => '',
);
new WP_GitHub_Updater_PS( $config );
}
}
add_action( 'gform_loaded', array( 'GF_PaySubs_Main', 'load' ), 5 );
class GF_PaySubs_Main
{
public static function load()
{
if ( !method_exists( 'GFForms', 'include_payment_addon_framework' ) ) {
return;
}
require_once 'paysubs-gf-class.php';
GFAddOn::register( 'GFPaySubs' );
}
}
/**
* Encrypt and decrypt
* @param string $string string to be encrypted/decrypted
* @param string $action what to do with this? e for encrypt, d for decrypt
*/
function PaySubs_encryption( $string, $action = 'e' )
{
// you may change these values to your own
$secret_key = AUTH_SALT;
$secret_iv = NONCE_SALT;
$output = false;
$encrypt_method = "AES-256-CBC";
$key = hash( 'sha256', $secret_key );
$iv = substr( hash( 'sha256', $secret_iv ), 0, 16 );
if ( $action == 'e' ) {
$output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
} else if ( $action == 'd' ) {
$output = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
}
return $output;
}