Advertisement
Guest User

Woocommerce code

a guest
Dec 20th, 2017
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. /**
  2. * Process the payment and return the result
  3. **/
  4. public function process_payment($order_id)
  5. {
  6. $order = wc_get_order($order_id);
  7. return array(
  8. 'result' => 'success',
  9. 'redirect' => $order->get_checkout_payment_url(true)
  10. );
  11. }
  12.  
  13.  
  14. /**
  15. * Output for the order received page.
  16. **/
  17. public function receipt_page($order_id)
  18. {
  19. if (!is_checkout_pay_page()) {
  20. return;
  21. }
  22.  
  23. if (is_checkout_pay_page() && get_query_var('order-pay')) {
  24.  
  25. $order_key = urldecode($_GET['key']);
  26. $order_id = absint(get_query_var('order-pay'));
  27. $order = wc_get_order($order_id);
  28.  
  29. if ($order->id == $order_id && $order->order_key == $order_key) {
  30. $merchant_name = $this->merchant_name;
  31. $password = $this->password;
  32. $orderid = $order_id;
  33. $tamount = $order->order_total;
  34. $request_url = $this->request_url;
  35. $rurl = $this->return_url;
  36.  
  37. $cert = dirname(__FILE__) ."/Demo Merchant 2020.pem";
  38. $opts = array(
  39.  
  40. 'ssl' => array(
  41. 'verify_peer' => true,
  42. 'verify_peer_name' => true,
  43. "cafile" => dirname(__FILE__) ."/ca.crt",
  44. //'ciphers'=>'RC4-SHA'
  45. )
  46.  
  47. );
  48.  
  49. $options = array(
  50. 'trace' => 1,
  51. 'keep_alive' => true,
  52. 'exceptions' => 0,
  53. //'soap_version' => SOAP_1_1,
  54. 'local_cert' => $cert,
  55. 'passphrase' => $password,
  56. 'stream_context' => stream_context_create($opts),
  57. 'cache_wsdl' => WSDL_CACHE_NONE
  58.  
  59. );
  60.  
  61. $client = new SoapClient($request_url, $options);
  62.  
  63.  
  64. $params = array(
  65. 'Register' => '',
  66. 'request' => array(
  67. 'Customer' => $merchant_name,
  68. 'Language' => 'en',
  69. 'version' => 2,
  70. 'Amount' => $tamount,
  71. 'Currency' => 'PKR',
  72. 'OrderID' => $orderid,
  73. 'OrderInfo' => $tamount,
  74. 'OrderName' => $orderid,
  75. 'ReturnPath' => $rurl,
  76. 'TransactionHint' => 'VCC:Y'
  77. )
  78. );
  79.  
  80.  
  81. $result = $client->Register($params);
  82.  
  83. echo '<pre>';
  84. print_r($result);
  85. echo '</pre>';
  86.  
  87. $html = '';
  88. $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>';
  89. $html .= '<div id="mj-wc-ezcash-form">';
  90. $html .= '<form id="order_review" method="post" action="https://demo-ipg.comtrust.ae/Payment/PaymentPortal.aspx?lang=en&layout=C0STCBVLEI">';
  91. $html .= '<input type="hidden" value="' . $result->RegisterResult->TransactionID . '" name="TransactionID">';
  92. $html .= '<button class="button alt" id="mj-wc-ezcash-payment-button">' . __('Pay Now', 'woothemes') . '</button>';
  93. $html .= '&nbsp;&nbsp;<a class="button cancel" href="' . esc_url($order->get_cancel_order_url()) . '">' . __('Cancel order &amp; restore cart', 'woothemes') . '</a>';
  94. $html .= '</form>';
  95. $html .= '</div>';
  96.  
  97. echo $html;
  98. }
  99. }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement