public function notification() { $params = array(); foreach ($_POST as $k => $v) { $params[$k] = $v; } $message = Twocheckout_Notification::check($params, "tango", 'array'); if ($message['code'] == 'Success') { switch ($params['message_type']) { case 'FRAUD_STATUS_CHANGED': if ($params['fraud_status'] == 'fail') { $id = $params['vendor_order_id']; $data = array('active' => 0); $this->ion_auth->update($id, $data); } break; case 'RECURRING_INSTALLMENT_FAILED': $id = $params['vendor_order_id']; $data = array('active' => 0); $this->ion_auth->update($id, $data); break; case 'RECURRING_INSTALLMENT_SUCCESS': $id = $params['vendor_order_id']; $user = $this->ion_auth->user($id)->row(); $status = $user->active; $data = array('active' => 1, 'last_billed' => time(), 'last_invoice' => $params['invoice_id']); $this->ion_auth->update($id, $data); break; } } }
function webhook_handler() { if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'psts_2co_webhook') { global $psts; if (Twocheckout_Notification::check($_REQUEST, $psts->get_setting('2co_secret_word'))) { $blog_id = $_POST['vendor_order_id']; switch ($_POST['message_type']) { case 'RECURRING_INSTALLMENT_SUCCESS': $this->tcheckout_modify_subscription($blog_id, 'renew'); break; case 'RECURRING_INSTALLMENT_FAILED': //faild buill, send email $this->tcheckout_modify_subscription($blog_id, 'renew_fail'); break; case 'RECURRING_STOPPED': $this->tcheckout_modify_subscription($blog_id, 'stopped'); break; } } } }
public function testNotificationCheck() { $params = array('vendor_id' => '1817037', 'sale_id' => '4774380224', 'invoice_id' => '4774380233', 'md5_hash' => '566C45D68B75357AD43F9010CFFE8CF5', 'secret' => 'tango'); $result = Twocheckout_Notification::check($params, 'tango'); $this->assertEquals("Success", $result['response_code']); }
function pmpro_twocheckoutValidate() { $params = array(); foreach ($_REQUEST as $k => $v) { $params[$k] = $v; } //2Checkout uses an order number of 1 in the hash for demo orders for some reason if ($params['demo'] == 'Y') { $params['order_number'] = 1; } //is this a return call or notification if (empty($params['message_type'])) { $check = Twocheckout_Return::check($params, pmpro_getOption('twocheckout_secretword'), 'array'); } else { $check = Twocheckout_Notification::check($params, pmpro_getOption('twocheckout_secretword'), 'array'); } return $check['response_code'] === 'Success'; }
function pmpro_twocheckoutValidate() { $params = array(); foreach ($_REQUEST as $k => $v) { $params[$k] = $v; } //2Checkout uses an order number of 1 in the hash for demo orders for some reason if (!empty($params['demo']) && $params['demo'] == 'Y') { $params['order_number'] = 1; } //is this a return call or notification if (empty($params['message_type'])) { $check = Twocheckout_Return::check($params, pmpro_getOption('twocheckout_secretword'), 'array'); } else { $check = Twocheckout_Notification::check($params, pmpro_getOption('twocheckout_secretword'), 'array'); } if (empty($check)) { $r = false; } else { if (empty($check['response_code'])) { $r = false; } else { $r = $check['response_code']; } } /** * Filter if an twocheckout request is valid or not. * * @since 1.8.6.3 * * @param bool $r true or false if the request is valid * @param mixed $check remote post object from request to Twocheckout */ $r = apply_filters('pmpro_twocheckout_validate', $r, $check); return $check['response_code'] === 'Success'; }