Skip to content

Commit 0cdfc85

Browse files
author
fre-sund
committed
Merge remote-tracking branch 'origin/develop'
2 parents 980d032 + d25d3e3 commit 0cdfc85

File tree

9 files changed

+80
-4
lines changed

9 files changed

+80
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,8 @@ $order = WebPay::checkout($config)
16411641
->setPushUri("https://svea.com/push.aspx?sid=123&svea_order=123") // required Merchant settings (push uri)
16421642
->setTermsUri("http://localhost:51898/terms") // required Merchant settings (terms uri)
16431643
->setValidationCallbackUri('http://localhost:51898/validation-callback') // optional Merchant settings (validation uri)
1644-
->setPartnerKey('77FB33EC-505D-4CCF-AA21-D9DF50DC8344') // optional GUID for partners to Svea, leave blank if you're unsure what this does
1644+
->setPartnerKey('77FB33EC-505D-4CCF-AA21-D9DF50DC8344') // optional GUID for partners to Svea, leave blank if you're unsure what this does
1645+
->setRequireElectronicIdAuthentication(true) // optional, force electronic id authentication when customer finalizes order
16451646
->setLocale('sv-SE') // required for Svea Checkout
16461647
->createOrder() // Create new Checkout order
16471648
;

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sveaekonomi/webpay",
3-
"version": "3.12.1",
3+
"version": "3.13.0",
44
"description": "Php integration library for Svea Ekonomis payment methods",
55
"license": "Apache-2.0",
66
"authors": [

example/checkout/createCheckoutOrder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
//->setValidationCallbackUri('http://localhost:51898/validation-callback')
3333
//->setPartnerKey("77FB33EC-505D-4CCF-AA21-D9DF50DC8344")
3434
//->setMerchantData("merchantData")
35+
//->setRequireElectronicIdAuthentication(true)
3536
->setLocale($locale);
3637

3738
$presetPhoneNumber = WebPayItem::presetValue()

src/Checkout/CheckoutOrderEntry.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,16 @@ public function setMerchantData($merchantData)
301301
$this->checkoutOrderBuilder->setMerchantData($merchantData);
302302
return $this;
303303
}
304+
305+
/**
306+
* Enable/disable electronic id authentication when end-customer finalizes order, default = false
307+
*
308+
* @param bool $enabled
309+
* @return $this
310+
*/
311+
public function setRequireElectronicIdAuthentication($enabled)
312+
{
313+
$this->checkoutOrderBuilder->setRequireElectronicIdAuthentication($enabled);
314+
return $this;
315+
}
304316
}

src/Checkout/Helper/CheckoutOrderBuilder.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ class CheckoutOrderBuilder extends OrderBuilder
5555
*/
5656
protected $merchantData;
5757

58+
/**
59+
* @var bool $requireElectronicIdAuthentication
60+
*/
61+
protected $requireElectronicIdAuthentication;
62+
5863
/**
5964
* CheckoutOrderBuilder constructor.
6065
* @param \Svea\WebPay\Config\ConfigurationProvider $config
@@ -348,4 +353,22 @@ public function getMerchantData()
348353
{
349354
return $this->merchantData;
350355
}
356+
357+
/**
358+
* Enable electronic id authentication for end-user if set to true
359+
*
360+
* @param bool $enabled
361+
* @return $this
362+
*/
363+
public function setRequireElectronicIdAuthentication($enabled)
364+
{
365+
$this->requireElectronicIdAuthentication = $enabled;
366+
return $this;
367+
}
368+
369+
public function getRequireElectronicIdAuthentication()
370+
{
371+
return $this->requireElectronicIdAuthentication;
372+
}
373+
351374
}

src/Checkout/Service/CreateOrderService.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ protected function mapCreateOrderData(CheckoutOrderBuilder $order)
106106

107107
$data['merchantData'] = $order->getMerchantData();
108108

109+
if($order->getRequireElectronicIdAuthentication() != null)
110+
{
111+
$data['requireElectronicIdAuthentication'] = $order->getRequireElectronicIdAuthentication();
112+
}
113+
109114
return $data;
110115
}
111116
}

src/Checkout/Validation/CreateOrderValidator.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@ public function validate($order)
3535

3636
$errors = $this->validateIdentityFlags($order, $errors);
3737

38+
$errors = $this->validateRequireElectronicIdAuthentication($order, $errors);
39+
40+
return $errors;
41+
}
42+
43+
/**
44+
* @param CheckoutOrderBuilder $order
45+
* @param array $errors
46+
* @return array
47+
*/
48+
private function validateRequireElectronicIdAuthentication($order, $errors)
49+
{
50+
if($order->getRequireElectronicIdAuthentication() != null)
51+
{
52+
if(!is_bool($order->getRequireElectronicIdAuthentication()))
53+
{
54+
$errors['invalid type'] = "requireElectronicIdAuthentication field isn't a boolean type, use setRequireElectronicIdAuthentication(true)";
55+
}
56+
}
3857
return $errors;
3958
}
4059

test/UnitTest/Checkout/Validation/CreateOrderValidationTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Svea\WebPay\Test\UnitTest\Checkout\Validation;
44

55
use Svea\WebPay\BuildOrder\Validator\OrderValidator;
6+
use Svea\WebPay\BuildOrder\Validator\ValidationException;
67
use Svea\WebPay\Checkout\Helper\CheckoutOrderBuilder;
78
use Svea\WebPay\Checkout\Validation\CreateOrderValidator;
89
use Svea\WebPay\Test\UnitTest\Checkout\TestCase;
@@ -14,7 +15,7 @@
1415
class CreateOrderValidationTest extends TestCase
1516
{
1617
/**
17-
* @var \Svea\WebPay\BuildOrder\Validator\OrderValidator
18+
* @var OrderValidator
1819
*/
1920
protected $validator;
2021

@@ -122,4 +123,18 @@ public function ifPartnerKeyPassed()
122123

123124
$this->assertEquals(0, $errorsNum);
124125
}
126+
127+
/**
128+
* @test
129+
*/
130+
public function requireElectronicIdAuthenticationWrongType()
131+
{
132+
$this->order->setRequireElectronicIdAuthentication(true);
133+
134+
$errors = $this->invokeMethod($this->validator, 'validateRequireElectronicIdAuthentication', array($this->order, array()));
135+
136+
$errorsNum = count($errors);
137+
138+
$this->assertEquals(0, $errorsNum);
139+
}
125140
}

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "3.12.1"
2+
"version": "3.13.0"
33
}

0 commit comments

Comments
 (0)