Skip to content

Commit

Permalink
fixed code via "PHP Coding Standards Fixer". Thanks @fabpot
Browse files Browse the repository at this point in the history
  • Loading branch information
cystbear committed Feb 15, 2013
1 parent 7498630 commit 78cf743
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 90 deletions.
2 changes: 1 addition & 1 deletion src/AuthorizeNet/Common/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ abstract protected function _getPostUrl();
/**
* Constructor.
*
* @param string $api_login_id The Merchant's API Login ID.
* @param string $api_login_id The Merchant's API Login ID.
* @param string $transaction_key The Merchant's Transaction Key.
*/
public function __construct($api_login_id = false, $transaction_key = false)
Expand Down
1 change: 0 additions & 1 deletion src/AuthorizeNet/Common/Type/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,3 @@ public function getXml()
return $xml_clean;
}
}

8 changes: 4 additions & 4 deletions src/AuthorizeNet/Common/Type/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@ class Transaction

public function __construct()
{
$this->tax = (object)array();
$this->tax = (object) array();
$this->tax->amount = "";
$this->tax->name = "";
$this->tax->description = "";

$this->shipping = (object)array();
$this->shipping = (object) array();
$this->shipping->amount = "";
$this->shipping->name = "";
$this->shipping->description = "";

$this->duty = (object)array();
$this->duty = (object) array();
$this->duty->amount = "";
$this->duty->name = "";
$this->duty->description = "";

// line items

$this->order = (object)array();
$this->order = (object) array();
$this->order->invoiceNumber = "";
$this->order->description = "";
$this->order->purchaseOrderNumber = "";
Expand Down
1 change: 1 addition & 0 deletions src/AuthorizeNet/Common/XmlResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ protected function _getElementContents($elementName)
} else {
$start_position = strpos($this->response, $start)+strlen($start);
$end_position = strpos($this->response, $end);

return substr($this->response, $start_position, $end_position-$start_position);
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/AuthorizeNet/Service/Aim/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public function authorizeAndCapture($amount = false, $card_num = false, $exp_dat
($card_num ? $this->card_num = $card_num : null);
($exp_date ? $this->exp_date = $exp_date : null);
$this->type = "AUTH_CAPTURE";

return $this->_sendRequest();
}

Expand All @@ -109,6 +110,7 @@ public function priorAuthCapture($trans_id = false, $amount = false)
($trans_id ? $this->trans_id = $trans_id : null);
($amount ? $this->amount = $amount : null);
$this->type = "PRIOR_AUTH_CAPTURE";

return $this->_sendRequest();
}

Expand All @@ -129,6 +131,7 @@ public function authorizeOnly($amount = false, $card_num = false, $exp_date = fa
($card_num ? $this->card_num = $card_num : null);
($exp_date ? $this->exp_date = $exp_date : null);
$this->type = "AUTH_ONLY";

return $this->_sendRequest();
}

Expand All @@ -146,6 +149,7 @@ public function void($trans_id = false)
{
($trans_id ? $this->trans_id = $trans_id : null);
$this->type = "VOID";

return $this->_sendRequest();
}

Expand All @@ -168,6 +172,7 @@ public function captureOnly($auth_code = false, $amount = false, $card_num = fal
($card_num ? $this->card_num = $card_num : null);
($exp_date ? $this->exp_date = $exp_date : null);
$this->type = "CAPTURE_ONLY";

return $this->_sendRequest();
}

Expand All @@ -188,6 +193,7 @@ public function credit($trans_id = false, $amount = false, $card_num = false)
($amount ? $this->amount = $amount : null);
($card_num ? $this->card_num = $card_num : null);
$this->type = "CREDIT";

return $this->_sendRequest();
}

Expand All @@ -214,7 +220,7 @@ public function __set($name, $value)
*/
public function setFields($fields)
{
$array = (array)$fields;
$array = (array) $fields;
foreach ($array as $key => $value) {
$this->setField($key, $value);
}
Expand All @@ -227,7 +233,7 @@ public function setFields($fields)
*/
public function setCustomFields($fields)
{
$array = (array)$fields;
$array = (array) $fields;
foreach ($array as $key => $value) {
$this->setCustomField($key, $value);
}
Expand Down
3 changes: 1 addition & 2 deletions src/AuthorizeNet/Service/Aim/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ public function __construct($response, $delimiter, $encap_char, $custom_fields)
$this->approved = false;
$this->error = true;
$this->error_message = "Unrecognized response from AuthorizeNet: $response";

return;
}



// Set all fields
$this->response_code = $this->_response_array[0];
$this->response_subcode = $this->_response_array[1];
Expand Down
4 changes: 4 additions & 0 deletions src/AuthorizeNet/Service/Arb/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function createSubscription(Subscription $subscription)
{
$this->_request_type = "CreateSubscriptionRequest";
$this->_request_payload .= $subscription->getXml();

return $this->_sendRequest();
}

Expand All @@ -65,6 +66,7 @@ public function updateSubscription($subscriptionId, Subscription $subscription)
$this->_request_type = "UpdateSubscriptionRequest";
$this->_request_payload .= "<subscriptionId>$subscriptionId</subscriptionId>";
$this->_request_payload .= $subscription->getXml();

return $this->_sendRequest();
}

Expand All @@ -79,6 +81,7 @@ public function getSubscriptionStatus($subscriptionId)
{
$this->_request_type = "GetSubscriptionStatusRequest";
$this->_request_payload .= "<subscriptionId>$subscriptionId</subscriptionId>";

return $this->_sendRequest();
}

Expand All @@ -93,6 +96,7 @@ public function cancelSubscription($subscriptionId)
{
$this->_request_type = "CancelSubscriptionRequest";
$this->_request_payload .= "<subscriptionId>$subscriptionId</subscriptionId>";

return $this->_sendRequest();
}

Expand Down
55 changes: 36 additions & 19 deletions src/AuthorizeNet/Service/Cim/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function createCustomerProfile($customerProfile, $validationMode = "none"
$this->_constructXml("createCustomerProfileRequest");
$profile = $this->_xml->addChild("profile");
$this->_addObject($profile, $customerProfile);

return $this->_sendRequest();
}

Expand All @@ -80,14 +81,15 @@ public function createCustomerPaymentProfile($customerProfileId, $paymentProfile
$this->_xml->addChild("customerProfileId", $customerProfileId);
$profile = $this->_xml->addChild("paymentProfile");
$this->_addObject($profile, $paymentProfile);

return $this->_sendRequest();
}

/**
* Create a shipping address.
*
* @param int $customerProfileId
* @param AuthorizeNetAddress $shippingAddress
* @param int $customerProfileId
* @param AuthorizeNetAddress $shippingAddress
*
* @return AuthorizeNetCIM_Response
*/
Expand All @@ -97,15 +99,16 @@ public function createCustomerShippingAddress($customerProfileId, $shippingAddre
$this->_xml->addChild("customerProfileId", $customerProfileId);
$address = $this->_xml->addChild("address");
$this->_addObject($address, $shippingAddress);

return $this->_sendRequest();
}

/**
* Create a transaction.
*
* @param string $transactionType
* @param AuthorizeNetTransaction $transaction
* @param string $extraOptionsString
* @param string $transactionType
* @param AuthorizeNetTransaction $transaction
* @param string $extraOptionsString
*
* @return AuthorizeNetCIM_Response
*/
Expand All @@ -116,6 +119,7 @@ public function createCustomerProfileTransaction($transactionType, $transaction,
$transactionChild = $transactionParent->addChild("profileTrans" . $transactionType);
$this->_addObject($transactionChild, $transaction);
$this->_extraOptions = $extraOptionsString;

return $this->_sendRequest();
}

Expand All @@ -130,6 +134,7 @@ public function deleteCustomerProfile($customerProfileId)
{
$this->_constructXml("deleteCustomerProfileRequest");
$this->_xml->addChild("customerProfileId", $customerProfileId);

return $this->_sendRequest();
}

Expand All @@ -146,6 +151,7 @@ public function deleteCustomerPaymentProfile($customerProfileId, $customerPaymen
$this->_constructXml("deleteCustomerPaymentProfileRequest");
$this->_xml->addChild("customerProfileId", $customerProfileId);
$this->_xml->addChild("customerPaymentProfileId", $customerPaymentProfileId);

return $this->_sendRequest();
}

Expand All @@ -162,6 +168,7 @@ public function deleteCustomerShippingAddress($customerProfileId, $customerAddre
$this->_constructXml("deleteCustomerShippingAddressRequest");
$this->_xml->addChild("customerProfileId", $customerProfileId);
$this->_xml->addChild("customerAddressId", $customerAddressId);

return $this->_sendRequest();
}

Expand All @@ -173,6 +180,7 @@ public function deleteCustomerShippingAddress($customerProfileId, $customerAddre
public function getCustomerProfileIds()
{
$this->_constructXml("getCustomerProfileIdsRequest");

return $this->_sendRequest();
}

Expand All @@ -187,6 +195,7 @@ public function getCustomerProfile($customerProfileId)
{
$this->_constructXml("getCustomerProfileRequest");
$this->_xml->addChild("customerProfileId", $customerProfileId);

return $this->_sendRequest();
}

Expand All @@ -203,6 +212,7 @@ public function getCustomerPaymentProfile($customerProfileId, $customerPaymentPr
$this->_constructXml("getCustomerPaymentProfileRequest");
$this->_xml->addChild("customerProfileId", $customerProfileId);
$this->_xml->addChild("customerPaymentProfileId", $customerPaymentProfileId);

return $this->_sendRequest();
}

Expand All @@ -219,14 +229,15 @@ public function getCustomerShippingAddress($customerProfileId, $customerAddressI
$this->_constructXml("getCustomerShippingAddressRequest");
$this->_xml->addChild("customerProfileId", $customerProfileId);
$this->_xml->addChild("customerAddressId", $customerAddressId);

return $this->_sendRequest();
}

/**
* Update a profile.
*
* @param int $customerProfileId
* @param AuthorizeNetCustomer $customerProfile
* @param int $customerProfileId
* @param AuthorizeNetCustomer $customerProfile
*
* @return AuthorizeNetCIM_Response
*/
Expand All @@ -236,6 +247,7 @@ public function updateCustomerProfile($customerProfileId, $customerProfile)
$customerProfile->customerProfileId = $customerProfileId;
$profile = $this->_xml->addChild("profile");
$this->_addObject($profile, $customerProfile);

return $this->_sendRequest();
}

Expand All @@ -257,15 +269,16 @@ public function updateCustomerPaymentProfile($customerProfileId, $customerPaymen
$paymentProfile->customerPaymentProfileId = $customerPaymentProfileId;
$profile = $this->_xml->addChild("paymentProfile");
$this->_addObject($profile, $paymentProfile);

return $this->_sendRequest();
}

/**
* Update a shipping address.
*
* @param int $customerProfileId
* @param int $customerShippingAddressId
* @param AuthorizeNetAddress $shippingAddress
* @param int $customerProfileId
* @param int $customerShippingAddressId
* @param AuthorizeNetAddress $shippingAddress
*
* @return AuthorizeNetCIM_Response
*/
Expand All @@ -277,14 +290,15 @@ public function updateCustomerShippingAddress($customerProfileId, $customerShipp
$shippingAddress->customerAddressId = $customerShippingAddressId;
$sa = $this->_xml->addChild("address");
$this->_addObject($sa, $shippingAddress);

return $this->_sendRequest();
}

/**
* Update the status of an existing order that contains multiple transactions with the same splitTenderId.
*
* @param int $splitTenderId
* @param string $splitTenderStatus
* @param int $splitTenderId
* @param string $splitTenderStatus
*
* @return AuthorizeNetCIM_Response
*/
Expand All @@ -293,17 +307,18 @@ public function updateSplitTenderGroup($splitTenderId, $splitTenderStatus)
$this->_constructXml("updateSplitTenderGroupRequest");
$this->_xml->addChild("splitTenderId", $splitTenderId);
$this->_xml->addChild("splitTenderStatus", $splitTenderStatus);

return $this->_sendRequest();
}

/**
* Validate a customer payment profile.
*
* @param int $customerProfileId
* @param int $customerPaymentProfileId
* @param int $customerShippingAddressId
* @param int $cardCode
* @param string $validationMode
* @param int $customerProfileId
* @param int $customerPaymentProfileId
* @param int $customerShippingAddressId
* @param int $cardCode
* @param string $validationMode
*
* @return AuthorizeNetCIM_Response
*/
Expand All @@ -315,6 +330,7 @@ public function validateCustomerPaymentProfile($customerProfileId, $customerPaym
$this->_xml->addChild("customerPaymentProfileId",$customerPaymentProfileId);
$this->_xml->addChild("customerShippingAddressId",$customerShippingAddressId);
$this->_xml->addChild("cardCode",$cardCode);

return $this->_sendRequest();
}

Expand Down Expand Up @@ -380,7 +396,7 @@ private function _constructXml($request_type)
*/
private function _addObject($destination, $object)
{
$array = (array)$object;
$array = (array) $object;
foreach ($array as $key => $value) {
if ($value && !is_object($value)) {
if (is_array($value) && count($value)) {
Expand All @@ -407,7 +423,7 @@ private function _addObject($destination, $object)
*/
private static function _notEmpty($object)
{
$array = (array)$object;
$array = (array) $object;
foreach ($array as $key => $value) {
if ($value && !is_object($value)) {
return true;
Expand All @@ -417,6 +433,7 @@ private static function _notEmpty($object)
}
}
}

return false;
}
}
Loading

0 comments on commit 78cf743

Please sign in to comment.