diff --git a/spec/Judopay/Model/AndroidPaymentSpec.php b/spec/Judopay/Model/AndroidPaymentSpec.php deleted file mode 100644 index f1e3415..0000000 --- a/spec/Judopay/Model/AndroidPaymentSpec.php +++ /dev/null @@ -1,133 +0,0 @@ -shouldHaveType('Judopay\Model\AndroidPayment'); - } - - public function it_should_create_a_new_payment() - { - $this->beConstructedWith( - $this->concoctRequest('transactions/android_payment.json') - ); - - $modelBuilder = new AndroidPaymentBuilder(); - /** @var AndroidPayment|AndroidPaymentSpec $this */ - $this->setAttributeValues( - $modelBuilder->compile()->getAttributeValues() - ); - $output = $this->create(); - - $output->shouldBeArray(); - $output['result']->shouldEqual('Success'); - } - - public function it_should_raise_an_error_when_required_fields_are_missing() - { - $this->beConstructedWith( - $this->concoctRequest('transactions/android_payment.json') - ); - $this->shouldThrow('\Judopay\Exception\ValidationError')->during( - 'create' - ); - } - - public function it_should_use_the_configured_judo_id_if_one_is_not_provided() - { - $this->beConstructedWith( - $this->concoctRequest('transactions/android_payment.json') - ); - - $modelBuilder = new AndroidPaymentBuilder(); - - // Set an empty Judo ID to make sure the config value is used - $modelBuilder->unsetAttribute('judoId'); - /** @var AndroidPayment|AndroidPaymentSpec $this */ - $this->setAttributeValues( - $modelBuilder->compile()->getAttributeValues() - ); - $this->create(); - - $this->getAttributeValue('judoId')->shouldEqual('123-456'); - } - - public function it_properly_coerces_wallet_field_from_json() - { - $input = array( - 'wallet' => '{"wallet":{"encryptedMessage":"SomeBase64encodedData","environment":1,' - .'"ephemeralPublicKey":"SomeBase64encodedData","googleTransactionId":"someId",' - .'"instrumentDetails":"1234","instrumentType":"VISA","publicKey":"SomeBase64encodedData",' - .'"tag":"SomeBase64encodedData","version":1}}', - ); - - $walletObj = new Wallet( - array( - "encryptedMessage" => "SomeBase64encodedData", - "environment" => 1, - "ephemeralPublicKey" => "SomeBase64encodedData", - "googleTransactionId" => "someId", - "instrumentDetails" => "1234", - "instrumentType" => "VISA", - "publicKey" => "SomeBase64encodedData", - "tag" => "SomeBase64encodedData", - "version" => 1, - ) - ); - - $expectedOutput = $walletObj->toObject(); - - /** @var AndroidPayment|AndroidPaymentSpec $this */ - $this->setAttributeValues($input); - $this->getAttributeValue('wallet')->shouldBeLike($expectedOutput); - } - - public function it_should_raise_an_error_when_bad_wallet_passed() - { - /** @var AndroidPayment|AndroidPaymentSpec $this */ - $this->shouldThrow( - new ValidationError(sprintf(Wallet::ERROR_MESSAGE_INVALID_JSON, 'Judopay\Model\Inner\Wallet')) - ) - ->during( - 'setAttributeValues', - array(array('wallet' => '{"someInvalidJson}}')) - ); - - $this->shouldThrow( - new ValidationError(sprintf(Wallet::ERROR_MESSAGE_CORRUPTED_OBJECT, 'Judopay\Model\Inner\Wallet')) - ) - ->during( - 'setAttributeValues', - array(array('wallet' => 1)) - ); - - $this->shouldThrow( - new ValidationError( - 'Judopay\Model\Inner\Wallet object misses required fields', - array( - 'encryptedMessage is missing or empty', - 'environment is missing or empty', - 'ephemeralPublicKey is missing or empty', - 'googleTransactionId is missing or empty', - 'instrumentDetails is missing or empty', - 'instrumentType is missing or empty', - 'publicKey is missing or empty', - 'tag is missing or empty', - 'version is missing or empty', - ) - ) - ) - ->during( - 'setAttributeValues', - array(array('wallet' => '{"wallet":{}}')) - ); - } -} diff --git a/spec/fixtures/transactions/android_payment.json b/spec/fixtures/transactions/android_payment.json deleted file mode 100644 index b968947..0000000 --- a/spec/fixtures/transactions/android_payment.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "receiptId": "xxxxxxx", - "yourPaymentReference": "xxxxxxxxxxxxxxxxxxxxxx", - "type": "Payment", - "createdAt": "2016-11-03T15:02:26.8290+00:00", - "result": "Success", - "message": "AuthCode: xxxxxx", - "judoId": "xxxxxxxxx", - "merchantName": "xxxxxxxxxxxx", - "appearsOnStatementAs": "xxxxxxxxxxxxx", - "originalAmount": "0.02", - "netAmount": "0.02", - "amount": "0.02", - "currency": "GBP", - "cardDetails": { - "cardLastfour": "xxxx", - "endDate": "xxxx", - "cardToken": "xxxx", - "cardType": 1 - }, - "consumer": { - "consumerToken": "xxxxxxxxxxxxxx", - "yourConsumerReference": "xxxxxxxxxxxxxxxx" - }, - "walletType": 2 -} diff --git a/src/Judopay/Model/AndroidPayment.php b/src/Judopay/Model/AndroidPayment.php deleted file mode 100644 index e453cdc..0000000 --- a/src/Judopay/Model/AndroidPayment.php +++ /dev/null @@ -1,32 +0,0 @@ - DataType::TYPE_STRING, - 'yourPaymentReference' => DataType::TYPE_STRING, - 'yourPaymentMetaData' => DataType::TYPE_OBJECT, - 'judoId' => DataType::TYPE_STRING, - 'amount' => DataType::TYPE_FLOAT, - 'currency' => DataType::TYPE_STRING, - 'clientDetails' => DataType::TYPE_OBJECT, - 'wallet' => DataType::TYPE_WALLET, - ); - protected $requiredAttributes - = array( - 'yourConsumerReference', - 'yourPaymentReference', - 'judoId', - 'amount', - 'currency', - 'wallet', - ); -} diff --git a/src/Judopay/Model/AndroidPreauth.php b/src/Judopay/Model/AndroidPreauth.php deleted file mode 100644 index b31cecb..0000000 --- a/src/Judopay/Model/AndroidPreauth.php +++ /dev/null @@ -1,8 +0,0 @@ -attributeValues = array( - "wallet" => array( - "encryptedMessage" => "ZW5jcnlwdGVkTWVzc2FnZQ==", - "environment" => 3, - "ephemeralPublicKey" => "ZXBoZW1lcmFsUHVibGljS2V5", - "googleTransactionId" => "123456789", - "instrumentDetails" => "1234", - "instrumentType" => "VISA", - "publicKey" => "someKey", - "tag" => "c2lnbmF0dXJl", - "version" => 1, - ), - "yourConsumerReference" => "AndroidPayTest", - "amount" => 0.10, - "currency" => "GBP", - "clientDetails" => array( - "key" => "someKey", - "value" => "somevalue", - ), - ); - } -}