Created
May 19, 2014 05:24
-
-
Save Lh4cKg/e97b4fe989a7e491dfb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ControllerPaymentpayge extends Controller { | |
protected function index() { | |
$this->load->model('checkout/order'); | |
$this->language->load('payment/payge'); | |
$this->data['button_confirm'] = $this->language->get('button_confirm'); | |
$this->data['action'] = 'https://www.pay.ge/pay'; | |
$testmode =1; | |
$this->data['ok_item_1_price'] = $this->session->data['order_id']; | |
$this->data['transaction_id'] = $this->session->data['order_id']; | |
$this->data['return_url'] = $this->url->link('checkout/success&'); | |
$this->data['error_url'] = $this->url->link('checkout/error&'); | |
$this->data['cancel_url'] = $this->url->link('checkout/checkout&', '', 'SSL'); | |
$this->data['return'] = $this->url->link('checkout/success&'); | |
$this->data['status_url'] = $this->url->link('payment/payge/callback&'); | |
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); | |
$this->data['order_id'] = $this->session->data['order_id']; | |
$this->data['description'] = "შეკვეთის ID:".$this->session->data['order_id']; | |
$this->data['pay_from_email'] = $order_info['email']; | |
$this->data['firstname'] = $order_info['payment_firstname']; | |
$this->data['lastname'] = $order_info['payment_lastname']; | |
$this->data['address'] = $order_info['payment_address_1']; | |
$this->data['address2'] = $order_info['payment_address_2']; | |
$this->data['phone_number'] = $order_info['telephone']; | |
$this->data['postal_code'] = $order_info['payment_postcode']; | |
$this->data['city'] = $order_info['payment_city']; | |
$this->data['state'] = $order_info['payment_zone']; | |
$this->data['country'] = $order_info['payment_iso_code_3']; | |
$this->data['ok_item_1_price'] = round($order_info['total'])*100; | |
$this->data['currency'] = $order_info['currency_code']; | |
$this->data['customdata'] =$order_info['total']; | |
$MERCHANT_KEY = 'გენერირებული პაროლი'; | |
$MERCHANT_NAME = 'კოდი'; | |
$time = time(); | |
$str1 = $time . $this->data['order_id']; | |
$AMOUNT = round($order_info['total'])*100; | |
$CURRENCY = 'GEL'; | |
$DESCRIPTION = 'გადახდა'; | |
$FULL_NAME = $order_info['payment_firstname'] . " " . $order_info['payment_lastname']; | |
$CUSTOMA_DATA = 'some data'; | |
$LANG = "KA"; | |
$TEST_MODE_ON = 1; | |
$IS_PREAUTH = 0; | |
$CUSTOMER_ID = 1; | |
$this->data['order'] = $str1; | |
$this->data['merchant'] = $MERCHANT_NAME; | |
$this->data['amount'] = $AMOUNT; | |
$this->data['currency'] = $CURRENCY; | |
$this->data['description'] = $DESCRIPTION; | |
$this->data['clientname'] = $FULL_NAME; | |
$this->data['customdata'] = $CUSTOMA_DATA; | |
$this->data['ispreauth'] = $IS_PREAUTH; | |
$this->data['lng'] = $LANG; | |
$this->data['customer_id'] = $CUSTOMER_ID; | |
$str = $MERCHANT_KEY. $MERCHANT_NAME . $str1 . $AMOUNT . $CURRENCY . $DESCRIPTION | |
. $FULL_NAME . $CUSTOMER_ID . $LANG . $TEST_MODE_ON . $IS_PREAUTH; | |
$check = strtoupper(hash('sha256', $str)); | |
$this->data['check'] = $check; | |
$this->data['str'] = $str; | |
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/payge.tpl')) { | |
$this->template = $this->config->get('config_template') . '/template/payment/payge.tpl'; | |
} else { | |
$this->template = 'oxy/template/payment/payge.tpl'; | |
} | |
$this->render(); | |
} | |
public function callback() { | |
$errorCodes = array( 0 => 'Ok', | |
1 => 'Duplicate transaction', | |
-1 => 'Technical problem', | |
-2 => 'Order has been cancelled', | |
-3 => 'Error in parameter(s)' ); | |
$status = $_GET["status"]; | |
$transactioncode = $_GET['transactioncode']; | |
$amount = $_GET['amount']; | |
$currency = $_GET['currency']; | |
$ordercode = $_GET['ordercode']; | |
$paymethod = $_GET['paymethod']; | |
$customdata = $_GET['customdata']; | |
$testmode = $_GET['testmode']; | |
$check = $_GET['check']; | |
$str = $status.$transactioncode.$amount.$currency.$ordercode.$paymethod.$customdata.$testmode; | |
$str .= "გენერირებული პაროლი"; | |
$calculatedCheck = strtoupper(hash('sha256', $str)); | |
if ($calculatedCheck != $check) { | |
$this->load->model('checkout/order'); | |
$this->model_checkout_order->confirm($ordercode, $this->config->get('config_order_status_id')); | |
returnResult(-3, $errorCodes[-3], NULL, $transactioncode); | |
} else { | |
$this->load->model('checkout/order'); | |
$this->model_checkout_order->confirm($ordercode, $this->config->get('config_order_status_id')); | |
$verified = true; | |
returnResult(0, $errorCodes[0], NULL, $transactioncode); | |
} | |
} | |
} | |
function returnResult($resultcode, $resultdesc, $data, $transactioncode) { | |
$check = strtoupper(hash('sha256', $resultcode.$resultdesc.$transactioncode."გენერირებული პაროლი")); | |
$xmlstr = | |
<<<XML | |
<result> | |
<resultcode>$resultcode</resultcode> | |
<resultdesc>$resultdesc</resultdesc> | |
<check>$check</check> | |
<data>$data</data> | |
</result> | |
XML; | |
header('Content-type: text/xml'); | |
die($xmlstr); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment