Skip to content

Commit 20c6d33

Browse files
committed
added ECI as value object describing all possible values
1 parent 72eaefc commit 20c6d33

3 files changed

Lines changed: 57 additions & 41 deletions

File tree

lib/Ogone/DirectLink/DirectLinkPaymentRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public function setAlias(Alias $alias)
6464
$this->parameters['alias'] = $alias->__toString();
6565
}
6666

67-
public function setAsRecurrentPayment()
67+
public function setEci(Eci $eci)
6868
{
69-
$this->parameters['eci'] = 9;
69+
$this->parameters['eci'] = (string) $eci;
7070
}
7171
}

lib/Ogone/DirectLink/Eci.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace Ogone\DirectLink;
4+
5+
/**
6+
* Class Eci
7+
*
8+
* Electronic Commerce Indicator. The ECI indicates the security level at which the payment information is processed between the cardholder and merchant.
9+
* A default ECI value can be set in the Technical Information page. An ECI value sent along in the transaction, will overwrite the default ECI value.
10+
* It is the merchant's responsibility to give correct ECI values for the transactions. For e-Commerce, our system sets ECI value 5, 6 or 7 depending on the 3-D Secure authentication result.
11+
*/
12+
class Eci
13+
{
14+
/** The merchant took the customer's credit card and swiped it through a machine that read the magnetic strip data of the card. */
15+
const SWIPED = 0;
16+
17+
/** The merchant received the customer's financial details over the phone or via fax/mail, but does not have the customer's card at hand. */
18+
const MANUALLY_KEYED = 1;
19+
20+
/** The customer's first transaction was a Mail Order / Telephone Order transaction, i.e. the customer gave his financial details over the phone or via mail/fax to the merchant. The merchant either stored the details himself or had these details stored in our system using an Alias and is performing another transaction for the same customer (recurring transaction). */
21+
const RECURRENT_MOTO = 2;
22+
23+
/** Partial payment of goods/services that have already been delivered, but will be paid for in several spread payments. */
24+
const INSTALLMENT_PAYMENTS = 3;
25+
26+
/** The customer is physically present in front of the merchant. The merchant has the customer's card at hand. The card details are manually entered, the card is not swiped through a machine. */
27+
const MANUALLY_KEYED_CARD_PRESENT = 4;
28+
29+
/** The cardholder's 3-D Secure identification was successful, i.e. there was a full authentication. (Full thumbs up) */
30+
const CARDHOLDER_IDENTIFICATION_SUCCESSFUL = 5;
31+
32+
/** Merchant supports identification but not cardholder, The merchant has a 3-D Secure contract, but the cardholder's card is not 3-D Secure or is 3-D Secure but the cardholder is not yet in possession of the PIN (Half thumbs up). Conditional payment guarantee rules apply. */
33+
const MERCHANT_IDENTIFICATION_3DSECURE = 6;
34+
35+
/** The merchant received the customer's financial details via a secure (SSL encrypted) website (either the merchant's website or our secure platform). */
36+
const ECOMMERCE_WITH_SSL = 7;
37+
38+
/** The customer's first transaction was an e-Commerce transaction, i.e. the customer entered his financial details himself on a secure website (either the merchant's website or our secure platform). The merchant either stored the details himself or had these details stored in our system using an Alias and is now performing another transaction for the same customer (recurring transaction), using the Alias details. */
39+
const ECOMMERCE_RECURRING = 9;
40+
41+
/** @var int */
42+
protected $code;
43+
44+
public function __construct($eciCode)
45+
{
46+
$this->code = $eciCode;
47+
}
48+
49+
public function __toString()
50+
{
51+
return (string) $this->code;
52+
}
53+
}

tests/Ogone/Tests/OgoneTest.php

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespace Ogone\Tests;
1212

1313
use Guzzle\Http\Client;
14+
use Ogone\DirectLink\Eci;
1415
use Ogone\Passphrase;
1516
use Ogone\DirectLink\Alias;
1617
use Ogone\DirectLink\CreateAliasRequest;
@@ -62,6 +63,7 @@ public function DirectLinkPaymentIsSuccessful($alias)
6263
$directLinkRequest->setAlias($alias);
6364
$directLinkRequest->setAmount(100);
6465
$directLinkRequest->setCurrency('EUR');
66+
$directLinkRequest->setEci(new Eci(Eci::ECOMMERCE_RECURRING));
6567
$directLinkRequest->validate();
6668

6769
$body = array();
@@ -82,45 +84,6 @@ public function DirectLinkPaymentIsSuccessful($alias)
8284
return $alias;
8385
}
8486

85-
/**
86-
* @test
87-
* @depends DirectLinkPaymentIsSuccessful
88-
*/
89-
public function DirectLinkRecurrentPaymentIsSuccessful($alias)
90-
{
91-
$passphrase = new Passphrase(PASSPHRASE_SHA_IN);
92-
$shaComposer = new AllParametersShaComposer($passphrase);
93-
$directLinkRequest = new DirectLinkPaymentRequest($shaComposer);
94-
95-
$orderId = uniqid('order_'); // create a unique order id
96-
$directLinkRequest->setOrderid($orderId);
97-
98-
$alias = new Alias($alias);
99-
$directLinkRequest->setPspid(PSPID);
100-
$directLinkRequest->setUserId(USERID);
101-
$directLinkRequest->setPassword(PASSWORD);
102-
$directLinkRequest->setAlias($alias);
103-
$directLinkRequest->setAmount(100);
104-
$directLinkRequest->setCurrency('EUR');
105-
$directLinkRequest->setAsRecurrentPayment();
106-
$directLinkRequest->validate();
107-
108-
$body = array();
109-
foreach($directLinkRequest->toArray() as $key => $value) {
110-
$body[strtoupper($key)] = $value;
111-
}
112-
113-
$body['SHASIGN'] = $directLinkRequest->getShaSign();
114-
115-
$client = new Client($directLinkRequest->getOgoneUri());
116-
$request = $client->post(null, null, $body);
117-
$response = $request->send();
118-
119-
$directLinkResponse = new DirectLinkPaymentResponse($response->getBody(true));
120-
121-
$this->assertTrue($directLinkResponse->isSuccessful());
122-
}
123-
12487
/**
12588
* @test
12689
*/

0 commit comments

Comments
 (0)