Completed
Push — update-3.0 ( 77c3a6...abf3f0 )
by Daniel Neis
04:03
created
lib.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -166,7 +166,7 @@
 block discarded – undo
166 166
             $teacher = false;
167 167
         }
168 168
 
169
-        if ( (float) $instance->cost <= 0 ) {
169
+        if ((float) $instance->cost <= 0) {
170 170
             $cost = (float) $this->get_config('cost');
171 171
         } else {
172 172
             $cost = (float) $instance->cost;
Please login to merge, or discard this patch.
process.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 define('COMMERCE_PAGSEGURO_STATUS_REFUNDED', 6);
44 44
 define('COMMERCE_PAGSEGURO_STATUS_CANCELED', 7);
45 45
 define('COMMERCE_PAYMENT_STATUS_SUCCESS', 'success');
46
-define('COMMERCE_PAYMENT_STATUS_FAILURE', 'failure') ;
46
+define('COMMERCE_PAYMENT_STATUS_FAILURE', 'failure');
47 47
 define('COMMERCE_PAYMENT_STATUS_PENDING', 'pending');
48 48
 
49
-$userid       =  $USER->id;
50
-$plugin       =  enrol_get_plugin('pagseguro');
51
-$email        =  $plugin->get_config('pagsegurobusiness');
52
-$token        =  $plugin->get_config('pagsegurotoken');
49
+$userid       = $USER->id;
50
+$plugin       = enrol_get_plugin('pagseguro');
51
+$email        = $plugin->get_config('pagsegurobusiness');
52
+$token        = $plugin->get_config('pagsegurotoken');
53 53
 
54 54
 $error_returnurl   = $CFG->wwwroot.'/enrol/pagseguro/return.php';
55 55
 $success_returnurl = $CFG->wwwroot.'/enrol/pagseguro/return.php';
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 $currency     = $plugin->get_config('currency');
63 63
 $encoding     = 'UTF-8';
64 64
 $item_id      = $courseid;
65
-$item_desc    = empty($course->fullname) ? null: $course->fullname;
66
-$item_qty     = (int)1;
65
+$item_desc    = empty($course->fullname) ? null : $course->fullname;
66
+$item_qty     = (int) 1;
67 67
 $item_cost    = empty($plugin_instance->cost) ? 0.00 : number_format($plugin_instance->cost, 2);
68 68
 $item_amount  = $item_cost;
69 69
 
70
-$redirect_url =  $CFG->wwwroot.'/enrol/pagseguro/process.php';
71
-$submitValue  =  get_string("sendpaymentbutton", "enrol_pagseguro");
70
+$redirect_url = $CFG->wwwroot.'/enrol/pagseguro/process.php';
71
+$submitValue  = get_string("sendpaymentbutton", "enrol_pagseguro");
72 72
 
73 73
 $submited = optional_param('usersubmited', 1, PARAM_INT);
74 74
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 $notificationCode = optional_param('notificationCode', '', PARAM_RAW);
77 77
 
78 78
 if ($submited) {
79
-    $url = "https://ws.pagseguro.uol.com.br/v2/checkout/?email=" . urlencode($email) . "&token=" . $token;
79
+    $url = "https://ws.pagseguro.uol.com.br/v2/checkout/?email=".urlencode($email)."&token=".$token;
80 80
 
81 81
     $xml = "<?xml version=\"1.0\" encoding=\"$encoding\" standalone=\"yes\"?>
82 82
         <checkout>
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 if (!empty($notificationCode)) {
124 124
     $transaction = null;
125 125
     // Sets the web service URL.
126
-    $url = "https://pagseguro.uol.com.br/v2/transactions/notifications/" . $notificationCode . "?email=".$email."&token=".$token;
126
+    $url = "https://pagseguro.uol.com.br/v2/transactions/notifications/".$notificationCode."?email=".$email."&token=".$token;
127 127
 
128 128
     $curl = curl_init($url);
129 129
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
     $transaction = curl_exec($curl);
132 132
     curl_close($curl);
133 133
 
134
-    if ($transaction == 'Unauthorized'){
134
+    if ($transaction == 'Unauthorized') {
135 135
         //Insira seu código avisando que o sistema está com problemas, sugiro enviar um e-mail avisando para alguém fazer a manutenção
136
-        exit;//Mantenha essa linha
136
+        exit; //Mantenha essa linha
137 137
     } else {
138
-        $transaction_data  = serialize(trim($transaction));
138
+        $transaction_data = serialize(trim($transaction));
139 139
         process_moodle($transaction_data, $instanceid, $courseid);
140 140
     }
141 141
 }
142 142
 
143 143
 function process_moodle($transaction_data, $instanceid, $cid) {
144
-    global $CFG,$USER,$DB,$course;
144
+    global $CFG, $USER, $DB, $course;
145 145
 
146 146
     /// Read all the data from pagseguro and get it ready for later;
147 147
     /// we expect only valid UTF-8 encoding, it is the responsibility
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
     $transaction_xml = unserialize($transaction_data);
162 162
     $transaction = json_decode(json_encode(simplexml_load_string($transaction_xml)));
163 163
 
164
-    if($transaction) {
164
+    if ($transaction) {
165 165
         foreach ($transaction as $trans_key => $trans_value) {
166 166
             $trans_key = strtolower($trans_key);
167
-            if(!is_object($trans_value)) {
167
+            if (!is_object($trans_value)) {
168 168
                 $data->$trans_key = $trans_value;
169 169
             } else {
170
-                foreach($trans_value as $key => $value) {
170
+                foreach ($trans_value as $key => $value) {
171 171
                     $key = strtolower($key);
172
-                    if(is_object($value)) {
173
-                        foreach($value as $k => $v) {
172
+                    if (is_object($value)) {
173
+                        foreach ($value as $k => $v) {
174 174
                             $k = strtolower($k);
175 175
                             $k = $trans_key.'_'.$key.'_'.$k;
176 176
                             $data->$k = $v;
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
     $data->instanceid       = $instanceid;
195 195
     $data->timeupdated      = time();
196 196
 
197
-    if(!isset($data->reference) && empty($data->reference)) {
197
+    if (!isset($data->reference) && empty($data->reference)) {
198 198
         $data->reference    = $plugin->get_config('pagsegurobusiness');
199 199
     }
200 200
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
     $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
270 270
 
271 271
     // Check that amount paid is the correct amount
272
-    if ( (float) $plugin_instance->cost <= 0 ) {
272
+    if ((float) $plugin_instance->cost <= 0) {
273 273
         $cost = (float) $plugin->get_config('cost');
274 274
     } else {
275 275
         $cost = (float) $plugin_instance->cost;
Please login to merge, or discard this patch.
version.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,6 +26,6 @@
 block discarded – undo
26 26
 
27 27
 defined('MOODLE_INTERNAL') || die();
28 28
 
29
-$plugin->version   = 2011112901;        // The current plugin version (Date: YYYYMMDDXX)
30
-$plugin->requires  = 2011112901;        // Requires this Moodle version
31
-$plugin->component = 'enrol_pagseguro';    // Full name of the plugin (used for diagnostics)
29
+$plugin->version   = 2011112901; // The current plugin version (Date: YYYYMMDDXX)
30
+$plugin->requires  = 2011112901; // Requires this Moodle version
31
+$plugin->component = 'enrol_pagseguro'; // Full name of the plugin (used for diagnostics)
Please login to merge, or discard this patch.