diff --git a/lib/Paymill/Models/Internal/AbstractAddress.php b/lib/Paymill/Models/Internal/AbstractAddress.php new file mode 100644 index 0000000..d9e8256 --- /dev/null +++ b/lib/Paymill/Models/Internal/AbstractAddress.php @@ -0,0 +1,253 @@ +_name; + } + + /** + * Set name + * + * @param null|string $name + * + * @return $this + */ + public function setName($name) + { + $this->_name = $name; + + return $this; + } + + /** + * Get streetAddress + * + * @return null|string + */ + public function getStreetAddress() + { + return $this->_streetAddress; + } + + /** + * Set streetAddress + * + * @param null|string $streetAddress + * + * @return $this + */ + public function setStreetAddress($streetAddress) + { + $this->_streetAddress = $streetAddress; + + return $this; + } + + /** + * Get streetAddressAddition + * + * @return null|string + */ + public function getStreetAddressAddition() + { + return $this->_streetAddressAddition; + } + + /** + * Set streetAddressAddition + * + * @param null|string $streetAddressAddition + * + * @return $this + */ + public function setStreetAddressAddition($streetAddressAddition) + { + $this->_streetAddressAddition = $streetAddressAddition; + + return $this; + } + + /** + * Get city + * + * @return null|string + */ + public function getCity() + { + return $this->_city; + } + + /** + * Set city + * + * @param null|string $city + * + * @return $this + */ + public function setCity($city) + { + $this->_city = $city; + + return $this; + } + + /** + * Get state + * + * @return null|string + */ + public function getState() + { + return $this->_state; + } + + /** + * Set state + * + * @param null|string $state + * + * @return $this + */ + public function setState($state) + { + $this->_state = $state; + + return $this; + } + + /** + * Get postalCode + * + * @return null|string + */ + public function getPostalCode() + { + return $this->_postalCode; + } + + /** + * Set postalCode + * + * @param null|string $postalCode + * + * @return $this + */ + public function setPostalCode($postalCode) + { + $this->_postalCode = $postalCode; + + return $this; + } + + /** + * Get country + * + * @return null|string + */ + public function getCountry() + { + return $this->_country; + } + + /** + * Set country + * + * @param null|string $country + * + * @return $this + */ + public function setCountry($country) + { + $this->_country = $country; + + return $this; + } + + /** + * Get phone + * + * @return null|string + */ + public function getPhone() + { + return $this->_phone; + } + + /** + * Set phone + * + * @param null|string $phone + * + * @return $this + */ + public function setPhone($phone) + { + $this->_phone = $phone; + + return $this; + } +} diff --git a/lib/Paymill/Models/Internal/BillingAddress.php b/lib/Paymill/Models/Internal/BillingAddress.php new file mode 100644 index 0000000..d345bee --- /dev/null +++ b/lib/Paymill/Models/Internal/BillingAddress.php @@ -0,0 +1,11 @@ +_name; + } + + /** + * Set name + * + * @param string $name + * + * @return $this + */ + public function setName($name) + { + $this->_name = $name; + + return $this; + } + + /** + * Get _description + * + * @return string + */ + public function getDescription() + { + return $this->_description; + } + + /** + * Set description + * + * @param string $description + * + * @return $this + */ + public function setDescription($description) + { + $this->_description = $description; + + return $this; + } + + /** + * Get _itemNumber + * + * @return string + */ + public function getItemNumber() + { + return $this->_itemNumber; + } + + /** + * Set itemNumber + * + * @param string $itemNumber + * + * @return $this + */ + public function setItemNumber($itemNumber) + { + $this->_itemNumber = $itemNumber; + + return $this; + } + + /** + * Get _url + * + * @return string + */ + public function getUrl() + { + return $this->_url; + } + + /** + * Set url + * + * @param string $url + * + * @return $this + */ + public function setUrl($url) + { + $this->_url = $url; + + return $this; + } + + /** + * Get _amount + * + * @return string + */ + public function getAmount() + { + return $this->_amount; + } + + /** + * Set amount + * + * @param string $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->_amount = $amount; + + return $this; + } + + /** + * Get _quantity + * + * @return int + */ + public function getQuantity() + { + return $this->_quantity; + } + + /** + * Set quantity + * + * @param int $quantity + * + * @return $this + */ + public function setQuantity($quantity) + { + $this->_quantity = $quantity; + + return $this; + } +} diff --git a/lib/Paymill/Models/Internal/ShippingAddress.php b/lib/Paymill/Models/Internal/ShippingAddress.php new file mode 100644 index 0000000..910bc97 --- /dev/null +++ b/lib/Paymill/Models/Internal/ShippingAddress.php @@ -0,0 +1,11 @@ +_shipping_amount; + return $this->_shippingAmount; } /** * Set shipping amount * - * @param int $shipping_amount Shipping amount + * @param int $shippingAmount Shipping amount * * @return $this */ - public function setShippingAmount($shipping_amount) + public function setShippingAmount($shippingAmount) { - $this->_shipping_amount = $shipping_amount; + $this->_shippingAmount = $shippingAmount; return $this; } @@ -624,19 +632,19 @@ public function setShippingAmount($shipping_amount) */ public function getHandlingAmount() { - return $this->_handling_amount; + return $this->_handlingAmount; } /** * Set handling amount * - * @param int $handling_amount Handling amount + * @param int $handlingAmount Handling amount * * @return $this */ - public function setHandlingAmount($handling_amount) + public function setHandlingAmount($handlingAmount) { - $this->_handling_amount = $handling_amount; + $this->_handlingAmount = $handlingAmount; return $this; } diff --git a/lib/Paymill/Services/ResponseHandler.php b/lib/Paymill/Services/ResponseHandler.php index a2e0d71..f599e19 100644 --- a/lib/Paymill/Services/ResponseHandler.php +++ b/lib/Paymill/Services/ResponseHandler.php @@ -2,9 +2,22 @@ namespace Paymill\Services; -use Paymill\Models\Response as Models; +use Paymill\Models\Internal\AbstractAddress; +use Paymill\Models\Internal\BillingAddress; +use Paymill\Models\Internal\ShippingAddress; +use Paymill\Models\Internal\Item; +use Paymill\Models\Response\Base; use Paymill\Models\Response\Checksum; +use Paymill\Models\Response\Client; use Paymill\Models\Response\Error; +use Paymill\Models\Response\Fraud; +use Paymill\Models\Response\Offer; +use Paymill\Models\Response\Payment; +use Paymill\Models\Response\Preauthorization; +use Paymill\Models\Response\Refund; +use Paymill\Models\Response\Subscription; +use Paymill\Models\Response\Transaction; +use Paymill\Models\Response\Webhook; /** * ResponseHandler @@ -116,7 +129,7 @@ class ResponseHandler * Converts a response to a model * @param array $response * @param string $serviceResource - * @return Models\Base|Error + * @return Base|Error */ public function convertResponse($response, $serviceResource) { @@ -128,7 +141,7 @@ public function convertResponse($response, $serviceResource) * Creates an object from a response array based on the call-context * @param array $response Response from any Request * @param string $resourceName - * @return Models\Base + * @return Base */ private function _convertResponseToModel($response, $resourceName) { @@ -171,6 +184,15 @@ private function _convertResponseToModel($response, $resourceName) case 'checksum': $model = $this->_createChecksum($response); break; + case AbstractAddress::TYPE_SHIPPING: + $model = $this->_createAddress($response, AbstractAddress::TYPE_SHIPPING); + break; + case AbstractAddress::TYPE_BILLING: + $model = $this->_createAddress($response, AbstractAddress::TYPE_BILLING); + break; + case 'item': + $model = $this->_createItem($response); + break; } return $model; @@ -180,11 +202,11 @@ private function _convertResponseToModel($response, $resourceName) * Creates and fills a client model * * @param array $response - * @return \Paymill\Models\Response\Client + * @return Client */ - private function _createClient($response) + private function _createClient(array $response) { - $model = new Models\Client(); + $model = new Client(); $model->setId($response['id']); $model->setEmail($response['email']); $model->setDescription($response['description']); @@ -200,11 +222,11 @@ private function _createClient($response) * Creates and fills a payment model * * @param array $response - * @return \Paymill\Models\Response\Payment + * @return Payment */ - private function _createPayment($response) + private function _createPayment(array $response) { - $model = new Models\Payment(); + $model = new Payment(); $model->setId($response['id']); $model->setType($response['type']); $model->setClient($this->_convertResponseToModel($response['client'], "client")); @@ -235,11 +257,11 @@ private function _createPayment($response) * Creates and fills a transaction model * * @param array $response - * @return \Paymill\Models\Response\Transaction + * @return Transaction */ - private function _createTransaction($response) + private function _createTransaction(array $response) { - $model = new Models\Transaction(); + $model = new Transaction(); $model->setId($response['id']); $model->setAmount($response['amount']); $model->setOriginAmount($response['origin_amount']); @@ -258,6 +280,29 @@ private function _createTransaction($response) $model->setPreauthorization($this->_convertResponseToModel($response['preauthorization'], "preauthorization")); $model->setFees($response['fees']); $model->setAppId($response['app_id']); + + if (isset($response[Transaction::RESPONSE_FIELD_SHIPPING_ADDRESS])) { + $model->setShippingAddress( + $this->_convertResponseToModel( + $response[Transaction::RESPONSE_FIELD_SHIPPING_ADDRESS], + AbstractAddress::TYPE_SHIPPING + ) + ); + } + + if (isset($response[Transaction::RESPONSE_FIELD_BILLING_ADDRESS])) { + $model->setBillingAddress( + $this->_convertResponseToModel( + $response[Transaction::RESPONSE_FIELD_BILLING_ADDRESS], + AbstractAddress::TYPE_BILLING + ) + ); + } + + if (isset($response[Transaction::RESPONSE_FIELD_ITEMS])) { + $model->setItems($this->_handleRecursive($response[Transaction::RESPONSE_FIELD_ITEMS], 'item')); + } + return $model; } @@ -265,11 +310,11 @@ private function _createTransaction($response) * Creates and fills a preauthorization model * * @param array $response - * @return \Paymill\Models\Response\Preauthorization + * @return Preauthorization */ private function _createPreauthorization($response) { - $model = new Models\Preauthorization(); + $model = new Preauthorization(); $model->setId($response['id']); $model->setAmount($response['amount']); $model->setCurrency($response['currency']); @@ -289,11 +334,11 @@ private function _createPreauthorization($response) * Creates and fills a refund model * * @param array $response - * @return \Paymill\Models\Response\Refund + * @return Refund */ - private function _createRefund($response) + private function _createRefund(array $response) { - $model = new Models\Refund(); + $model = new Refund(); $model->setId($response['id']); $model->setAmount($response['amount']); $model->setStatus($response['status']); @@ -312,11 +357,11 @@ private function _createRefund($response) * Creates and fills a offer model * * @param array $response - * @return \Paymill\Models\Response\Offer + * @return Offer */ - private function _createOffer($response) + private function _createOffer(array $response) { - $model = new Models\Offer(); + $model = new Offer(); $model->setId($response['id']); $model->setName($response['name']); $model->setAmount($response['amount']); @@ -334,11 +379,11 @@ private function _createOffer($response) * Creates and fills a subscription model * * @param array $response - * @return \Paymill\Models\Response\Subscription + * @return Subscription */ - private function _createSubscription($response) + private function _createSubscription(array $response) { - $model = new Models\Subscription(); + $model = new Subscription(); $model->setId($response['id']); $model->setOffer($this->_convertResponseToModel($response['offer'], 'offer')); $model->setLivemode($response['livemode']); @@ -363,11 +408,11 @@ private function _createSubscription($response) * Creates and fills a webhook model * * @param array $response - * @return \Paymill\Models\Response\Webhook + * @return Webhook */ - private function _createWebhook($response) + private function _createWebhook(array $response) { - $model = new Models\Webhook(); + $model = new Webhook(); $model->setId($response['id']); isset($response['url']) ? $model->setUrl($response['url']) : $model->setEmail($response['email']); $model->setLivemode($response['livemode']); @@ -383,11 +428,11 @@ private function _createWebhook($response) * Creates and fills a fraud model * * @param array $response - * @return \Paymill\Models\Response\Fraud + * @return Fraud */ - private function _createFraud($response) + private function _createFraud(array $response) { - $model = new Models\Fraud(); + $model = new Fraud(); $model->setId($response['id']); $model->setLivemode($response['livemode']); $model->setStatus($response['status']); @@ -402,7 +447,7 @@ private function _createFraud($response) * @param array $response * @return Checksum */ - private function _createChecksum($response) + private function _createChecksum(array $response) { $model = new Checksum(); $model->setId($response['id']); @@ -417,11 +462,62 @@ private function _createChecksum($response) return $model; } + /** + * Creates and fills an item model. + * + * @param array $response + * @return Item + */ + private function _createItem(array $response) + { + $model = new Item(); + $model->setName($response[Item::FIELD_NAME]) + ->setDescription($response[Item::FIELD_DESCRIPTION]) + ->setItemNumber($response[Item::FIELD_ITEM_NUMBER]) + ->setUrl($response[Item::FIELD_URL]) + ->setAmount($response[Item::FIELD_AMOUNT]) + ->setQuantity($response[Item::FIELD_QUANTITY]); + + return $model; + } + + /** + * Creates and fills a shipping- / billing address model. + * + * @param array $response + * @param string $type + * @return null|BillingAddress|ShippingAddress + */ + private function _createAddress(array $response, $type) + { + switch($type) { + case AbstractAddress::TYPE_SHIPPING: + $model = new ShippingAddress(); + break; + case AbstractAddress::TYPE_BILLING: + $model = new BillingAddress(); + break; + default: + return null; + } + + $model->setName($response[AbstractAddress::FIELD_NAME]) + ->setStreetAddress($response[AbstractAddress::FIELD_STREET_ADDRESS]) + ->setStreetAddressAddition($response[AbstractAddress::FIELD_STREET_ADDRESS_ADDITION]) + ->setPostalCode($response[AbstractAddress::FIELD_POSTAL_CODE]) + ->setCity($response[AbstractAddress::FIELD_CITY]) + ->setState($response[AbstractAddress::FIELD_STATE]) + ->setCountry($response[AbstractAddress::FIELD_COUNTRY]) + ->setPhone($response[AbstractAddress::FIELD_PHONE]); + + return $model; + } + /** * Handles the multidimensional param arrays during model creation * @param array $response * @param string $resourceName - * @return array|null|Models\Base + * @return array|null|Base */ private function _handleRecursive($response, $resourceName) { @@ -500,7 +596,7 @@ public function convertErrorToModel(array $response, $resourceName = null) * * @return boolean True if valid */ - public function validateResponse($response) + public function validateResponse(array $response) { $returnValue = false; if (isset($response['header']) @@ -514,7 +610,7 @@ public function validateResponse($response) return $returnValue; } - private function getErrorMessageFromArray($errorArray) + private function getErrorMessageFromArray(array $errorArray) { $errorMessage = array_shift($errorArray); if (is_array($errorMessage)) { @@ -527,8 +623,8 @@ private function getErrorMessageFromArray($errorArray) /** * Converts an array into an object * - * @param array $array - * @return stdClass + * @param mixed $array + * @return \StdClass */ public function arrayToObject($array) { diff --git a/tests/unit/Paymill/Models/Internal/BillingAddressTest.php b/tests/unit/Paymill/Models/Internal/BillingAddressTest.php new file mode 100644 index 0000000..cf88ac0 --- /dev/null +++ b/tests/unit/Paymill/Models/Internal/BillingAddressTest.php @@ -0,0 +1,71 @@ +_billingAddress = new BillingAddress(); + } + + /** + * Cleans up the environment after running a test. + */ + protected function tearDown() + { + $this->_billingAddress = null; + parent::tearDown(); + } + + //Testmethods + /** + * Tests the getters and setters of the model + * @test + */ + public function setGetTest() + { + $sample = array( + 'name' => 'Max Muster', + 'street_address' => 'Musterstrasse 1', + 'street_address_addition' => 'EG', + 'city' => 'Musterhausen', + 'state' => 'BY', + 'postal_code' => '99999', + 'country' => 'DE', + 'phone' => '+49 89 1234567', + ); + + $this->_billingAddress->setName($sample['name']) + ->setStreetAddress($sample['street_address']) + ->setStreetAddressAddition($sample['street_address_addition']) + ->setCity($sample['city']) + ->setState($sample['state']) + ->setPostalCode($sample['postal_code']) + ->setCountry($sample['country']) + ->setPhone($sample['phone']); + + $this->assertEquals($this->_billingAddress->getName(), $sample['name']); + $this->assertEquals($this->_billingAddress->getStreetAddress(), $sample['street_address']); + $this->assertEquals($this->_billingAddress->getStreetAddressAddition(), $sample['street_address_addition']); + $this->assertEquals($this->_billingAddress->getCity(), $sample['city']); + $this->assertEquals($this->_billingAddress->getState(), $sample['state']); + $this->assertEquals($this->_billingAddress->getPostalCode(), $sample['postal_code']); + $this->assertEquals($this->_billingAddress->getCountry(), $sample['country']); + $this->assertEquals($this->_billingAddress->getPhone(), $sample['phone']); + + return $this->_billingAddress; + } +} diff --git a/tests/unit/Paymill/Models/Internal/ItemTest.php b/tests/unit/Paymill/Models/Internal/ItemTest.php new file mode 100644 index 0000000..6ed8e94 --- /dev/null +++ b/tests/unit/Paymill/Models/Internal/ItemTest.php @@ -0,0 +1,65 @@ +_item = new Item(); + } + + /** + * Cleans up the environment after running a test. + */ + protected function tearDown() + { + $this->_item = null; + parent::tearDown(); + } + + //Testmethods + /** + * Tests the getters and setters of the model + * @test + */ + public function setGetTest() + { + $sample = array( + 'name' => 'Product 1', + 'description' => 'Product description', + 'item_number' => 'ITM123456', + 'url' => 'https://shop.example.com/item/1', + 'amount' => '1999', + 'quantity' => 1, + ); + + $this->_item->setName($sample['name']) + ->setDescription($sample['description']) + ->setItemNumber($sample['item_number']) + ->setUrl($sample['url']) + ->setAmount($sample['amount']) + ->setQuantity($sample['quantity']); + + $this->assertEquals($this->_item->getName(), $sample['name']); + $this->assertEquals($this->_item->getDescription(), $sample['description']); + $this->assertEquals($this->_item->getItemNumber(), $sample['item_number']); + $this->assertEquals($this->_item->getUrl(), $sample['url']); + $this->assertEquals($this->_item->getAmount(), $sample['amount']); + $this->assertEquals($this->_item->getQuantity(), $sample['quantity']); + + return $this->_item; + } +} diff --git a/tests/unit/Paymill/Models/Internal/ShippingAddressTest.php b/tests/unit/Paymill/Models/Internal/ShippingAddressTest.php new file mode 100644 index 0000000..30ceb38 --- /dev/null +++ b/tests/unit/Paymill/Models/Internal/ShippingAddressTest.php @@ -0,0 +1,71 @@ +_shippingAddress = new ShippingAddress(); + } + + /** + * Cleans up the environment after running a test. + */ + protected function tearDown() + { + $this->_shippingAddress = null; + parent::tearDown(); + } + + //Testmethods + /** + * Tests the getters and setters of the model + * @test + */ + public function setGetTest() + { + $sample = array( + 'name' => 'Max Muster', + 'street_address' => 'Musterstrasse 1', + 'street_address_addition' => 'EG', + 'city' => 'Musterhausen', + 'state' => 'BY', + 'postal_code' => '99999', + 'country' => 'DE', + 'phone' => '+49 89 1234567', + ); + + $this->_shippingAddress->setName($sample['name']) + ->setStreetAddress($sample['street_address']) + ->setStreetAddressAddition($sample['street_address_addition']) + ->setCity($sample['city']) + ->setState($sample['state']) + ->setPostalCode($sample['postal_code']) + ->setCountry($sample['country']) + ->setPhone($sample['phone']); + + $this->assertEquals($this->_shippingAddress->getName(), $sample['name']); + $this->assertEquals($this->_shippingAddress->getStreetAddress(), $sample['street_address']); + $this->assertEquals($this->_shippingAddress->getStreetAddressAddition(), $sample['street_address_addition']); + $this->assertEquals($this->_shippingAddress->getCity(), $sample['city']); + $this->assertEquals($this->_shippingAddress->getState(), $sample['state']); + $this->assertEquals($this->_shippingAddress->getPostalCode(), $sample['postal_code']); + $this->assertEquals($this->_shippingAddress->getCountry(), $sample['country']); + $this->assertEquals($this->_shippingAddress->getPhone(), $sample['phone']); + + return $this->_shippingAddress; + } +} diff --git a/tests/unit/Paymill/Models/Request/RefundTest.php b/tests/unit/Paymill/Models/Request/RefundTest.php index e3b6439..71f213a 100644 --- a/tests/unit/Paymill/Models/Request/RefundTest.php +++ b/tests/unit/Paymill/Models/Request/RefundTest.php @@ -10,7 +10,6 @@ */ class RefundTest extends PHPUnit_Framework_TestCase { - /** * @var Request\Refund */ diff --git a/tests/unit/Paymill/Models/Request/TransactionTest.php b/tests/unit/Paymill/Models/Request/TransactionTest.php index 8a4d5f2..fc1479e 100755 --- a/tests/unit/Paymill/Models/Request/TransactionTest.php +++ b/tests/unit/Paymill/Models/Request/TransactionTest.php @@ -56,6 +56,7 @@ public function setGetTest() ->setSource($sample['source']) ->setShippingAddress($sample['shipping_address']) ->setBillingAddress($sample['billing_address']) + ->setItems($sample['items']) ->setMandateReference($sample['mandate_reference']); $this->assertEquals($this->_transaction->getAmount(), $sample['amount']); @@ -71,6 +72,7 @@ public function setGetTest() $this->assertEquals($this->_transaction->getSource(), $sample['source']); $this->assertEquals($this->_transaction->getShippingAddress(), $sample['shipping_address']); $this->assertEquals($this->_transaction->getBillingAddress(), $sample['billing_address']); + $this->assertEquals($this->_transaction->getItems(), $sample['items']); $this->assertEquals($this->_transaction->getMandateReference(), $sample['mandate_reference']); return $this->_transaction; @@ -95,18 +97,19 @@ public function parameterizeTest(Transaction $transaction) $getOneArray = $transaction->parameterize("getOne"); $this->assertEquals(array( - 'amount' => $sample['amount'], // e.g. "4200" for 42.00 EUR - 'currency' => $sample['currency'], // ISO 4217 - 'client' => $sample['client'], - 'preauthorization' => $sample['preauthorization'], - 'fee_amount' => $sample['fee_amount'], // e.g. "420" for 4.20 EUR - 'fee_payment' => $sample['fee_payment'], - 'fee_currency' => $sample['fee_currency'], - 'description' => $sample['description'], - 'source' => $sample['source'], + 'amount' => $sample['amount'], // e.g. "4200" for 42.00 EUR + 'currency' => $sample['currency'], // ISO 4217 + 'client' => $sample['client'], + 'preauthorization' => $sample['preauthorization'], + 'fee_amount' => $sample['fee_amount'], // e.g. "420" for 4.20 EUR + 'fee_payment' => $sample['fee_payment'], + 'fee_currency' => $sample['fee_currency'], + 'description' => $sample['description'], + 'source' => $sample['source'], 'mandate_reference' => $sample['mandate_reference'], - 'shipping_address' => $sample['shipping_address'], - 'billing_address' => $sample['billing_address'] + 'shipping_address' => $sample['shipping_address'], + 'billing_address' => $sample['billing_address'], + 'items' => $sample['items'], ), $creationArray); $this->assertEquals(array( @@ -149,21 +152,41 @@ private function getSampleData() 'phone' => '+49 89 189 045 300' ); + $items = array( + array( + 'name' => 'Product 1', + 'description' => 'Product description 1', + 'item_number' => 'ITM123456_1', + 'url' => 'https://shop.example.com/product/product-1', + 'amount' => '2100', + 'quantity' => 1, + ), + array( + 'name' => 'Product 2', + 'description' => 'Product description 2', + 'item_number' => 'ITM123456_2', + 'url' => 'https://shop.example.com/product/product-2', + 'amount' => '1050', + 'quantity' => 2, + ), + ); + $sample = array( - 'amount' => '4200', // e.g. "4200" for 42.00 EUR - 'currency' => 'EUR', // ISO 4217 - 'payment' => 'pay_2f82a672574647cd911d', - 'token' => '098f6bcd4621d373cade4e832627b4f6', - 'client' => 'client_c781b1d2f7f0f664b4d9', - 'preauthorization' => 'preauth_ec54f67e52e92051bd65', - 'fee_amount' => '420', // e.g. "420" for 4.20 EUR - 'fee_payment' => 'pay_098f6bcd4621d373cade4e832627b4f6', - 'fee_currency' => 'EUR', - 'description' => 'Test Transaction', - 'source' => 'merchantcenter', - 'mandate_reference' =>'DE1234TEST', - 'shipping_address' => $shippingAddress, - 'billing_address' => $billingAddress + 'amount' => '4200', // e.g. "4200" for 42.00 EUR + 'currency' => 'EUR', // ISO 4217 + 'payment' => 'pay_2f82a672574647cd911d', + 'token' => '098f6bcd4621d373cade4e832627b4f6', + 'client' => 'client_c781b1d2f7f0f664b4d9', + 'preauthorization' => 'preauth_ec54f67e52e92051bd65', + 'fee_amount' => '420', // e.g. "420" for 4.20 EUR + 'fee_payment' => 'pay_098f6bcd4621d373cade4e832627b4f6', + 'fee_currency' => 'EUR', + 'description' => 'Test Transaction', + 'source' => 'merchantcenter', + 'mandate_reference' => 'DE1234TEST', + 'shipping_address' => $shippingAddress, + 'billing_address' => $billingAddress, + 'items' => $items, ); return $sample; diff --git a/tests/unit/Paymill/Services/ResponseHandlerTest.php b/tests/unit/Paymill/Services/ResponseHandlerTest.php index 30e1ab0..9c2c0f3 100644 --- a/tests/unit/Paymill/Services/ResponseHandlerTest.php +++ b/tests/unit/Paymill/Services/ResponseHandlerTest.php @@ -669,6 +669,7 @@ public function ProveConversionToArray(){ "fees" => array(), "app_id" => null ); + $responseObject = $this->_responseHandler->arrayToObject($response['body']); $this->assertInstanceOf('stdClass', $responseObject); $this->assertEquals($response['body']['data']['id'], $responseObject->data->id);