Skip to content

Commit 0908a1e

Browse files
committed
Merge pull request #114 from steveneaston/master
SagePay uses shorthand type names for Mastercard and Diners Club
2 parents bab644e + 2315304 commit 0908a1e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Omnipay/SagePay/Message/DirectAuthorizeRequest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,23 @@ public function getData()
6262
$data = $this->getBaseAuthorizeData();
6363
$this->getCard()->validate();
6464

65+
$cardType = $this->getCard()->getBrand();
66+
67+
// list of brands SagePay names differently
68+
$brands = array(
69+
'mastercard' => 'mc',
70+
'diners_club' => 'dc'
71+
);
72+
73+
if (isset($brands[$cardType])) {
74+
$cardType = $brands[$cardType];
75+
}
76+
6577
$data['CardHolder'] = $this->getCard()->getName();
6678
$data['CardNumber'] = $this->getCard()->getNumber();
6779
$data['CV2'] = $this->getCard()->getCvv();
6880
$data['ExpiryDate'] = $this->getCard()->getExpiryDate('my');
69-
$data['CardType'] = $this->getCard()->getBrand();
81+
$data['CardType'] = $cardType;
7082

7183
if ($this->getCard()->getStartMonth() and $this->getCard()->getStartYear()) {
7284
$data['StartDate'] = $this->getCard()->getStartDate('my');

0 commit comments

Comments
 (0)