Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Process the payment and return the result
- **/
- public function process_payment($order_id)
- {
- $order = wc_get_order($order_id);
- return array(
- 'result' => 'success',
- 'redirect' => $order->get_checkout_payment_url(true)
- );
- }
- /**
- * Output for the order received page.
- **/
- public function receipt_page($order_id)
- {
- if (!is_checkout_pay_page()) {
- return;
- }
- if (is_checkout_pay_page() && get_query_var('order-pay')) {
- $order_key = urldecode($_GET['key']);
- $order_id = absint(get_query_var('order-pay'));
- $order = wc_get_order($order_id);
- if ($order->id == $order_id && $order->order_key == $order_key) {
- $merchant_name = $this->merchant_name;
- $password = $this->password;
- $orderid = $order_id;
- $tamount = $order->order_total;
- $request_url = $this->request_url;
- $rurl = $this->return_url;
- $cert = dirname(__FILE__) ."/Demo Merchant 2020.pem";
- $opts = array(
- 'ssl' => array(
- 'verify_peer' => true,
- 'verify_peer_name' => true,
- "cafile" => dirname(__FILE__) ."/ca.crt",
- //'ciphers'=>'RC4-SHA'
- )
- );
- $options = array(
- 'trace' => 1,
- 'keep_alive' => true,
- 'exceptions' => 0,
- //'soap_version' => SOAP_1_1,
- 'local_cert' => $cert,
- 'passphrase' => $password,
- 'stream_context' => stream_context_create($opts),
- 'cache_wsdl' => WSDL_CACHE_NONE
- );
- $client = new SoapClient($request_url, $options);
- $params = array(
- 'Register' => '',
- 'request' => array(
- 'Customer' => $merchant_name,
- 'Language' => 'en',
- 'version' => 2,
- 'Amount' => $tamount,
- 'Currency' => 'PKR',
- 'OrderID' => $orderid,
- 'OrderInfo' => $tamount,
- 'OrderName' => $orderid,
- 'ReturnPath' => $rurl,
- 'TransactionHint' => 'VCC:Y'
- )
- );
- $result = $client->Register($params);
- echo '<pre>';
- print_r($result);
- echo '</pre>';
- $html = '';
- $html .= '<p>' . __('Thank you for your order, please click the button below to pay with Dialog, Etisalat and Hutch mobile phones using eZ Cash.', 'woothemes') . '</p>';
- $html .= '<div id="mj-wc-ezcash-form">';
- $html .= '<form id="order_review" method="post" action="https://demo-ipg.comtrust.ae/Payment/PaymentPortal.aspx?lang=en&layout=C0STCBVLEI">';
- $html .= '<input type="hidden" value="' . $result->RegisterResult->TransactionID . '" name="TransactionID">';
- $html .= '<button class="button alt" id="mj-wc-ezcash-payment-button">' . __('Pay Now', 'woothemes') . '</button>';
- $html .= ' <a class="button cancel" href="' . esc_url($order->get_cancel_order_url()) . '">' . __('Cancel order & restore cart', 'woothemes') . '</a>';
- $html .= '</form>';
- $html .= '</div>';
- echo $html;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement