Skip to content

Commit 822a617

Browse files
authored
Merge pull request #10 from alegraio/dev
Fixed amount.
2 parents bb52a46 + e70f6b0 commit 822a617

File tree

4 files changed

+11
-19
lines changed

4 files changed

+11
-19
lines changed

src/Messages/AbstractRequest.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -231,32 +231,26 @@ protected function getHttpMethod(): string
231231

232232
/**
233233
* @return string
234-
* @throws \Omnipay\Common\Exception\InvalidRequestException
235234
*/
236235
protected function getTransactionHash(): string
237236
{
238-
$amount = (int)$this->getAmount();
239-
240237
return strtoupper(SHA1(sprintf('%s%s%s%s%s',
241238
$this->getOrderId(),
242239
$this->getTerminalId(),
243240
$this->getCard()->getNumber(),
244-
$amount,
241+
$this->getAmountInteger(),
245242
$this->getSecurityHash())));
246243
}
247244

248245
/**
249246
* @return string
250-
* @throws \Omnipay\Common\Exception\InvalidRequestException
251247
*/
252248
protected function getTransactionHashWithoutCardNumber(): string
253249
{
254-
$amount = (int)$this->getAmount();
255-
256250
return strtoupper(SHA1(sprintf('%s%s%s%s',
257251
$this->getOrderId(),
258252
$this->getTerminalId(),
259-
$amount,
253+
$this->getAmountInteger(),
260254
$this->getSecurityHash())));
261255
}
262256

@@ -293,7 +287,7 @@ protected function getSalesRequestParams(): array
293287
$data['Transaction'] = array(
294288
'Type' => 'sales',
295289
'InstallmentCnt' => $this->getInstallment(),
296-
'Amount' => (int)$this->getAmount(),
290+
'Amount' => $this->getAmountInteger(),
297291
'CurrencyCode' => $this->currency_list[$this->getCurrency()],
298292
'CardholderPresentCode' => "0",
299293
'MotoInd' => "N"
@@ -329,7 +323,7 @@ protected function getCompleteSalesRequestParams(): array
329323

330324
$data['Transaction'] = array(
331325
'Type' => 'sales',
332-
'Amount' => (int)$this->getAmount(),
326+
'Amount' => $this->getAmountInteger(),
333327
'CurrencyCode' => $this->currency_list[$this->getCurrency()],
334328
'MotoInd' => "N"
335329
);
@@ -339,7 +333,6 @@ protected function getCompleteSalesRequestParams(): array
339333

340334
/**
341335
* @return array
342-
* @throws \Omnipay\Common\Exception\InvalidRequestException
343336
*/
344337
protected function getAuthorizeRequestParams(): array
345338
{
@@ -365,7 +358,7 @@ protected function getAuthorizeRequestParams(): array
365358
$data['Transaction'] = array(
366359
'Type' => 'preauth',
367360
'InstallmentCnt' => $this->getInstallment(),
368-
'Amount' => (int)$this->getAmount(),
361+
'Amount' => $this->getAmountInteger(),
369362
'CurrencyCode' => $this->currency_list[$this->getCurrency()],
370363
'CardholderPresentCode' => "0",
371364
'MotoInd' => "N"
@@ -387,7 +380,7 @@ protected function getSalesRequestParamsFor3d(): array
387380
$params['terminalid'] = $this->getTerminalId();
388381
$params['terminalmerchantid'] = $this->getMerchantId();
389382
$params['txntype'] = 'sales';
390-
$params['txnamount'] = (int)$this->getAmount();
383+
$params['txnamount'] = $this->getAmountInteger();
391384
$params['txncurrencycode'] = $this->currency_list[$this->getCurrency()];
392385
$params['txninstallmentcount'] = $this->getInstallment();
393386
$params['customeremailaddress'] = $this->getCard()->getEmail();

src/Messages/RefundRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function getData(): array
3333

3434
$data['Transaction'] = array(
3535
'Type' => 'refund',
36-
'Amount' => (int)$this->getAmount(),
36+
'Amount' => $this->getAmountInteger(),
3737
'CurrencyCode' => $this->currency_list[$this->getCurrency()]
3838
);
3939

src/Messages/VoidRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function getData(): array
3434
$data['Transaction'] = array(
3535
'Type' => 'void',
3636
'InstallmentCnt' => $this->getInstallment(),
37-
'Amount' => (int)$this->getAmount(),
37+
'Amount' => $this->getAmountInteger(),
3838
'CurrencyCode' => $this->currency_list[$this->getCurrency()],
3939
'CardholderPresentCode' => "0",
4040
'MotoInd' => "N"

tests/GatewayTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,19 @@ public function testPurchase()
3636
{
3737
$this->options = [
3838
'card' => $this->getCardInfo(),
39-
'orderId' => '8985204111',
40-
'amount' => "100",
39+
'orderId' => '1085204111',
40+
'amount' => "3.50",
4141
'currency' => 'TRY',
4242
'returnUrl' => "https://eticaret.garanti.com.tr/destek/postback.aspx",
4343
'cancelUrl' => "https://eticaret.garanti.com.tr/destek/postback.aspx",
4444
'installment' => "",
45-
'paymentMethod' => '3d',
45+
'paymentMethod' => '',
4646
'clientIp' => '10.241.19.2',
4747
'secureKey' => '12345678'
4848
];
4949

5050
/** @var PurchaseResponse $response */
5151
$response = $this->gateway->purchase($this->options)->send();
52-
5352
$this->assertTrue($response->isSuccessful());
5453
}
5554

0 commit comments

Comments
 (0)