diff --git a/.gitignore b/.gitignore index 0d77fdb3..2ce2f7e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /vendor -composer.lock -composer.phar -phpunit.xml -.idea +/composer.lock +/composer.phar +/phpunit.xml +/.idea +/.DS_Store diff --git a/src/CIMGateway.php b/src/CIMGateway.php index b515f5b2..462a2c3c 100644 --- a/src/CIMGateway.php +++ b/src/CIMGateway.php @@ -51,6 +51,11 @@ public function getPaymentProfile(array $parameters = array()) return $this->createRequest('\Omnipay\AuthorizeNet\Message\CIMGetPaymentProfileRequest', $parameters); } + public function updateCard(array $parameters = array()) + { + return $this->createRequest('\Omnipay\AuthorizeNet\Message\CIMUpdatePaymentProfileRequest', $parameters); + } + public function deleteCard(array $parameters = array()) { return $this->createRequest('\Omnipay\AuthorizeNet\Message\CIMDeletePaymentProfileRequest', $parameters); diff --git a/src/Message/AIMVoidRequest.php b/src/Message/AIMVoidRequest.php index 39abb6d8..da815929 100644 --- a/src/Message/AIMVoidRequest.php +++ b/src/Message/AIMVoidRequest.php @@ -14,7 +14,7 @@ public function getData() $this->validate('transactionReference'); $data = $this->getBaseData(); - $data->transactionRequest->refTransId = $this->getTransactionReference()->getTransId(); + $data->transactionRequest->refTransId = $this->getTransactionReference(); $this->addTransactionSettings($data); return $data; diff --git a/src/Message/CIMAuthorizeRequest.php b/src/Message/CIMAuthorizeRequest.php index d39fb972..d391283a 100644 --- a/src/Message/CIMAuthorizeRequest.php +++ b/src/Message/CIMAuthorizeRequest.php @@ -18,9 +18,7 @@ protected function addPayment(\SimpleXMLElement $data) /** @var CardReference $cardRef */ $cardRef = $this->getCardReference(false); - $req->profile->customerProfileId = $cardRef->getCustomerProfileId(); - $req->profile->paymentProfile->paymentProfileId = $cardRef->getPaymentProfileId(); if ($shippingProfileId = $cardRef->getShippingProfileId()) { diff --git a/src/Message/CIMCreateCardRequest.php b/src/Message/CIMCreateCardRequest.php index 81fa4b37..61fd88fa 100644 --- a/src/Message/CIMCreateCardRequest.php +++ b/src/Message/CIMCreateCardRequest.php @@ -74,17 +74,42 @@ protected function addBillingData(\SimpleXMLElement $data) /** @var CreditCard $card */ if ($card = $this->getCard()) { $req = $data->addChild('billTo'); + // A card is present, so include billing details - $req->firstName = $card->getBillingFirstName(); - $req->lastName = $card->getBillingLastName(); - $req->company = $card->getBillingCompany(); - $req->address = trim($card->getBillingAddress1() . " \n" . $card->getBillingAddress2()); - $req->city = $card->getBillingCity(); - $req->state = $card->getBillingState(); - $req->zip = $card->getBillingPostcode(); - $req->country = $card->getBillingCountry(); + if ($card->getBillingFirstName()) { + $req->firstName = $card->getBillingFirstName(); + } + + if ($card->getBillingLastName()) { + $req->lastName = $card->getBillingLastName(); + } + + if ($card->getBillingCompany()) { + $req->company = $card->getBillingCompany(); + } + + if ($card->getBillingAddress1()) { + $req->address = trim($card->getBillingAddress1() . " \n" . $card->getBillingAddress2()); + } + + if ($card->getBillingCity()) { + $req->city = $card->getBillingCity(); + } + + if ($card->getBillingState()) { + $req->state = $card->getBillingState(); + } + + if ($card->getBillingPostcode()) { + $req->zip = $card->getBillingPostcode(); + } + + if ($card->getBillingCountry()) { + $req->country = $card->getBillingCountry(); + } $defaultBillTo = $this->getParameter('defaultBillTo'); + if (is_array($defaultBillTo)) { // A configuration parameter to populate billTo has been specified foreach ($defaultBillTo as $field => $value) { diff --git a/src/Message/CIMDeletePaymentProfileRequest.php b/src/Message/CIMDeletePaymentProfileRequest.php index 4b30ac10..1d36e111 100644 --- a/src/Message/CIMDeletePaymentProfileRequest.php +++ b/src/Message/CIMDeletePaymentProfileRequest.php @@ -11,6 +11,10 @@ class CIMDeletePaymentProfileRequest extends CIMAbstractRequest public function getData() { + $cardRef = $this->getCardReference(false); + $this->setCustomerProfileId($cardRef->getCustomerProfileId()); + $this->setCustomerPaymentProfileId($cardRef->getPaymentProfileId()); + $this->validate('customerProfileId', 'customerPaymentProfileId'); $data = $this->getBaseData(); diff --git a/src/Message/CIMUpdatePaymentProfileRequest.php b/src/Message/CIMUpdatePaymentProfileRequest.php index 37a7e1a9..a858d3e8 100644 --- a/src/Message/CIMUpdatePaymentProfileRequest.php +++ b/src/Message/CIMUpdatePaymentProfileRequest.php @@ -13,6 +13,19 @@ class CIMUpdatePaymentProfileRequest extends CIMCreatePaymentProfileRequest public function getData() { + $cardReference = $this->getCardReference(false); + + // If the customer profile and the cusromer payment profile is NOT + // already set directly, then pull both these from the car reference object. + + if (! $this->getCustomerProfileId()) { + $this->setCustomerProfileId($cardReference->getCustomerProfileId()); + } + + if (! $this->getCustomerPaymentProfileId()) { + $this->setCustomerPaymentProfileId($cardReference->getPaymentProfileId()); + } + $this->validate('card', 'customerProfileId', 'customerPaymentProfileId'); /** @var CreditCard $card */