Skip to content

Commit cb19462

Browse files
authored
Merge pull request #27 from dnetix/fix-nvp-value-type
Fix NVP value type
2 parents 5f6f664 + 568e4f3 commit cb19462

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/Entities/NameValuePair.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class NameValuePair extends Entity
88
{
99
protected string $keyword;
10-
protected string $value = '';
10+
protected $value;
1111
protected string $displayOn = 'none';
1212

1313
public function __construct($data = [])
@@ -20,7 +20,10 @@ public function keyword(): string
2020
return $this->keyword;
2121
}
2222

23-
public function value(): string
23+
/**
24+
* @return string|array
25+
*/
26+
public function value()
2427
{
2528
return $this->value;
2629
}

tests/Functionality/ServiceQueryTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ public function testItHandlesANonExistentSession()
2626
$this->assertNull($response->request());
2727
}
2828

29+
public function testItHandlesCustomNameValuePairs()
30+
{
31+
$response = $this->getService()->query(10010);
32+
33+
$this->assertSame([
34+
'merchantCode' => '1065152',
35+
'terminalNumber' => '00990099',
36+
'credit' => [
37+
'code' => 1,
38+
'type' => '03',
39+
'groupCode' => 'X',
40+
'installments' => 9,
41+
],
42+
'totalAmount' => 3809000,
43+
'interestAmount' => 0,
44+
'installmentAmount' => 423205.13,
45+
'iceAmount' => 0,
46+
'bin' => '365454',
47+
'expiration' => '1122',
48+
'lastDigits' => '0008',
49+
], $response->lastTransaction()->additionalData());
50+
}
51+
2952
public function testItHandlesABankAccountSubscription()
3053
{
3154
$response = $this->getService()->query(10009);

tests/Mocks/RestCarrierMock.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ public function query($requestId): FulfilledPromise
140140
case 10009:
141141
$response = '{"requestId": 10009,"status": {"status": "APPROVED","reason": "00","message": "La petición ha sido aprobada exitosamente","date": "2021-09-14T19:16:59-05:00"},"request": {"locale": "es_CO","buyer": {"document": "1040035000","documentType": "CC","name": "Nakia","surname": "Walker","email": "[email protected]","mobile": 3006108300},"payer": {"document": "1040035000","documentType": "CC","name": "Nakia","surname": "Walker","email": "[email protected]","mobile": 3006108300},"subscription": {"reference": "800166551","description": "Pago en micrositio"},"returnUrl": "https://dnetix.co/ping/test","ipAddress": "186.84.220.137","userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Mobile/15E148 Safari/604.1","expiration": "2021-09-19T17:05:23-05:00"},"payment": null,"subscription": {"type": "account","status": {"status": "OK","reason": "00","message": "Account stored successfully","date": "2021-09-15T00:16:45.345048Z"},"instrument": [{"keyword": "bankCode","value": "007","displayOn": "none"},{"keyword": "bankName","value": "Bancolombia","displayOn": "none"},{"keyword": "accountType","value": "A","displayOn": "none"},{"keyword": "accountNumber","value": "00849514000","displayOn": "none"}]}}';
142142
break;
143+
case 10010:
144+
$response = '{"requestId": 328759,"status": {"status": "APPROVED","reason": "00","message": "La petici\u00f3n ha sido aprobada exitosamente","date": "2021-09-23T19:00:08-05:00"},"request": {"locale": "es_CO","buyer": {"document": "1040035000","documentType": "CC","name": "Nakia","surname": "Walker","email": "[email protected]","mobile": 3006108300},"payer": {"document": "1036949824","documentType": "CI","name": "Diego","surname": "osorio","email": "[email protected]","mobile": "3102903560"},"payment": {"reference": "800166551","description": "Pago en micrositio","amount": {"currency": "COP","total": 3809000},"allowPartial": true,"subscribe": false},"fields": [{"keyword": "_processUrl_","value": "https:\/\/test.placetopay.ec\/redirection\/session\/328759\/ccad4021c274a7dc3ef71f526f2b1cb5","displayOn": "none"}],"returnUrl": "https:\/\/dnetix.co\/ping\/test","ipAddress": "186.84.220.137","userAgent": "Mozilla\/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit\/605.1.15 (KHTML, like Gecko) Version\/14.1.1 Mobile\/15E148 Safari\/604.1","expiration": "2021-10-19T17:05:23-05:00"},"payment": [{"status": {"status": "APPROVED","reason": "00","message": "Aprobada","date": "2021-09-23T18:59:45-05:00"},"internalReference": "230192","paymentMethod": "diners","paymentMethodName": "Diners","issuerName": "Diners","amount": {"from": {"currency": "COP","total": 3809000},"to": {"currency": "USD","total": 990.58},"factor": 0.0002600630086636913},"authorization": "999999","reference": "800166551","receipt": "230192","franchise": "ID_DN","refunded": false,"processorFields": [{"keyword": "merchantCode","value": "1065152","displayOn": "none"},{"keyword": "terminalNumber","value": "00990099","displayOn": "none"},{"keyword": "credit","value": {"code": 1,"type": "03","groupCode": "X","installments": 9},"displayOn": "none"},{"keyword": "totalAmount","value": 3809000.0,"displayOn": "none"},{"keyword": "interestAmount","value": 0,"displayOn": "none"},{"keyword": "installmentAmount","value": 423205.13,"displayOn": "none"},{"keyword": "iceAmount","value": 0,"displayOn": "none"},{"keyword": "bin","value": "365454","displayOn": "none"},{"keyword": "expiration","value": "1122","displayOn": "none"},{"keyword": "lastDigits","value": "0008","displayOn": "none"}]}],"subscription": null}';
145+
break;
143146
default:
144147
$response = '{"status":{"status":"FAILED","reason":0,"message":"No existe la sesi\u00f3n que busca","date":"' . date('c') . '"}}';
145148
}

0 commit comments

Comments
 (0)