From 9ed999ad8590a75b7c943e3bc9ece6f54d75e68e Mon Sep 17 00:00:00 2001 From: mar Date: Thu, 10 Nov 2016 10:51:22 -0700 Subject: [PATCH 1/5] Fixes deleteCard when only CardReference is supplied. --- .gitignore | 9 +++++---- src/Message/CIMDeletePaymentProfileRequest.php | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) 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/Message/CIMDeletePaymentProfileRequest.php b/src/Message/CIMDeletePaymentProfileRequest.php index 4b30ac10..959dca82 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(); From 578a0af85da1b07018b59eedd8d4f61068ded32b Mon Sep 17 00:00:00 2001 From: mar Date: Thu, 10 Nov 2016 14:24:50 -0700 Subject: [PATCH 2/5] adding support for updating card --- src/CIMGateway.php | 5 +++++ src/Message/CIMUpdatePaymentProfileRequest.php | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/CIMGateway.php b/src/CIMGateway.php index b515f5b2..f71f6a3d 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/CIMUpdatePaymentProfileRequest.php b/src/Message/CIMUpdatePaymentProfileRequest.php index 37a7e1a9..71f1cf86 100644 --- a/src/Message/CIMUpdatePaymentProfileRequest.php +++ b/src/Message/CIMUpdatePaymentProfileRequest.php @@ -13,6 +13,10 @@ class CIMUpdatePaymentProfileRequest extends CIMCreatePaymentProfileRequest public function getData() { + $cardReference = $this->getCardReference(false); + $this->setCustomerId($cardReference->getCustomerProfileId()); + $this->setCustomerPaymentProfileId($cardReference->getPaymentProfileId()); + $this->validate('card', 'customerProfileId', 'customerPaymentProfileId'); /** @var CreditCard $card */ From b143ace74e918cee0762d756e4b6386b56456ddd Mon Sep 17 00:00:00 2001 From: mar Date: Thu, 10 Nov 2016 14:39:28 -0700 Subject: [PATCH 3/5] adding support for updating card --- src/Message/CIMUpdatePaymentProfileRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Message/CIMUpdatePaymentProfileRequest.php b/src/Message/CIMUpdatePaymentProfileRequest.php index 71f1cf86..a80c3ca7 100644 --- a/src/Message/CIMUpdatePaymentProfileRequest.php +++ b/src/Message/CIMUpdatePaymentProfileRequest.php @@ -14,7 +14,7 @@ class CIMUpdatePaymentProfileRequest extends CIMCreatePaymentProfileRequest public function getData() { $cardReference = $this->getCardReference(false); - $this->setCustomerId($cardReference->getCustomerProfileId()); + $this->setCustomerProfileId($cardReference->getCustomerProfileId()); $this->setCustomerPaymentProfileId($cardReference->getPaymentProfileId()); $this->validate('card', 'customerProfileId', 'customerPaymentProfileId'); From b1c9ddd02517f57feb22e766a24a50528fbfc316 Mon Sep 17 00:00:00 2001 From: mar Date: Fri, 11 Nov 2016 18:09:15 -0700 Subject: [PATCH 4/5] adding support for updating card --- src/Message/AIMVoidRequest.php | 2 +- src/Message/CIMAuthorizeRequest.php | 2 -- src/Message/CIMCreateCardRequest.php | 32 +++++++++++++++++++++------- 3 files changed, 25 insertions(+), 11 deletions(-) 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 827e84da..cf145445 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 09ac180a..8eb28d6b 100644 --- a/src/Message/CIMCreateCardRequest.php +++ b/src/Message/CIMCreateCardRequest.php @@ -75,14 +75,30 @@ protected function addBillingData(\SimpleXMLElement $data) 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)) { From 9bf552a58b22f8fe4b8f01186fbb0c4b69426149 Mon Sep 17 00:00:00 2001 From: Jason Judge Date: Sun, 8 Oct 2017 17:16:23 +0100 Subject: [PATCH 5/5] PR #67 CS fixes --- src/CIMGateway.php | 8 +-- src/Message/CIMCreateCardRequest.php | 57 +++++++++++-------- .../CIMDeletePaymentProfileRequest.php | 6 +- .../CIMUpdatePaymentProfileRequest.php | 15 ++++- 4 files changed, 52 insertions(+), 34 deletions(-) diff --git a/src/CIMGateway.php b/src/CIMGateway.php index f71f6a3d..462a2c3c 100644 --- a/src/CIMGateway.php +++ b/src/CIMGateway.php @@ -51,10 +51,10 @@ 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 updateCard(array $parameters = array()) + { + return $this->createRequest('\Omnipay\AuthorizeNet\Message\CIMUpdatePaymentProfileRequest', $parameters); + } public function deleteCard(array $parameters = array()) { diff --git a/src/Message/CIMCreateCardRequest.php b/src/Message/CIMCreateCardRequest.php index 5d0797a0..61fd88fa 100644 --- a/src/Message/CIMCreateCardRequest.php +++ b/src/Message/CIMCreateCardRequest.php @@ -74,33 +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 - 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(); - } + 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 959dca82..1d36e111 100644 --- a/src/Message/CIMDeletePaymentProfileRequest.php +++ b/src/Message/CIMDeletePaymentProfileRequest.php @@ -11,9 +11,9 @@ class CIMDeletePaymentProfileRequest extends CIMAbstractRequest public function getData() { - $cardRef = $this->getCardReference(false); - $this->setCustomerProfileId($cardRef->getCustomerProfileId()); - $this->setCustomerPaymentProfileId($cardRef->getPaymentProfileId()); + $cardRef = $this->getCardReference(false); + $this->setCustomerProfileId($cardRef->getCustomerProfileId()); + $this->setCustomerPaymentProfileId($cardRef->getPaymentProfileId()); $this->validate('customerProfileId', 'customerPaymentProfileId'); diff --git a/src/Message/CIMUpdatePaymentProfileRequest.php b/src/Message/CIMUpdatePaymentProfileRequest.php index a80c3ca7..a858d3e8 100644 --- a/src/Message/CIMUpdatePaymentProfileRequest.php +++ b/src/Message/CIMUpdatePaymentProfileRequest.php @@ -13,9 +13,18 @@ class CIMUpdatePaymentProfileRequest extends CIMCreatePaymentProfileRequest public function getData() { - $cardReference = $this->getCardReference(false); - $this->setCustomerProfileId($cardReference->getCustomerProfileId()); - $this->setCustomerPaymentProfileId($cardReference->getPaymentProfileId()); + $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');