Skip to content

Commit

Permalink
Merge pull request #8 from aslangery/cart_items_in_order
Browse files Browse the repository at this point in the history
Fixes for GooglePay
  • Loading branch information
anmoroz authored Jan 25, 2022
2 parents b33da54 + e233fb4 commit cfed18b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "3davinci/sberbank-gateway",
"version": "0.2.3",
"version": "0.2.4",
"description": "Sberbank REST client",
"type": "library",
"license": "MIT",
Expand Down
14 changes: 13 additions & 1 deletion src/Sberbank/Message/GooglePaymentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,19 @@ public function send(): ResponseInterface
$httpResponse = $this->sberbankClient->post(
$this->getUrl(),
['Content-type' => 'application/json'],
json_encode($this->getParameters(['orderBundle']))
json_encode($this->getParameters([
'merchant',
'orderNumber',
'paymentToken',
'amount',
'orderBundle',
'returnUrl',
'failUrl',
'description',
'phone',
'email',
'clientId'
]))
);

$body = $httpResponse->getBody();
Expand Down
29 changes: 28 additions & 1 deletion src/Sberbank/Message/GooglePaymentResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,33 @@ class GooglePaymentResponse extends RestResponse
*/
public function getOrderId(): ?string
{
return $this->data['orderId'] ?? null;
return $this->data['data']['orderId'] ?? null;
}

/**
* @return int|null
*/
public function getErrorCode(): ?int
{
if (isset($this->data['error']['code'])) {

return (int) $this->data['error']['code'];
}

return null;

}

/**
* @return string
*/
public function getErrorMessage(): string
{
if (isset($this->data['error']['message'])) {

return $this->data['error']['message'];
}

return '';
}
}

0 comments on commit cfed18b

Please sign in to comment.