Created
July 3, 2018 05:38
-
-
Save ridouchire/b745909be3879bb3d47bb9db2c90b787 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
diff --git a/app/addons/rus_payments/func.php b/app/addons/rus_payments/func.php | |
index 746fbfe..9a51883 100644 | |
--- a/app/addons/rus_payments/func.php | |
+++ b/app/addons/rus_payments/func.php | |
@@ -631,34 +631,49 @@ function fn_yandex_checkpoint_get_refunded_order($order_info) | |
*/ | |
function fn_rus_payments_payanyway_send_order_info($params, $order_info) | |
{ | |
- $inventory_positions = fn_rus_payments_payanyway_get_inventory_positions($order_info); | |
- | |
- if (!empty($inventory_positions)) { | |
- $data = array( | |
- 'id' => $params['MNT_TRANSACTION_ID'], | |
- 'checkoutDateTime' => date(DATE_ATOM), | |
- 'docNum' => $params['MNT_TRANSACTION_ID'], | |
- 'docType' => 'SALE', | |
- 'email' => $order_info['email'], | |
- 'inventPositions' => $inventory_positions, | |
- 'moneyPositions' => array(array('paymentType' => 'CARD', 'sum' => $params['MNT_AMOUNT'])) | |
- ); | |
- | |
- $mnt_dataintegrity_code = $order_info['payment_method']['processor_params']['mnt_dataintegrity_code']; | |
- $data['signature'] = md5($data['id'] . $data['checkoutDateTime'] . $mnt_dataintegrity_code); | |
- $jsonData = json_encode($data); | |
- $operationUrl = PAYANYWAY_GATEWAY_URL . '/api/api.php?method=sale&accountid=' . $params['MNT_ID']; | |
- | |
- $extra = array( | |
- 'headers' => array( | |
- 'Content-Type: application/json', | |
- 'Content-Length: ' . strlen($jsonData) | |
- ), | |
- 'log_preprocessor' => '\Tygh\Http::unescapeJsonResponse' | |
- ); | |
- | |
- Http::post($operationUrl, $jsonData, $extra); | |
- } | |
+ $result_code = 200; | |
+ $dataintegrity_code = $order_info['payment_method']['processor_params']['mnt_dataintegrity_code']; | |
+ $signature = $signature = md5($result_code . $params['MNT_ID'] . $params['MNT_TRANSACTION_ID'] . $dataintegrity_code); | |
+ $inventory = json_encode(fn_rus_payments_payanyway_get_inventory_positions($order_info)); | |
+ | |
+ header("Content-type: application/xml"); | |
+ | |
+ $data = <<<EOT | |
+<?xml version="1.0" encoding="UTF-8" ?> | |
+<MNT_RESPONSE> | |
+EOT; | |
+ | |
+ $data .= fn_array_to_xml(array( | |
+ 'MNT_ID' => $params['MNT_ID'], | |
+ 'MNT_TRANSACTION_ID' => $params['MNT_TRANSACTION_ID'], | |
+ 'MNT_RESULT_CODE' => 200, | |
+ 'MNT_SIGNATURE' => $signature, | |
+ )); | |
+ | |
+ $data .= <<<EOT | |
+<MNT_ATTRIBUTES> | |
+<ATTRIBUTE> | |
+EOT; | |
+ $data .= fn_array_to_xml(array( | |
+ 'KEY' => 'INVENTORY', | |
+ 'VALUE' => $inventory, | |
+ )); | |
+ $data .= <<<EOT | |
+</ATTRIBUTE> | |
+<ATTRIBUTE> | |
+EOT; | |
+ $data .= fn_array_to_xml(array( | |
+ 'KEY' => 'CUSTOMER', | |
+ 'VALUE' => $order_info['email'], | |
+ )); | |
+ $data .= <<<EOT | |
+</ATTRIBUTE> | |
+</MNT_ATTRIBUTES> | |
+</MNT_RESPONSE> | |
+EOT; | |
+ | |
+ echo $data; | |
+ exit; | |
} | |
/** | |
@@ -683,6 +698,7 @@ function fn_rus_payments_payanyway_get_inventory_positions($order_info) | |
'name' => $item->getName(), | |
'price' => $item->getPrice(), | |
'quantity' => $item->getQuantity(), | |
+ 'type' => $item->getType(), | |
'vatTag' => isset($map_taxes[$item->getTaxType()]) ? $map_taxes[$item->getTaxType()] : $map_taxes[TaxType::NONE] | |
); | |
} |
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
diff --git a/app/addons/rus_payments/payments/payanyway.php b/app/addons/rus_payments/payments/payanyway.php | |
index 2be6a01..d552b7c 100644 | |
--- a/app/addons/rus_payments/payments/payanyway.php | |
+++ b/app/addons/rus_payments/payments/payanyway.php | |
@@ -37,8 +37,9 @@ if (defined('PAYMENT_NOTIFICATION')) { | |
&& $processor_data['processor_params']['send_receipt'] == 'Y' | |
) { | |
fn_rus_payments_payanyway_send_order_info($_REQUEST, $order_info); | |
+ } else { | |
+ die('SUCCESS'); | |
} | |
- die('SUCCESS'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment