diff --git a/spectrocoin/lib/SCMerchantClient/SCMerchantClient.php b/spectrocoin/lib/SCMerchantClient/SCMerchantClient.php index 0fded4d..5e70ad9 100644 --- a/spectrocoin/lib/SCMerchantClient/SCMerchantClient.php +++ b/spectrocoin/lib/SCMerchantClient/SCMerchantClient.php @@ -92,7 +92,7 @@ public function createOrder(CreateOrderRequest $request) if ($body != null) { if (is_array($body) && count($body) > 0 && isset($body[0]->code)) { return new ApiError($body[0]->code, $body[0]->message); - } else if (isset($body->orderRequestId)) { + } else { return new CreateOrderResponse($body->orderRequestId, $body->orderId, $body->depositAddress, $body->payAmount, $body->payCurrency, $body->receiveAmount, $body->receiveCurrency, $body->validUntil, $body->redirectUrl); } } @@ -127,7 +127,7 @@ public function parseCreateOrderCallback($r) { $result = null; - if ($r != null && isset($r['userId'], $r['merchantApiId'], $r['orderId'], $r['payCurrency'], $r['payAmount'], $r['receiveCurrency'], $r['receiveAmount'], $r['receivedAmount'], $r['description'], $r['orderRequestId'], $r['status'], $r['sign'])) { + if ($r != null && isset($r['userId'], $r['merchantApiId'], $r['merchantId'], $r['apiId'], $r['orderId'], $r['payCurrency'], $r['payAmount'], $r['receiveCurrency'], $r['receiveAmount'], $r['receivedAmount'], $r['description'], $r['orderRequestId'], $r['status'], $r['sign'])) { $result = new OrderCallback($r['userId'], $r['merchantApiId'], $r['orderId'], $r['payCurrency'], $r['payAmount'], $r['receiveCurrency'], $r['receiveAmount'], $r['receivedAmount'], $r['description'], $r['orderRequestId'], $r['status'], $r['sign']); } @@ -151,8 +151,8 @@ public function validateCreateOrderCallback(OrderCallback $c) return $valid; $payload = array( - 'userId' => $c->getUserId(), - 'merchantApiId' => $c->getMerchantApiId(), + 'merchantId' => $c->getMerchantId(), + 'apiId' => $c->getApiId(), 'orderId' => $c->getOrderId(), 'payCurrency' => $c->getPayCurrency(), 'payAmount' => $c->getPayAmount(), @@ -188,4 +188,4 @@ private function validateSignature($data, $signature) return $r; } -} \ No newline at end of file +} diff --git a/spectrocoin/lib/SCMerchantClient/data/OrderCallback.php b/spectrocoin/lib/SCMerchantClient/data/OrderCallback.php index c8a9142..6475534 100644 --- a/spectrocoin/lib/SCMerchantClient/data/OrderCallback.php +++ b/spectrocoin/lib/SCMerchantClient/data/OrderCallback.php @@ -4,6 +4,8 @@ class OrderCallback { private $userId; private $merchantApiId; + private $merchantId; + private $apiId; private $orderId; private $payCurrency; private $payAmount; @@ -14,10 +16,12 @@ class OrderCallback private $orderRequestId; private $status; private $sign; - function __construct($userId, $merchantApiId, $orderId, $payCurrency, $payAmount, $receiveCurrency, $receiveAmount, $receivedAmount, $description, $orderRequestId, $status, $sign) + function __construct($userId, $merchantApiId, $merchantId, $apiId, $orderId, $payCurrency, $payAmount, $receiveCurrency, $receiveAmount, $receivedAmount, $description, $orderRequestId, $status, $sign) { $this->userId = $userId; $this->merchantApiId = $merchantApiId; + $this->merchantId = $merchantId; + $this->apiId = $apiId; $this->orderId = $orderId; $this->payCurrency = $payCurrency; $this->payAmount = $payAmount; @@ -33,17 +37,17 @@ function __construct($userId, $merchantApiId, $orderId, $payCurrency, $payAmount /** * @return mixed */ - public function getUserId() + public function getMerchantId() { - return $this->userId; + return $this->merchantId; } /** * @return mixed */ - public function getMerchantApiId() + public function getApiId() { - return $this->merchantApiId; + return $this->apiId; } /** @@ -130,8 +134,10 @@ public function validate() { $valid = true; - $valid &= $this->getUserId() > 0; - $valid &= $this->getMerchantApiId() > 0; + $valid &= $this->getuserId() != ''; + $valid &= $this->getmerchantApiId() != ''; + $valid &= $this->getMerchantId() > 0; + $valid &= $this->getApiId() > 0; $valid &= $this->getOrderId() != ''; $valid &= $this->getPayCurrency() != ''; $valid &= $this->getPayAmount() > 0; @@ -146,4 +152,4 @@ public function validate() } -} \ No newline at end of file +}