Skip to content

Merchant flow possible #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions spectrocoin/lib/SCMerchantClient/SCMerchantClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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']);
}

Expand All @@ -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(),
Expand Down Expand Up @@ -188,4 +188,4 @@ private function validateSignature($data, $signature)
return $r;
}

}
}
22 changes: 14 additions & 8 deletions spectrocoin/lib/SCMerchantClient/data/OrderCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ class OrderCallback
{
private $userId;
private $merchantApiId;
private $merchantId;
private $apiId;
private $orderId;
private $payCurrency;
private $payAmount;
Expand All @@ -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;
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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;
Expand All @@ -146,4 +152,4 @@ public function validate()
}


}
}