Skip to content
This repository was archived by the owner on May 4, 2020. It is now read-only.

Commit d1dc070

Browse files
authored
Merge pull request #20 from Estigy/dev-master
Update BasketItem and Basket fields to new wirecard specs
2 parents d019a00 + bde651f commit d1dc070

File tree

4 files changed

+118
-41
lines changed

4 files changed

+118
-41
lines changed

src/Model/Common/Basket.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Basket extends Model
1616
*/
1717
function setAmount($amount)
1818
{
19-
return $this->addParam('basketAmount', $amount);
19+
return $this->addParam('amount', $amount);
2020
}
2121

2222
/**
@@ -26,7 +26,7 @@ function setAmount($amount)
2626
*/
2727
function getAmount()
2828
{
29-
return $this->getParam('basketAmount');
29+
return $this->getParam('amount');
3030
}
3131

3232
/**
@@ -37,7 +37,7 @@ function getAmount()
3737
*/
3838
function setCurrency($currency)
3939
{
40-
return $this->addParam('basketCurrency', $currency);
40+
return $this->addParam('currency', $currency);
4141
}
4242

4343
/**
@@ -47,7 +47,7 @@ function setCurrency($currency)
4747
*/
4848
function getCurrency()
4949
{
50-
return $this->getParam('basketCurrency');
50+
return $this->getParam('currency');
5151
}
5252

5353
/**

src/Model/Common/BasketItem.php

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,25 @@ function getArticleNumber()
2525
return $this->getParam('articleNumber');
2626
}
2727

28+
/**
29+
* Set the item's name
30+
*
31+
* @param string $name
32+
* @return BasketItem
33+
*/
34+
function setName($name)
35+
{
36+
return $this->addParam('name', $name);
37+
}
38+
39+
/**
40+
* @return string
41+
*/
42+
function getName()
43+
{
44+
return $this->getParam('name');
45+
}
46+
2847
/**
2948
* Set the item description, typically a product name
3049
*
@@ -64,40 +83,78 @@ function getQuantity()
6483
}
6584

6685
/**
67-
* Set item tax amount as string, formatted as float, e.g. "12.50"
86+
* Set item tax amount as string, formatted as float, e.g. "2.50"
87+
*
88+
* @param string $amount
89+
* @return BasketItem
90+
*/
91+
function setUnitTaxAmount($amount)
92+
{
93+
return $this->addParam('unitTaxAmount', $amount);
94+
}
95+
96+
/**
97+
* @return string
98+
*/
99+
function getUnitTaxAmount()
100+
{
101+
return $this->getParam('unitTaxAmount');
102+
}
103+
104+
/**
105+
* Set item tax rate as string, formatted as float, e.g. "25"
106+
*
107+
* @param string $rate
108+
* @return BasketItem
109+
*/
110+
function setUnitTaxRate($rate)
111+
{
112+
return $this->addParam('unitTaxRate', $rate);
113+
}
114+
115+
/**
116+
* @return string
117+
*/
118+
function getUnitTaxRate()
119+
{
120+
return $this->getParam('unitTaxRate');
121+
}
122+
123+
/**
124+
* Set item gross amount as string, formatted as float, e.g. "12.50"
68125
*
69126
* @param string $amount
70127
* @return BasketItem
71128
*/
72-
function setTax($amount)
129+
function setUnitGrossAmount($amount)
73130
{
74-
return $this->addParam('tax', $amount);
131+
return $this->addParam('unitGrossAmount', $amount);
75132
}
76133

77134
/**
78135
* @return string
79136
*/
80-
function getTax()
137+
function getUnitGrossAmount()
81138
{
82-
return $this->getParam('tax');
139+
return $this->getParam('unitGrossAmount');
83140
}
84141

85142
/**
86-
* Set item cost as string, formatted as float, e.g. "12.50"
143+
* Set item net amount as string, formatted as float, e.g. "10.00"
87144
*
88145
* @param string $amount
89146
* @return BasketItem
90147
*/
91-
function setUnitPrice($amount)
148+
function setUnitNetAmount($amount)
92149
{
93-
return $this->addParam('unitPrice', $amount);
150+
return $this->addParam('unitNetAmount', $amount);
94151
}
95152

96153
/**
97154
* @return string
98155
*/
99-
function getUnitPrice()
156+
function getUnitNetAmount()
100157
{
101-
return $this->getParam('unitPrice');
158+
return $this->getParam('unitNetAmount');
102159
}
103160
}

tests/functional/Request/Seamless/Frontend/InitPaymentRequestTest.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,21 @@ public function testBasket()
4343
$basket->setCurrency('EUR');
4444
$basket->addItem((new BasketItem)
4545
->setArticleNumber('A001')
46-
->setDescription('Product A1')
46+
->setName('Product A1')
4747
->setQuantity(1)
48-
->setUnitPrice('10.00')
49-
->setTax('2.00')
48+
->setUnitGrossAmount('11.00')
49+
->setUnitNetAmount('10.00')
50+
->setUnitTaxAmount('1.00')
51+
->setUnitTaxRate('10')
5052
);
5153
$basket->addItem((new BasketItem)
5254
->setArticleNumber('SHIPPING')
53-
->setDescription('Shipping')
55+
->setName('Shipping')
5456
->setQuantity(1)
55-
->setUnitPrice('5.00')
56-
->setTax('1.00')
57+
->setUnitGrossAmount('5.00')
58+
->setUnitNetAmount('5.00')
59+
->setUnitTaxAmount('0')
60+
->setUnitTaxRate('0')
5761
);
5862

5963
$shippingInformation = (new ShippingInformation)

tests/unit/Common/BasketTest.php

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,66 @@ class BasketTest extends \PHPUnit_Framework_Testcase
1010
function test()
1111
{
1212
$basket = new Basket;
13-
$basket->setAmount(58);
13+
$basket->setAmount(110);
1414
$basket->setCurrency('EUR');
1515
$basket->addItem((new BasketItem)
1616
->setArticleNumber('A001')
17-
->setDescription('Product A1')
17+
->setName('Product A1')
18+
->setDescription('Desc for Product A1')
1819
->setQuantity(1)
19-
->setUnitPrice(10)
20-
->setTax(1)
20+
->setUnitGrossAmount(55)
21+
->setUnitNetAmount(50)
22+
->setUnitTaxAmount(5)
23+
->setUnitTaxRate(10)
2124
);
2225
$basket->addItem((new BasketItem)
2326
->setArticleNumber('A002')
24-
->setDescription('Product A2')
27+
->setName('Product A2')
28+
->setDescription('Desc for Product A2')
2529
->setQuantity(2)
26-
->setUnitPrice(20)
27-
->setTax(2)
30+
->setUnitGrossAmount(25)
31+
->setUnitNetAmount(20)
32+
->setUnitTaxAmount(5)
33+
->setUnitTaxRate(25)
2834
);
2935
$basket->addItem((new BasketItem)
3036
->setArticleNumber('S001')
31-
->setDescription('Shipping')
37+
->setName('Shipping')
3238
->setQuantity(1)
33-
->setUnitPrice(5)
34-
->setTax(0)
39+
->setUnitGrossAmount(5)
40+
->setUnitNetAmount(5)
41+
->setUnitTaxAmount(0)
42+
->setUnitTaxRate(0)
3543
);
3644

3745
$this->assertEquals(
3846
[
39-
'basketAmount' => 58,
40-
'basketCurrency' => 'EUR',
47+
'amount' => 110,
48+
'currency' => 'EUR',
4149
'basketItems' => 3,
4250
'basketItem1ArticleNumber' => 'A001',
43-
'basketItem1Description' => 'Product A1',
51+
'basketItem1Name' => 'Product A1',
52+
'basketItem1Description' => 'Desc for Product A1',
4453
'basketItem1Quantity' => 1,
45-
'basketItem1UnitPrice' => 10,
46-
'basketItem1Tax' => 1,
54+
'basketItem1UnitGrossAmount' => 55,
55+
'basketItem1UnitNetAmount' => 50,
56+
'basketItem1UnitTaxAmount' => 5,
57+
'basketItem1UnitTaxRate' => 10,
4758
'basketItem2ArticleNumber' => 'A002',
48-
'basketItem2Description' => 'Product A2',
59+
'basketItem2Name' => 'Product A2',
60+
'basketItem2Description' => 'Desc for Product A2',
4961
'basketItem2Quantity' => 2,
50-
'basketItem2UnitPrice' => 20,
51-
'basketItem2Tax' => 2,
62+
'basketItem2UnitGrossAmount' => 25,
63+
'basketItem2UnitNetAmount' => 20,
64+
'basketItem2UnitTaxAmount' => 5,
65+
'basketItem2UnitTaxRate' => 25,
5266
'basketItem3ArticleNumber' => 'S001',
53-
'basketItem3Description' => 'Shipping',
67+
'basketItem3Name' => 'Shipping',
5468
'basketItem3Quantity' => 1,
55-
'basketItem3UnitPrice' => 5,
56-
'basketItem3Tax' => 0,
69+
'basketItem3UnitGrossAmount' => 5,
70+
'basketItem3UnitNetAmount' => 5,
71+
'basketItem3UnitTaxAmount' => 0,
72+
'basketItem3UnitTaxRate' => 0,
5773
],
5874
$basket->toArray()
5975
);

0 commit comments

Comments
 (0)