Changeset 2605840
- Timestamp:
- 09/27/2021 09:06:48 PM (4 years ago)
- Location:
- helcim-commerce-for-woocommerce/trunk
- Files:
-
- 7 edited
-
WCHelcimGateway.php (modified) (15 diffs)
-
classes/HelcimCurl.php (modified) (1 diff)
-
classes/HelcimDirectService.php (modified) (2 diffs)
-
classes/HelcimJSService.php (modified) (1 diff)
-
index.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
helcim-commerce-for-woocommerce/trunk/WCHelcimGateway.php
r2601916 r2605840 17 17 * Provides integration between WooCommerce and Helcim Commerce .js 18 18 * 19 * @uses WC_Payment_Gateway::validate_fields() 19 20 * @class WCHelcimGateway 20 21 * @extends WC_Payment_Gateway 21 * @version 2.0. 422 * @version 2.0.5 22 23 * @author Helcim Inc. 23 24 */ 24 25 class WCHelcimGateway extends WC_Payment_Gateway 25 26 { 26 private const PLUGIN_NAME = 'woocommerce';27 private const VERSION = '2.0.4';28 27 private const HELCIM_JS_FILE = 'https://secure.myhelcim.com/js/version2.js'; 29 28 private const GOOGLE_RECAPTCHA_URL = 'https://www.google.com/recaptcha/api.js'; … … 31 30 private const GOOGLE_RECAPTCHA_LIVE_SITE_KEY = '6LdixK0UAAAAABmBXVo_jyFJSkQ5Doj9kloLyxGG'; 32 31 32 public const PLUGIN_NAME = 'woocommerce'; 33 public const VERSION = '2.0.5'; 33 34 public const HELCIM_CARD_TOKEN = 'helcim-card-token'; 34 35 public const API_ENDPOINT = 'https://secure.myhelcim.com/api/'; … … 45 46 private $terminalId; 46 47 47 private $helcimCURL;48 48 private $helcimJSService; 49 49 private $helcimDirectService; … … 112 112 } 113 113 114 public function getHelcimCURL(): ?HelcimCurl115 {116 return $this->helcimCURL;117 }118 119 public function setHelcimCURL(HelcimCurl $helcimCURL): WCHelcimGateway120 {121 $this->helcimCURL = $helcimCURL;122 return $this;123 }124 125 114 public function getAccountId(): string 126 115 { … … 131 120 { 132 121 return $this->apiToken; 122 } 123 124 public function getTransactionType(): string 125 { 126 return $this->transactionType; 127 } 128 129 public function getTerminalId(): string 130 { 131 return $this->terminalId; 133 132 } 134 133 … … 137 136 * - Options for bits like 'title' and availability on a country-by-country basis 138 137 * 138 * @return void 139 * @uses WC_Payment_Gateway::admin_options() 139 140 * @access public 140 * @return void141 141 */ 142 142 public function admin_options(): void … … 155 155 } 156 156 157 p rivatefunction isJS(): bool157 public function isJS(): bool 158 158 { 159 159 return $this->method === 'js'; 160 160 } 161 161 162 p rivatefunction isDirect(): bool162 public function isDirect(): bool 163 163 { 164 164 return $this->method === 'direct'; … … 265 265 } 266 266 267 private function buildPostData($order): array268 {269 $shippingAmount = $order->get_shipping_total();270 $discountAmount = $order->get_total_discount();271 $refundAmount = 0;272 $orderItemCounter = 0;273 $taxed = false;274 if (is_array($order->get_refunds())) {275 foreach ($order->get_refunds() as $refund) {276 $refundAmount += $refund->get_amount();277 }278 }279 $ipAddress = class_exists('WC_Geolocation') ? WC_Geolocation::get_ip_address() : $_SERVER['REMOTE_ADDR'] ?? '';280 $helcimArgs = [281 'accountId' => $this->accountId,282 'apiToken' => $this->apiToken,283 'transactionType' => $this->transactionType,284 'terminalId' => $this->terminalId,285 'test' => $this->isTest(),286 'ecommerce' => 1,287 'cvvIndicator' => 1,288 'ipAddress' => $ipAddress,289 'thirdParty' => self::PLUGIN_NAME,290 ];291 $helcimArgs['server_remote_addr'] = $_SERVER['REMOTE_ADDR'] ?? '';292 $helcimArgs['amount'] = number_format($order->get_total(), 2, '.', '');293 $helcimArgs['currency'] = $this->woocommerceCurrencyAbbreviation();294 $helcimArgs['amountShipping'] = number_format($shippingAmount, 2, '.', '');295 $helcimArgs['amountTax'] = number_format($order->get_total_tax(), 2, '.', '');296 $helcimArgs['amountDiscount'] = number_format('-' . ($discountAmount + $refundAmount), 2, '.', '');297 $helcimArgs['orderNumber'] = $this->setOrderNumber($order->get_order_number());298 $helcimArgs['comments'] = $order->get_customer_note();299 if (get_current_user_id()) {300 $helcimArgs['customerCode'] = get_current_user_id();301 }302 if ($this->isJS()) {303 // look for generated customer code from verify transaction not matching user's id304 if (isset($_POST['customerCode'], $helcimArgs['customerCode'])305 && $_POST['customerCode'] !== $helcimArgs['customerCode']) {306 $helcimArgs['customerCodeOld'] = $_POST['customerCode'];307 }308 if (isset($_POST['cardToken'])) {309 $helcimArgs['cardToken'] = $_POST['cardToken'];310 }311 $helcimArgs['cardF4L4Skip'] = 1;312 }elseif($this->isDirect()) {313 $helcimArgs['cardHolderName'] = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name();314 if (isset($_POST['cardNumber'])) {315 $helcimArgs['cardNumber'] = $_POST['cardNumber'];316 }317 if (isset($_POST['cardExpiryMonth'], $_POST['cardExpiryYear'])) {318 $helcimArgs['cardExpiry'] = $_POST['cardExpiryMonth'] . $_POST['cardExpiryYear'];319 }320 if (isset($_POST['cardCVV'])) {321 $helcimArgs['cardCVV'] = $_POST['cardCVV'];322 }323 $helcimArgs['cardHolderAddress'] = $order->get_billing_address_1() . ' ' . $order->get_billing_address_2();324 $helcimArgs['cardHolderPostalCode'] = $order->get_billing_postcode();325 }326 if (is_array($order->get_items())) {327 foreach ($order->get_items() as $item) {328 $orderItemCounter++;329 $product = $order->get_product_from_item($item);330 $sku = $product->get_sku() ?: 'NoSKU';331 $helcimArgs['itemSKU' . $orderItemCounter] = $sku;332 $helcimArgs['itemDescription' . $orderItemCounter] = $item['name'];333 $helcimArgs['itemQuantity' . $orderItemCounter] = $item['qty'];334 $helcimArgs['itemPrice' . $orderItemCounter] = $order->get_item_total($item, $taxed, false);335 $helcimArgs['itemTotal' . $orderItemCounter] = $order->get_line_total($item, $taxed, false);336 }337 }338 if (is_array($order->get_fees())) {339 foreach ($order->get_fees() as $fee) {340 $orderItemCounter++;341 $helcimArgs['itemSKU' . $orderItemCounter] = 'Fee' . $fee->get_id();342 $helcimArgs['itemDescription' . $orderItemCounter] = $fee->get_name();343 $helcimArgs['itemQuantity' . $orderItemCounter] = '1';344 $helcimArgs['itemPrice' . $orderItemCounter] = $fee->get_total();345 $helcimArgs['itemTotal' . $orderItemCounter] = $fee->get_total();346 }347 }348 $helcimArgs['billing_contactName'] = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name();349 $helcimArgs['billing_street1'] = $order->get_billing_address_1();350 $helcimArgs['billing_street2'] = $order->get_billing_address_2();351 $helcimArgs['billing_city'] = $order->get_billing_city();352 $helcimArgs['billing_province'] = $order->get_billing_state();353 $helcimArgs['billing_postalCode'] = $order->get_billing_postcode();354 $helcimArgs['billing_country'] = $order->get_billing_country();355 $helcimArgs['billing_phone'] = $order->get_billing_phone();356 $helcimArgs['billing_email'] = $order->get_billing_email();357 $helcimArgs['shipping_contactName'] = $order->get_shipping_first_name() . ' ' . $order->get_shipping_last_name(358 );359 $helcimArgs['shipping_street1'] = $order->get_shipping_address_1();360 $helcimArgs['shipping_street2'] = $order->get_shipping_address_2();361 $helcimArgs['shipping_city'] = $order->get_shipping_city();362 $helcimArgs['shipping_province'] = $order->get_shipping_state();363 $helcimArgs['shipping_postalCode'] = $order->get_shipping_postcode();364 $helcimArgs['shipping_country'] = $order->get_shipping_country();365 foreach ($helcimArgs as $key => $value) {366 $helcimArgs[$key] = trim($value);367 }368 return $helcimArgs;369 }370 371 267 /** 372 268 * Process payment 373 269 * 270 * @uses WC_Payment_Gateway::process_payment() 374 271 * @access public 375 272 * @param int $orderId … … 380 277 if (!$this->getHelcimJSService() instanceof HelcimJSService) { 381 278 $this->setHelcimJSService(new HelcimJSService()); 279 } 280 if (!$this->getHelcimDirectService() instanceof HelcimDirectService) { 281 $this->setHelcimDirectService(new HelcimDirectService()); 382 282 } 383 283 $order = wc_get_order($orderId); … … 408 308 } 409 309 410 $helcimArgs = $this->buildPostData($order); 411 if (!$this->getHelcimCURL() instanceof HelcimCurl) { 412 $this->setHelcimCURL(new HelcimCurl()); 413 } 414 $response = $this->getHelcimCURL()->curl($helcimArgs, self::API_ENDPOINT); 415 if (!is_string($response)) { 416 wc_add_notice( 417 '<b>Payment error:</b> Something went wrong please contact the Merchant', 418 'error' 419 ); 420 self::log( 421 'Invalid Transaction: Connection Error ' . $this->getHelcimCURL()->getCurlErrorNumber( 422 ) . '-' . $this->getHelcimCURL()->getCurlError() 423 ); 310 $xmlObject = $this->getHelcimDirectService()->processPurchasePreauth($order, $this); 311 if (!$xmlObject instanceof SimpleXMLElement) { 312 wc_add_notice('<b>Payment error:</b> Something went wrong please contact the Merchant', 'error'); 313 self::log("ORDER {$order->get_id()} ERROR - {$this->getHelcimDirectService()->getError()}"); 424 314 $order->add_order_note( 425 "Helcim payment Failed - Connection Error ({$this->getHelcimCURL()->getCurlErrorNumber()}) {$this->getHelcimCURL()->getCurlError()}"315 "Helcim Payment Failed - {$this->getHelcimDirectService()->getError()}" 426 316 ); 427 317 return []; 428 318 } 429 return $this->checkDirectResponse($response, $order); 319 $this->completeOrder( 320 $order, 321 (string)$xmlObject->approvalCode ?: '', 322 isset($xmlObject->transaction->transactionId) ? (string)$xmlObject->transaction->transactionId : '0', 323 (string)$xmlObject->cardToken ?: '' 324 ); 325 return [ 326 'result' => 'success', 327 'redirect' => $this->get_return_url($order) 328 ]; 430 329 } 431 330 432 331 /** 332 * @uses WC_Payment_Gateway::process_refund() 433 333 * @param int $orderId 434 334 * @param null $amount … … 445 345 $approvalCode = $this->getHelcimDirectService()->processRefund($order, $amount, $this); 446 346 if (!is_string($approvalCode)) { 447 wc_add_notice("Refund - {$this->getHelcimDirectService()->getError()}", 'error');347 wc_add_notice("Refund Failed - {$this->getHelcimDirectService()->getError()}", 'error'); 448 348 self::log("ORDER {$order->get_id()} Failed to Refund - {$this->getHelcimDirectService()->getError()}"); 449 349 $order->add_order_note( 450 "Helcim Refund {$this->getHelcimDirectService()->getError()}"350 "Helcim Refund Failed - {$this->getHelcimDirectService()->getError()}" 451 351 ); 452 352 return false; … … 459 359 } 460 360 461 private function checkDirectResponse($xml_string, $order): array462 {463 if (!$this->getHelcimCURL() instanceof HelcimCurl) {464 $this->setHelcimCURL(new HelcimCurl());465 }466 $objectXML = $this->getHelcimCURL()->convertToXML($xml_string);467 if (!$objectXML instanceof SimpleXMLElement) {468 wc_add_notice('<b>Payment error:</b> Something went wrong please contact the Merchant', 'error');469 self::log("ORDER {$order->get_id()} ERROR - {$this->getHelcimCURL()->getError()}");470 $order->add_order_note(471 "Helcim Payment Failed - Invalid Response Format"472 );473 return [];474 }475 if (!$this->getHelcimCURL()->validateXML($objectXML)) {476 wc_add_notice(477 '<b>Payment error:</b> DECLINED - ' . $this->getHelcimCURL()->getError(),478 'error'479 );480 self::log('ORDER ' . $order->get_id() . ' DECLINED - ' . print_r($objectXML, true));481 $order->add_order_note(482 "Helcim Payment Failed - {$this->getHelcimCURL()->getError()}"483 );484 return [];485 }486 $this->completeOrder(487 $order,488 isset($objectXML->transaction->approvalCode) ? (string)$objectXML->transaction->approvalCode : '',489 isset($objectXML->transaction->transactionId) ? (string)$objectXML->transaction->transactionId : '0',490 isset($objectXML->transaction->cardToken) ? (string)$objectXML->transaction->cardToken : ''491 );492 return [493 'result' => 'success',494 'redirect' => $this->get_return_url($order)495 ];496 }497 498 361 /** 499 362 * Payment Fields 500 363 * 364 * @uses WC_Payment_Gateway::payment_fields() 501 365 * @access public 502 366 * @return void … … 690 554 } 691 555 692 /** 693 * Validate payment fields 694 * 695 * @access public 696 * @return void 697 */ 556 /** 557 * Validate payment fields 558 * 559 * @return void 560 * @uses WC_Payment_Gateway::validate_fields() 561 * @access public 562 */ 698 563 public function validate_fields(): void 699 564 { … … 707 572 return; 708 573 } 574 $objectXML = $this->getHelcimJSService()->parseXML($_POST['xml'], $_POST['xmlHash'], $this); 575 $transactionType = isset($objectXML->type) ? strtoupper((string)$objectXML->type) : 'UNKNOWN'; 576 $transactionId = isset($objectXML->transactionId) ? (string)$objectXML->transactionId : '0'; 577 $approvalCode = (string)$objectXML->approvalCode ?: ''; 578 self::log("$transactionType #$transactionId Approved - $approvalCode"); 579 $this->voidTransactionOnCheckoutOrderException((int)$transactionId); 709 580 return; 710 581 } … … 780 651 return strtoupper((string)preg_replace("/[^a-zA-Z]/", '', get_woocommerce_currency())); 781 652 } 653 654 private function voidTransactionOnCheckoutOrderException(int $transactionId): void 655 { 656 $arguments = [ 657 'transactionId' => $transactionId, 658 'gateway' => $this, 659 ]; 660 add_action( 661 'woocommerce_checkout_order_exception', 662 function () use ($arguments) { 663 $transactionId = (int)$arguments['transactionId']; 664 $gateway = $arguments['gateway']; 665 $service = new HelcimDirectService(); 666 $objectXML = $service->processVoid($transactionId, $gateway); 667 if (!$objectXML instanceof SimpleXMLElement) { 668 wc_add_notice("Void Failed", 'error'); 669 self::log("FAILED TO VOID TRANSACTION #{$transactionId} - {$service->getError()}"); 670 return; 671 } 672 $approvalCode = isset($objectXML->transaction->approvalCode) ? (string)$objectXML->transaction->approvalCode : ''; 673 self::log("VOID #{$transactionId} Approved"); 674 }, 675 0, 676 1 677 ); 678 } 782 679 } -
helcim-commerce-for-woocommerce/trunk/classes/HelcimCurl.php
r2596407 r2605840 122 122 return true; 123 123 } 124 125 public function validXML(string $response): ?SimpleXMLElement 126 { 127 $objectXML = $this->convertToXML($response); 128 if (!$objectXML instanceof SimpleXMLElement) { 129 return null; 130 } 131 if (!$this->validateXML($objectXML)) { 132 return null; 133 } 134 return $objectXML; 135 } 136 137 public function buildGenericPostData(WCHelcimGateway $wcHelcimGateway): array 138 { 139 $ipAddress = class_exists('WC_Geolocation') ? WC_Geolocation::get_ip_address() : $_SERVER['REMOTE_ADDR'] ?? ''; 140 return [ 141 'accountId' => $wcHelcimGateway->getAccountId(), 142 'apiToken' => $wcHelcimGateway->getAPIToken(), 143 'test' => $wcHelcimGateway->isTest(), 144 'ecommerce' => 1, 145 'ipAddress' => $ipAddress, 146 'thirdParty' => WCHelcimGateway::PLUGIN_NAME, 147 'pluginVersion' => WCHelcimGateway::VERSION, 148 'server_remote_addr' => $_SERVER['REMOTE_ADDR'] ?? '', 149 ]; 150 } 124 151 } -
helcim-commerce-for-woocommerce/trunk/classes/HelcimDirectService.php
r2596407 r2605840 17 17 * @return false|string 18 18 */ 19 public function processRefund(WC_Order $order, float $amount, WCHelcimGateway $helcimGateway) 19 public function processRefund(WC_Order $order, float $amount, WCHelcimGateway $helcimGateway): ?string 20 20 { 21 21 if (!$this->getHelcimCURL() instanceof HelcimCurl) { … … 24 24 if (!$this->checkOrderForRefund($order, $amount)) { 25 25 $this->setError("Error - {$this->getError()}"); 26 return false; 27 } 28 $post = [ 29 'accountId' => $helcimGateway->getAccountId(), 30 'apiToken' => $helcimGateway->getAPIToken(), 31 'transactionType' => 'refund', 32 'transactionId' => $order->get_transaction_id(), 33 'amount' => $amount, 34 'cardToken' => $order->get_meta(WCHelcimGateway::HELCIM_CARD_TOKEN), 35 'cardF4L4Skip' => '1', 36 'test' => $helcimGateway->isTest(), 37 ]; 38 39 $response = $this->getHelcimCURL()->curl($post, WCHelcimGateway::API_ENDPOINT); 26 return null; 27 } 28 $response = $this->getHelcimCURL()->curl( 29 $this->buildRefundPostData($helcimGateway, $order, $amount), 30 WCHelcimGateway::API_ENDPOINT 31 ); 40 32 if (!is_string($response)) { 41 33 $this->setError($this->getHelcimCURL()->getError()); 42 return false;43 } 44 $objectXML = $this->getHelcimCURL()-> convertToXML($response);34 return null; 35 } 36 $objectXML = $this->getHelcimCURL()->validXML($response); 45 37 if (!$objectXML instanceof SimpleXMLElement) { 46 38 $this->setError($this->getHelcimCURL()->getError()); 47 return false; 48 } 49 if (!$this->getHelcimCURL()->validateXML($objectXML)) { 50 $this->setError($this->getHelcimCURL()->getError()); 51 return false; 39 return null; 52 40 } 53 41 return isset($objectXML->transaction->approvalCode) ? (string)$objectXML->transaction->approvalCode : ''; 42 } 43 44 private function buildRefundPostData(WCHelcimGateway $helcimGateway, $order, float $amount): array 45 { 46 if (!$this->getHelcimCURL() instanceof HelcimCurl) { 47 $this->setHelcimCURL(new HelcimCurl()); 48 } 49 $postData = $this->getHelcimCURL()->buildGenericPostData($helcimGateway); 50 $postData['transactionType'] = 'refund'; 51 $postData['transactionId'] = $order->get_transaction_id(); 52 $postData['amount'] = $amount; 53 $postData['cardToken'] = $order->get_meta(WCHelcimGateway::HELCIM_CARD_TOKEN); 54 $postData['cardF4L4Skip'] = '1'; 55 $postData['test'] = $helcimGateway->isTest(); 56 return $postData; 57 } 58 59 public function processVoid(int $transactionId, WCHelcimGateway $wcHelcimGateway): ?SimpleXMLElement 60 { 61 if (!$this->getHelcimCURL() instanceof HelcimCurl) { 62 $this->setHelcimCURL(new HelcimCurl()); 63 } 64 $response = $this->getHelcimCURL()->curl( 65 $this->buildVoidPostData($wcHelcimGateway, $transactionId), 66 WCHelcimGateway::API_ENDPOINT 67 ); 68 if (!is_string($response)) { 69 $this->setError($this->getHelcimCURL()->getError()); 70 return null; 71 } 72 $objectXML = $this->getHelcimCURL()->validXML($response); 73 if (!$objectXML instanceof SimpleXMLElement) { 74 $this->setError($this->getHelcimCURL()->getError()); 75 return null; 76 } 77 return $objectXML; 78 } 79 80 private function buildVoidPostData(WCHelcimGateway $wcHelcimGateway, int $transactionId): array 81 { 82 if (!$this->getHelcimCURL() instanceof HelcimCurl) { 83 $this->setHelcimCURL(new HelcimCurl()); 84 } 85 $postData = $this->getHelcimCURL()->buildGenericPostData($wcHelcimGateway); 86 $postData['transactionType'] = 'void'; 87 $postData['transactionId'] = $transactionId; 88 $postData['test'] = $wcHelcimGateway->isTest(); 89 return $postData; 90 } 91 92 public function processPurchasePreauth($order, WCHelcimGateway $wcHelcimGateway): ?SimpleXMLElement 93 { 94 if (!$this->getHelcimCURL() instanceof HelcimCurl) { 95 $this->setHelcimCURL(new HelcimCurl()); 96 } 97 $response = $this->getHelcimCURL()->curl( 98 $this->buildPurchasePreauthPostData($order, $wcHelcimGateway), 99 WCHelcimGateway::API_ENDPOINT 100 ); 101 if (!is_string($response)) { 102 $this->setError($this->getHelcimCURL()->getError()); 103 return null; 104 } 105 $objectXML = $this->getHelcimCURL()->validXML($response); 106 if (!$objectXML instanceof SimpleXMLElement) { 107 $this->setError($this->getHelcimCURL()->getError()); 108 return null; 109 } 110 return $objectXML; 111 } 112 113 private function buildPurchasePreauthPostData($order, WCHelcimGateway $wcHelcimGateway): array 114 { 115 $shippingAmount = $order->get_shipping_total(); 116 $discountAmount = $order->get_total_discount(); 117 $refundAmount = 0; 118 $orderItemCounter = 0; 119 $taxed = false; 120 if (is_array($order->get_refunds())) { 121 foreach ($order->get_refunds() as $refund) { 122 $refundAmount += $refund->get_amount(); 123 } 124 } 125 if (!$this->getHelcimCURL() instanceof HelcimCurl) { 126 $this->setHelcimCURL(new HelcimCurl()); 127 } 128 $helcimArgs = $this->getHelcimCURL()->buildGenericPostData($wcHelcimGateway); 129 $helcimArgs['transactionType'] = $wcHelcimGateway->getTransactionType(); 130 $helcimArgs['terminalId'] = $wcHelcimGateway->getTerminalId(); 131 $helcimArgs['cvvIndicator'] = 1; 132 $helcimArgs['amount'] = number_format($order->get_total(), 2, '.', ''); 133 $helcimArgs['currency'] = $wcHelcimGateway->woocommerceCurrencyAbbreviation(); 134 $helcimArgs['amountShipping'] = number_format($shippingAmount, 2, '.', ''); 135 $helcimArgs['amountTax'] = number_format($order->get_total_tax(), 2, '.', ''); 136 $helcimArgs['amountDiscount'] = number_format('-' . ($discountAmount + $refundAmount), 2, '.', ''); 137 $helcimArgs['orderNumber'] = $wcHelcimGateway->setOrderNumber($order->get_order_number()); 138 $helcimArgs['comments'] = $order->get_customer_note(); 139 if (get_current_user_id()) { 140 $helcimArgs['customerCode'] = get_current_user_id(); 141 } 142 if ($wcHelcimGateway->isJS()) { 143 // look for generated customer code from verify transaction not matching user's id 144 if (isset($_POST['customerCode'], $helcimArgs['customerCode']) 145 && $_POST['customerCode'] !== $helcimArgs['customerCode']) { 146 $helcimArgs['customerCodeOld'] = $_POST['customerCode']; 147 } 148 if (isset($_POST['cardToken'])) { 149 $helcimArgs['cardToken'] = $_POST['cardToken']; 150 } 151 $helcimArgs['cardF4L4Skip'] = 1; 152 } elseif ($wcHelcimGateway->isDirect()) { 153 $helcimArgs['cardHolderName'] = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name(); 154 if (isset($_POST['cardNumber'])) { 155 $helcimArgs['cardNumber'] = $_POST['cardNumber']; 156 } 157 if (isset($_POST['cardExpiryMonth'], $_POST['cardExpiryYear'])) { 158 $helcimArgs['cardExpiry'] = $_POST['cardExpiryMonth'] . $_POST['cardExpiryYear']; 159 } 160 if (isset($_POST['cardCVV'])) { 161 $helcimArgs['cardCVV'] = $_POST['cardCVV']; 162 } 163 $helcimArgs['cardHolderAddress'] = $order->get_billing_address_1() . ' ' . $order->get_billing_address_2(); 164 $helcimArgs['cardHolderPostalCode'] = $order->get_billing_postcode(); 165 } 166 if (is_array($order->get_items())) { 167 foreach ($order->get_items() as $item) { 168 $orderItemCounter++; 169 $product = $order->get_product_from_item($item); 170 $sku = $product->get_sku() ?: 'NoSKU'; 171 $helcimArgs['itemSKU' . $orderItemCounter] = $sku; 172 $helcimArgs['itemDescription' . $orderItemCounter] = $item['name']; 173 $helcimArgs['itemQuantity' . $orderItemCounter] = $item['qty']; 174 $helcimArgs['itemPrice' . $orderItemCounter] = $order->get_item_total($item, $taxed, false); 175 $helcimArgs['itemTotal' . $orderItemCounter] = $order->get_line_total($item, $taxed, false); 176 } 177 } 178 if (is_array($order->get_fees())) { 179 foreach ($order->get_fees() as $fee) { 180 $orderItemCounter++; 181 $helcimArgs['itemSKU' . $orderItemCounter] = 'Fee' . $fee->get_id(); 182 $helcimArgs['itemDescription' . $orderItemCounter] = $fee->get_name(); 183 $helcimArgs['itemQuantity' . $orderItemCounter] = '1'; 184 $helcimArgs['itemPrice' . $orderItemCounter] = $fee->get_total(); 185 $helcimArgs['itemTotal' . $orderItemCounter] = $fee->get_total(); 186 } 187 } 188 $helcimArgs['billing_contactName'] = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name(); 189 $helcimArgs['billing_street1'] = $order->get_billing_address_1(); 190 $helcimArgs['billing_street2'] = $order->get_billing_address_2(); 191 $helcimArgs['billing_city'] = $order->get_billing_city(); 192 $helcimArgs['billing_province'] = $order->get_billing_state(); 193 $helcimArgs['billing_postalCode'] = $order->get_billing_postcode(); 194 $helcimArgs['billing_country'] = $order->get_billing_country(); 195 $helcimArgs['billing_phone'] = $order->get_billing_phone(); 196 $helcimArgs['billing_email'] = $order->get_billing_email(); 197 $helcimArgs['shipping_contactName'] = $order->get_shipping_first_name() . ' ' . $order->get_shipping_last_name( 198 ); 199 $helcimArgs['shipping_street1'] = $order->get_shipping_address_1(); 200 $helcimArgs['shipping_street2'] = $order->get_shipping_address_2(); 201 $helcimArgs['shipping_city'] = $order->get_shipping_city(); 202 $helcimArgs['shipping_province'] = $order->get_shipping_state(); 203 $helcimArgs['shipping_postalCode'] = $order->get_shipping_postcode(); 204 $helcimArgs['shipping_country'] = $order->get_shipping_country(); 205 foreach ($helcimArgs as $key => $value) { 206 $helcimArgs[$key] = trim($value); 207 } 208 return $helcimArgs; 54 209 } 55 210 -
helcim-commerce-for-woocommerce/trunk/classes/HelcimJSService.php
r2601916 r2605840 40 40 $this->setHelcimCURL(new HelcimCurl()); 41 41 } 42 $post = [43 "accountId" => $helcimGateway->getAccountId(),44 "apiToken" => $helcimGateway->getAPIToken(),45 "action" => "orderEdit",46 "orderNumber" => $orderNumber,47 "newOrderNumber" => $helcimGateway->setOrderNumber($order->get_order_number()),48 ];42 if (!$this->getHelcimCURL() instanceof HelcimCurl) { 43 $this->setHelcimCURL(new HelcimCurl()); 44 } 45 $post = $this->getHelcimCURL()->buildGenericPostData($helcimGateway); 46 $post["action"] = "orderEdit"; 47 $post["orderNumber"] = $orderNumber; 48 $post["newOrderNumber"] = $helcimGateway->setOrderNumber($order->get_order_number()); 49 49 $response = $this->getHelcimCURL()->curl($post, WCHelcimGateway::API_ENDPOINT); 50 50 if (!is_string($response)) { -
helcim-commerce-for-woocommerce/trunk/index.php
r2601916 r2605840 4 4 Plugin URI: https://www.helcim.com/ 5 5 Description: Helcim Commerce for WooCommerce 6 Version: 2.0. 46 Version: 2.0.5 7 7 Author: Helcim Inc. 8 8 Author URI: https://www.helcim.com/ -
helcim-commerce-for-woocommerce/trunk/readme.txt
r2601916 r2605840 73 73 == Changelog == 74 74 75 = 2.0.5 = 76 * Bug Fix - Void/Reverse Approved Transactions when checkout fails 77 * Tested upto WordPress 5.8 78 * Tested upto woocommerce v5.7 79 75 80 = 2.0.4 = 76 81 * Bug Fix - transactions expiring after 1min from approval time -
helcim-commerce-for-woocommerce/trunk/uninstall.php
r2601916 r2605840 5 5 * Uninstalls Helcim Gateway. 6 6 * 7 * @version 2.0. 47 * @version 2.0.5 8 8 * @author Helcim Inc. 9 9 */
Note: See TracChangeset
for help on using the changeset viewer.