Skip to content

Commit 84b2c3f

Browse files
committed
Make CVV optional
1 parent 9344b3e commit 84b2c3f

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@
2424
"homepage": "https://github.com/thephpleague/omnipay-authorizenet/contributors"
2525
}
2626
],
27+
"repositories": [
28+
{
29+
"type": "vcs",
30+
"url": "https://github.com/xola/omnipay-common"
31+
}
32+
],
2733
"autoload": {
2834
"psr-4": { "Omnipay\\AuthorizeNet\\" : "src/" }
2935
},
3036
"require": {
31-
"omnipay/common": "~2.0"
37+
"omnipay/common": "~2.4.2"
3238
},
3339
"require-dev": {
3440
"omnipay/tests": "~2.0"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Message;
4+
5+
use Omnipay\AuthorizeNet\Message\CIMAbstractRequest;
6+
7+
abstract class CIMAbstractCustomerProfileRequest extends CIMAbstractRequest
8+
{
9+
const VALIDATION_MODE_TEST = 'testMode';
10+
const VALIDATION_MODE_LIVE = 'liveMode';
11+
const VALIDATION_MODE_NONE = 'none';
12+
13+
public function setValidationMode($value)
14+
{
15+
return $this->setParameter('validationMode', $value);
16+
}
17+
18+
public function getValidationMode()
19+
{
20+
$validationMode = $this->getParameter('validationMode');
21+
if($validationMode !== self::VALIDATION_MODE_NONE) {
22+
$validationMode = $this->getDeveloperMode() ? self::VALIDATION_MODE_TEST : self::VALIDATION_MODE_LIVE;
23+
}
24+
return $validationMode;
25+
}
26+
}

src/Message/CIMCreateCardRequest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
namespace Omnipay\AuthorizeNet\Message;
44

5+
use Message\CIMAbstractCustomerProfileRequest;
56
use Omnipay\Common\CreditCard;
67

78
/**
89
* Create Credit Card Request.
910
*/
10-
class CIMCreateCardRequest extends CIMAbstractRequest
11+
class CIMCreateCardRequest extends CIMAbstractCustomerProfileRequest
1112
{
1213
protected $xmlRootElement = 'createCustomerProfileRequest';
1314

@@ -103,7 +104,9 @@ protected function addBillingData(\SimpleXMLElement $data)
103104
$req = $data->addChild('payment');
104105
$req->creditCard->cardNumber = $card->getNumber();
105106
$req->creditCard->expirationDate = $card->getExpiryDate('Y-m');
106-
$req->creditCard->cardCode = $card->getCvv();
107+
if ($card->getCvv()) {
108+
$req->creditCard->cardCode = $card->getCvv();
109+
}
107110
}
108111
}
109112

@@ -145,8 +148,7 @@ protected function addShippingData(\SimpleXMLElement $data)
145148

146149
protected function addTestModeSetting(\SimpleXMLElement $data)
147150
{
148-
// Test mode setting
149-
$data->validationMode = $this->getDeveloperMode() ? 'testMode' : 'liveMode';
151+
$data->validationMode = $this->getValidationMode();
150152
}
151153

152154
public function sendData($data)

0 commit comments

Comments
 (0)