diff --git a/lib/AktiveMerchant/Billing/Gateways/Iridium.php b/lib/AktiveMerchant/Billing/Gateways/Iridium.php index 5ec38fc..7af6df2 100644 --- a/lib/AktiveMerchant/Billing/Gateways/Iridium.php +++ b/lib/AktiveMerchant/Billing/Gateways/Iridium.php @@ -4,30 +4,33 @@ namespace AktiveMerchant\Billing\Gateways; -use AktiveMerchant\Billing\Interfaces as Interfaces; use AktiveMerchant\Billing\Gateway; -use AktiveMerchant\Billing\CreditCard; use AktiveMerchant\Common\Options; -use AktiveMerchant\Billing\Response; -use Thapp\XmlBuilder\XmlBuilder; -use AktiveMerchant\Common\Address; -use AktiveMerchant\Billing\Gateways\Worldpay\XmlNormalizer; use AktiveMerchant\Common\Country; +use AktiveMerchant\Billing\Response; +use AktiveMerchant\Billing\CreditCard; +use AktiveMerchant\Common\SimpleXmlBuilder; +use AktiveMerchant\Billing\Interfaces as Interfaces; /** * Integration of Iridium gateway. * * @author Dimitris Giannakakis + * @author Andreas Kollaros * @license MIT License http://www.opensource.org/licenses/mit-license.php */ class Iridium extends Gateway implements Interfaces\Charge, Interfaces\Credit { - const TEST_URL = 'https://gw1.iridiumcorp.net/'; const LIVE_URL = 'https://gw1.iridiumcorp.net/'; - const DISPLAY_NAME = 'Iridium'; + + const PURCHASE = 'SALE'; + const AUTHORIZE = 'PREAUTH'; + const CAPTURE = 'COLLECTION'; + const CREDIT = 'REFUND'; + const VOID = 'VOID'; public static $money_format = 'cents'; @@ -53,13 +56,15 @@ class Iridium extends Gateway implements 'diners_club' ); - protected $soap; + protected $options; - protected $reply = array(); - - protected $success; - - protected $message; + private $soapCall = array( + self::PURCHASE => 'CardDetailsTransaction', + self::AUTHORIZE => 'CardDetailsTransaction', + self::CAPTURE => 'CrossReferenceTransaction', + self::CREDIT => 'CrossReferenceTransaction', + self::VOID => 'CrossReferenceTransaction', + ); /** * {@inheritdoc} @@ -77,8 +82,7 @@ class Iridium extends Gateway implements public static $default_currency = 'EUR'; - protected $SOAP_ATTRIBUTES = array ( - + protected $SOAP_ATTRIBUTES = array( 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema' @@ -88,324 +92,134 @@ public function __construct($options = array()) { $this->required_options('merchant_id, password', $options); - if (isset($options['currency'])) { - self::$default_currency = $options['currency']; - } - - $this->options = $options; - + parent::__construct($options); } public function authorize($money, CreditCard $creditcard, $options = array()) { $options = new Options($options); + $this->createXmlBuilder(self::AUTHORIZE); + $this->addTransactionDetails($money, self::AUTHORIZE, $options['order_id']); + $this->addCreditcard($creditcard); + $this->addCustomerDetails($options); - $this->setupAddressHash($options); - - if (isset($creditcard->number)) { - return $this->commit($this->buildPurchaseRequest('PREAUTH', $money, $creditcard, $options), $options); - } else { - return $this->commit($this->buildReferenceRequest('PREAUTH', $money, $creditcard, $options), $options); - } + return $this->commit(self::AUTHORIZE, $options); } public function purchase($money, CreditCard $creditcard, $options = array()) { $options = new Options($options); + $this->createXmlBuilder(self::PURCHASE); + $this->addTransactionDetails($money, self::PURCHASE, $options['order_id']); + $this->addCreditcard($creditcard); + $this->addCustomerDetails($options); - $this->setupAddressHash($options); - - if (isset($creditcard->number)) { - return $this->commit($this->buildPurchaseRequest('SALE', $money, $creditcard, $options), $options); - } else { - return $this->commit($this->buildReferenceRequest('SALE', $money, $creditcard, $options), $options); - } + return $this->commit(self::PURCHASE, $options); } public function capture($money, $authorization, $options = array()) { $options = new Options($options); + list($orderId, $crossReference, $authCode) = $this->splitAuthorization($authorization); - return $this->commit($this->buildReferenceRequest('COLLECTION', $money, $authorization, $options), $options); + $this->createXmlBuilder(self::CAPTURE); + $this->addTransactionDetails($money, self::CAPTURE, $options['order_id'] ?: $orderId, $crossReference); + + return $this->commit(self::CAPTURE, $options); } public function credit($money, $authorization, $options = array()) { $options = new Options($options); + list($orderId, $crossReference, $authCode) = $this->splitAuthorization($authorization); + + $this->createXmlBuilder(self::CREDIT); + $this->addTransactionDetails($money, self::CREDIT, $options['order_id'] ?: $orderId, $crossReference); - return $this->commit($this->buildReferenceRequest('REFUND', $money, $authorization, $options), $options); + return $this->commit(self::CREDIT, $options); } public function void($authorization, $options = array()) { $options = new Options($options); + list($orderId, $crossReference, $authCode) = $this->splitAuthorization($authorization); - return $this->commit($this->buildReferenceRequest('VOID', null, $authorization, $options), $options); + $this->createXmlBuilder(self::VOID); + $this->addTransactionDetails(0, self::VOID, $options['order_id'] ?: $orderId, $crossReference); + + return $this->commit(self::VOID, $options); } - private function commit($request, $options) + private function commit($action, Options $options) { $url = $this->isTest() ? self::TEST_URL : self::LIVE_URL; + $call = $this->soapCall[$action]; + $headers = array( 'headers' => array( 'Content-Type: text/xml; charset=utf-8;', - 'SOAPAction: https://www.thepaymentgateway.net/'.$options->action + 'SOAPAction: https://www.thepaymentgateway.net/'.$call ), 'request_timeout' => 10 ); - $data = $this->ssl_post($url, $request, $headers); + $data = $this->ssl_post($url, $this->xml->__toString(), $headers); - $this->parse($data); - - $test_mode = $this->isTest(); - $this->success = $this->reply['transaction_result']['StatusCode'] == "0"; - $this->message = $this->reply['transaction_result']['Message']; + $response = new Options($this->parse($data)); return new Response( - $this->success, - $this->message, - $this->reply, + $response['StatusCode'] == "0", + $response['Message'], + $response->getArrayCopy(), array( - - 'test' => $test_mode, - 'authorization' => $this->authorizationFrom($options), + 'test' => $this->isTest(), + 'authorization' => $this->authorizationFrom($response, $options), ) ); } - private function setupAddressHash(Options $options) - { - if ($options->billing_address) { - $adr = $options->billing_address; - } elseif ($options->address) { - $adr = $options->address; - } else { - $adr = null; - } - - $options->billing_address = $adr; - $options->shipping_address = ($options->shipping_address)? $options->shipping_address : null; - } - - private function buildPurchaseRequest( - $type, - $money, - CreditCard $creditcard, - $options - ) { - - $options->action ='CardDetailsTransaction'; - $this->buildRequest($options, $money, $type, $creditcard); - - return $this->builderSoapEnvelope($this->soap); - } - - private function buildReferenceRequest( - $type, - $money, - $authorization, - $options - ) { - - $options->action ='CrossReferenceTransaction'; - - $this->buildRequest($options, $money, $type, $authorization); - - return $this->builderSoapEnvelope($this->soap); - } - - private function buildRequest( - $options, - $money, - $type, - $payment_source - ) { - - $this->required_options('action', $options); - - $merchant_data = $this->addMerchant($options); - $purchase_data = isset($payment_source->number) ? $this->addPurchaseData($type, $money, $options) : array(); - $credit_data = isset($payment_source->number) ? $this->addCreditcard($payment_source, $options) : array(); - $customer_details = isset($payment_source->number) ? $this->addCustomerDetails($payment_source, $options) : array(); - - if (!$purchase_data) { - $reference = $this->referenceDetails($options, $money, $type, $payment_source); - } else { - $reference = array(); - } - - $this->soap = array( - 'soapBody' => array( - $options->action => array ( - '@attributes'=> array( - 'xmlns' => "https://www.thepaymentgateway.net/" - - ), - 'PaymentMessage'=> array( - array_merge($merchant_data, $purchase_data, $credit_data, $customer_details, $reference) , - ) - ) - ) - ); - } - - private function addMerchant($options) - { - $merchant = array( - 'MerchantAuthentication' => array( - '@attributes' => array( - 'MerchantID' => $this->options['merchant_id'], - 'Password' => $this->options['password'] - ) - ) - ); - - return $merchant; - } - - private function builderSoapEnvelope(&$data) - { - $xml = new XmlBuilder('soap:Envelope', new XmlNormalizer()); - $data['@attributes'] = $this->SOAP_ATTRIBUTES; - $xml->load($this->soap); - $xml->setRenderTypeAttributes(false); - - $request = $xml->createXML(true); - - $request = str_replace("soapBody", "soap:Body", $request); - - return $request; - } - - private function addPurchaseData($type, $money, $options) - { - $this->required_options('order_id', $options); - - $purchase_data = array( - 'TransactionDetails' => array( - '@attributes' => array( - 'Amount' => $this->amount($money), - 'CurrencyCode' => ($options->currency)? $this->currency_lookup($options->currency) :$this->currency_lookup(self::$default_currency) - ), - 'MessageDetails' => array( - '@attributes' => array( - 'TransactionType' => $type - ) - ), - 'OrderID' => $options->order_id, - 'TransactionControl' => array( - 'ThreeDSecureOverridePolicy' => 'FALSE', - 'EchoAVSCheckResult' => 'TRUE', - 'EchoCV2CheckResult' => 'TRUE' - ) - ) - ); - - return $purchase_data; - } - /** * Adds a CreditCard object * * @param CreditCard $creditcard * @param array reference $post */ - private function addCreditcard(CreditCard $creditcard, $options) + private function addCreditcard(CreditCard $creditcard) { - $credit = array( - 'CardDetails' => array( - 'CardName' => $creditcard->name(), - 'CV2' => $creditcard->verification_value, - 'CardNumber' => $creditcard->number, - 'ExpiryDate' => array( - '@attributes'=> array( - 'Month' => $this->cc_format($creditcard->month, 'two_digits'), - 'Year' => $this->cc_format($creditcard->year, 'two_digits') - ) - ) - ) - ); - - return $credit; + $this->xml->CardDetails(null, 'PaymentMessage'); + $this->xml->CardName($creditcard->name(), 'CardDetails'); + $this->xml->CV2($creditcard->verification_value, 'CardDetails'); + $this->xml->CardNumber($creditcard->number, 'CardDetails'); + $this->xml->ExpiryDate(null, 'CardDetails', array( + 'Month' => $creditcard->month, + 'Year' => $this->cc_format($creditcard->year, 'two_digits'), + )); } - private function addCustomerDetails($creditcard, $options, $shipTo = false) + private function addCustomerDetails($options) { - $customer = array( - 'CustomerDetails' => array( - 'BillingAddress'=> array( - 'Address1' => $options->billing_address->address1, - 'Address2' => $options->billing_address->address2, - 'City' => $options->billing_address->city, - 'State' => $options->billing_address->state, - 'PostCode' => $options->billing_address->zip, - 'CountryCode' => ($options->billing_address->country) ? Country::find($options->billing_address->country)->getCode('numeric')->__toString() : null - ), - 'PhoneNumber' => $options->billing_address->phone, - 'EmailAddress' => $options->email, - 'CustomerIPAddress' => ($options->ip) ? $options->ip : "127.0.0.1" - ), + $billingAddress = $options['billingAddress'] ?: $options['address']; - ); + $country = null; + if ($billingAddress['country']) { + $country = Country::find($billingAddress['country'])->getCode('numeric'); + } - return $customer; + $this->xml->CustomerDetails(null, 'PaymentMessage'); + $this->xml->BillingAddress(null, 'CustomerDetails'); + $this->xml->Address1($billingAddress['address1'], 'BillingAddress'); + $this->xml->City($billingAddress['city'], 'BillingAddress'); + $this->xml->State($billingAddress['state'], 'BillingAddress'); + $this->xml->PostCode($billingAddress['zip'], 'BillingAddress'); + $this->xml->CountryCode($country, 'BillingAddress'); + $this->xml->EmailAddress($options['email'], 'CustomerDetails'); + $this->xml->CustomerIPAddress($options['ip'], 'CustomerDetails'); } private function splitAuthorization($authorization) { - list($transaction_id, $amount, $last_four) = explode(';', $authorization); - - $array = array( - 'order_id' => $transaction_id, - 'cross_reference' => $amount, - 'auth_id' => $last_four - ); - - return $array; - } - - private function referenceDetails($options, $money, $type, $authorization) - { - $author = $this->splitAuthorization($authorization); - - if ($money) { - $details = array( - 'TransactionDetails' => array( - '@attributes' => array( - 'Amount' => $this->amount($money), - 'CurrencyCode' => ($options->currency)? $this->currency_lookup($options->currency) :$this->currency_lookup(self::$default_currency) - ), - 'MessageDetails' => array( - '@attributes' => array( - 'TransactionType' => $type, - 'CrossReference' => $author['cross_reference'] - ) - ), - 'OrderID' => ($options->order_id) ? $options->order_id : $author['order_id'], - ) - ); - } else { - $details =array( - 'TransactionDetails' => array( - '@attributes' => array( - 'Amount' =>'0', - 'CurrencyCode' => $this->currency_lookup(self::$default_currency) - ), - 'MessageDetails' => array( - '@attributes' => array( - 'TransactionType' => $type, - 'CrossReference' =>$author['cross_reference'] - ) - ), - 'OrderID' => ($options->order_id) ? $options->order_id :$author['order_id'] - ) - ); - - } - - return $details; + return explode(';', $authorization); } /** @@ -415,94 +229,95 @@ private function referenceDetails($options, $money, $type, $authorization) */ private function parse($body) { - $body = $this->substringBetween($body, '', ''); + $xml = simplexml_load_string($body); + + $data = $xml->xpath('//soap:Body'); - $xml = new \SimpleXMLElement($body); + $response = array(); - foreach ($xml as $child => $value) { - $this->parseElement($child, $value); + foreach ($data as $node) { + $this->parseElement($response, $node); } + + return $response; } - private function parseElement($child, $value) + private function parseElement(&$response, $node) { - if (($child == 'CardDetailsTransactionResult' ) - || ($child == 'CrossReferenceTransactionResult') - ) { - $attributes = $value->attributes(); - - if (isset($attributes)) { - foreach ($attributes as $key => $att) { - $this->reply['transaction_result'][$key] = (string) $att; - } - } - - foreach ($value as $key => $value) { - $this->reply['transaction_result'][$key] = (string) $value; - } - - } elseif ($child == 'TransactionOutputData') { - $attributes = $value->attributes(); + foreach ($node->attributes() as $k => $v) { + $response[$node->getName() . '_' . $k] = trim($v->__toString()); + } - if (isset($attributes)) { - foreach ($attributes as $key => $att) { - $this->reply['transaction_output_data'][$key] = (string) $att; + if ($node->count() > 0) { + if ($node->getName()) { + $response[$node->getName()] = true; + foreach ($node as $n) { + $this->parseElement($response, $n); } } + } else { + $response[$node->getName()] = trim($node->__toString()); + } + } - foreach ($value as $child_node => $child_value) { - if ($child_node == 'GatewayEntryPoints') { - $index = 0; - - foreach ($child_value as $key => $att) { - $attributes = $att->attributes(); - - if (isset($attributes)) { - foreach ($attributes as $att_key => $att_value) { - $this->reply['transaction_output_data']['gateway_entry_points'][$index][$att_key] = (string) $att_value; - - } - } - $index++; - } - } - - $this->reply['transaction_output_data'][$child_node] = (string) $child_value; - } + private function authorizationFrom(Options $response, Options $options) + { + if ($response['StatusCode'] == "0") { + $authCode = $response['AuthCode'] ?: null; + + return implode(';', array( + $options['order_id'], + $response['TransactionOutputData_CrossReference'], + $authCode, + )); } } - private function substringBetween($haystack, $start, $end) + private function createXmlBuilder($action) { - if (strpos($haystack, $start) === false - || strpos($haystack, $end) === false - ) { - return false; - } else { - $start_position = strpos($haystack, $start) + strlen($start); + $call = $this->soapCall[$action]; - $end_position = strpos($haystack, $end); + $this->xml = new SimpleXmlBuilder('1.0', 'UTF-8'); - return substr($haystack, $start_position, $end_position - $start_position); - } + $this->xml->{'soap:Envelope'}(null, null, $this->SOAP_ATTRIBUTES); + $this->xml->{'soap:Body'}(null, 'soap:Envelope'); + + $this->xml->$call(null, 'soap:Body', [], 'https://www.thepaymentgateway.net/'); + $this->xml->PaymentMessage(null, $call); + + $this->xml->MerchantAuthentication( + null, + 'PaymentMessage', + array( + 'MerchantID' => $this->options['merchant_id'], + 'Password' => $this->options['password'] + ) + ); } - private function authorizationFrom(Options $options) + private function addTransactionDetails($money, $action, $orderId, $crossReference = null) { - if ($this->success) { - $auth_code = isset($this->reply['transaction_output_data']['AuthCode']) - ? $this->reply['transaction_output_data']['AuthCode'] - : null ; - $auth = $options->order_id - .';' - .$this->reply['transaction_output_data']['CrossReference'] - .';' - .$auth_code; + $this->xml->TransactionDetails( + null, + 'PaymentMessage', + array( + 'Amount' => $this->amount($money), + 'CurrencyCode' => $this->currency_lookup(self::$default_currency), + ) + ); - } else { - $auth = null; + $messageDetails = array('TransactionType' => $action); + if ($crossReference) { + $messageDetails['CrossReference'] = $crossReference; + } + $this->xml->MessageDetails(null, 'TransactionDetails', $messageDetails); + + $this->xml->OrderID($orderId, 'TransactionDetails'); + if (null == $crossReference) { + $this->xml->TransactionControl(null, 'TransactionDetails'); + $this->xml->ThreeDSecureOverridePolicy('FALSE', 'TransactionControl'); + $this->xml->EchoAVSCheckResult('TRUE', 'TransactionControl'); + $this->xml->EchoCV2CheckResult('TRUE', 'TransactionControl'); } - - return $auth; } } diff --git a/lib/AktiveMerchant/Common/SimpleXmlBuilder.php b/lib/AktiveMerchant/Common/SimpleXmlBuilder.php index 7080eb6..bb90c8e 100644 --- a/lib/AktiveMerchant/Common/SimpleXmlBuilder.php +++ b/lib/AktiveMerchant/Common/SimpleXmlBuilder.php @@ -22,21 +22,26 @@ class SimpleXmlBuilder private $encoding; + private $namespace; + + private $nodes; + /** * @param string $version Default '1.0' * @param string $encoding Default 'UTF-8' */ - public function __construct($version = '1.0', $encoding = 'UTF-8') + public function __construct($version = '1.0', $encoding = 'UTF-8', $namespace = null) { $this->version = $version; $this->encoding = $encoding; + $this->namespace = $namespace; } /** * @param string $name The name of element * @param array $args An array with: * - (string) value of element - * - (string) node element to add this element as child. + * - (string) parent node element to add this element as child. * - (array) attributes of element * * @return XmlBuilder @@ -46,6 +51,7 @@ public function __call($name, $args) $value = array_shift($args); $parentNode = array_shift($args); $attrs = array_shift($args) ?: array(); + $namespace = array_shift($args) ?: null; if (null === $this->root) { $this->createRootNode($name, $attrs); @@ -53,27 +59,49 @@ public function __call($name, $args) return $this; } - $this->createNode($name, $value, $attrs, $parentNode); + $this->createNode($name, $value, $attrs, $parentNode, $namespace); return $this; } - private function createNode($name, $value, array $attrs = array(), $parentNode = null) + public function registerXPathNamespace($prefix, $ns) + { + $this->root->registerXPathNamespace($prefix, $ns); + } + + private function createNode($name, $value, array $attrs = array(), $parentNode = null, $namespace = null) { if ($parentNode) { - $node = $this->xpath('//' . $parentNode)->addChild($name, $value); + #$node = $this->xpath('//' . $parentNode); + $node = $this->nodes[$parentNode]; + $node = $node->addChild($name, $value, $namespace); } else { - $node = $this->root->addChild($name, $value); + $node = $this->root->addChild($name, $value, $namespace); } $this->addAttributes($node, $attrs); + $this->nodes[$name] = $node; } private function createRootNode($tag, array $attrs = array()) { - $root = '<%s>'; - $string = sprintf($root, $this->version, $this->encoding, $tag, $tag); + $attr = ""; + if (!empty($attrs)) { + $attr = $this->serializeAttributes($attrs); + } + $root = '<%s%s>'; + $string = sprintf($root, $this->version, $this->encoding, $tag, $attr, $tag); $this->root = new SimpleXmlElement($string); - $this->addAttributes($this->root, $attrs); + $this->nodes[$tag] = $this->root; + } + + private function serializeAttributes($attrs) + { + $string = ""; + foreach ($attrs as $name => $value) { + $string .= ' '.$name.'="'.$value.'"'; + } + + return $string; } private function addAttributes($node, array $attrs) diff --git a/tests/AktiveMerchant/Billing/Gateways/IridiumTest.php b/tests/AktiveMerchant/Billing/Gateways/IridiumTest.php index 02546d2..ba86f9b 100644 --- a/tests/AktiveMerchant/Billing/Gateways/IridiumTest.php +++ b/tests/AktiveMerchant/Billing/Gateways/IridiumTest.php @@ -2,15 +2,16 @@ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +namespace AktiveMerchant\Billing\Gateways; + use AktiveMerchant\Billing\Base; -use AktiveMerchant\Billing\Gateways\Iridium; use AktiveMerchant\Billing\CreditCard; use AktiveMerchant\Common\Options; -use AktiveMerchant\Billing\Gateways\Eway; +use AktiveMerchant\TestCase; +use AktiveMerchant\Event\RequestEvents; -class IridiumTest extends AktiveMerchant\TestCase +class IridiumTest extends TestCase { - public $gateway; public $amount; public $options; @@ -28,12 +29,11 @@ public function setUp() $this->creditcard = new CreditCard( array( - "type" => 'VC', "first_name" => "John", "last_name" => "Doe", "number" => '4976000000003436', "month" => "12", - "year" => "2015", + "year" => date('Y') + 1, "verification_value" => "452" ) ); @@ -55,7 +55,7 @@ public function setUp() public function testSuccessfulAuthorization() { - $this->mock_request($this->successful_authorize_response()); + $this->mock_request($this->successfulAuthorizeResponse()); $response = $this->gateway->authorize( $this->amount, @@ -64,31 +64,32 @@ public function testSuccessfulAuthorization() ); $this->assert_success($response); - $this->assertRegExp('/033976/', $response->authorization()); + $this->assertNotNull($response->authorization()); - $this->assertTrue(!is_null($response->authorization())); - + return $response->authorization(); } - public function testSuccesfulCapture () + /** + * @depends testSuccessfulAuthorization + */ + public function testSuccesfulCapture($authorization) { - $this->mock_request($this->successful_capture_response()); + $this->mock_request($this->successfulCaptureResponse()); - $authorization = 'REF1401315153;140529115207528401556604;033976'; $response = $this->gateway->capture( $this->amount, $authorization, $this->options ); + $this->assert_success($response); $this->assertRegExp('/140529115328094701097945/', $response->authorization()); - } public function testSuccesfulPurchase() { - $this->mock_request($this->successful_purchase_response()); + $this->mock_request($this->successfulPurchaseResponse()); $response = $this->gateway->purchase( $this->amount, @@ -96,41 +97,46 @@ public function testSuccesfulPurchase() $this->options ); - $this->assertRegExp('/140529120244578301140694/', $response->authorization()); $this->assert_success($response); + $this->assertRegExp('/140529120244578301140694/', $response->authorization()); + + return $response->authorization(); } - public function testSuccessfulCredit() + /** + * @depends testSuccesfulPurchase + */ + public function testSuccessfulCredit($authorization) { - $this->mock_request($this->successful_credit_response()); + $this->mock_request($this->successfulCreditResponse()); - $authorization = 'REF1768823666;140529120244578301140694;931597'; $response = $this->gateway->credit( $this->amount, $authorization, $this->options ); - $this->assertRegExp('/140529131137341901180555/', $response->authorization()); $this->assert_success($response); + $this->assertRegExp('/140529131137341901180555/', $response->authorization()); } - public function testSuccessfulVoid() + /** + * @depends testSuccessfulAuthorization + */ + public function testSuccessfulVoid($authorization) { - $this->mock_request($this->successful_void_response()); - $authorization = 'REF1768823666;140529120244578301140694;931597'; + $this->mock_request($this->successfulVoidResponse()); $response = $this->gateway->void( $authorization, $this->options ); - $this->assertRegExp('/140529132114901901941710/', $response->authorization()); $this->assert_success($response); + $this->assertRegExp('/140529132114901901941710/', $response->authorization()); } - - private function successful_authorize_response() + private function successfulAuthorizeResponse() { return ' @@ -144,9 +150,9 @@ private function successful_authorize_response() '; } - private function successful_capture_response() + private function successfulCaptureResponse() { - return ' + return ' 0Collection successful @@ -157,7 +163,7 @@ private function successful_capture_response() } - private function successful_purchase_response() + private function successfulPurchaseResponse() { return ' @@ -168,11 +174,11 @@ private function successful_purchase_response() PASSEDPASSED PASSED - A'; + '; } - private function successful_credit_response() + private function successfulCreditResponse() { return ' @@ -184,7 +190,7 @@ private function successful_credit_response() '; } - private function successful_void_response() + private function successfulVoidResponse() { return' @@ -197,6 +203,4 @@ private function successful_void_response() '; } - - }