diff --git a/README.md b/README.md index b912541..cfd3250 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ composer require league/omnipay omnipay/mollie The following gateways are provided by this package: * Mollie +* Mollie_Connect For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay) repository. diff --git a/src/ConnectGateway.php b/src/ConnectGateway.php new file mode 100644 index 0000000..2e9e5df --- /dev/null +++ b/src/ConnectGateway.php @@ -0,0 +1,161 @@ + '' + ); + } + + /** + * @return string + */ + public function getApiKey() + { + return $this->getParameter('apiKey'); + } + + /** + * @param string $value + * @return $this + */ + public function setApiKey($value) + { + return $this->setParameter('apiKey', $value); + } + + /** + * @param array $parameters + * @return ConnectFetchIssuersRequest + */ + public function fetchIssuers(array $parameters = []) + { + /** @var ConnectFetchIssuersRequest $request */ + $request = $this->createRequest(ConnectFetchIssuersRequest::class, $parameters); + + return $request; + } + + /** + * @param array $parameters + * @return ConnectFetchPaymentMethodsRequest + */ + public function fetchPaymentMethods(array $parameters = []) + { + /** @var ConnectFetchPaymentMethodsRequest $request */ + $request = $this->createRequest(ConnectFetchPaymentMethodsRequest::class, $parameters); + + return $request; + } + + /** + * @param array $parameters + * @return ConnectFetchTransactionRequest + */ + public function fetchTransaction(array $parameters = []) + { + /** @var ConnectFetchTransactionRequest $request */ + $request = $this->createRequest(ConnectFetchTransactionRequest::class, $parameters); + + return $request; + } + + /** + * @param array $parameters + * @return ConnectPurchaseRequest + */ + public function purchase(array $parameters = []) + { + /** @var ConnectPurchaseRequest $request */ + $request = $this->createRequest(ConnectPurchaseRequest::class, $parameters); + + return $request; + } + + /** + * @param array $parameters + * @return CompletePurchaseRequest + */ + public function completePurchase(array $parameters = []) + { + /** @var ConnectCompletePurchaseRequest $request */ + $request = $this->createRequest(ConnectCompletePurchaseRequest::class, $parameters); + + return $request; + } + + /** + * @param array $parameters + * @return ConnectRefundRequest + */ + public function refund(array $parameters = []) + { + /** @var ConnectRefundRequest $request */ + $request = $this->createRequest(ConnectRefundRequest::class, $parameters); + + return $request; + } + + /** + * @param array $parameters + * @return ConnectCreateCustomerRequest + */ + public function createCustomer(array $parameters = []) + { + /** @var ConnectCreateCustomerRequest $request */ + $request = $this->createRequest(ConnectCreateCustomerRequest::class, $parameters); + + return $request; + } + + /** + * @param array $parameters + * @return ConnectUpdateCustomerRequest + */ + public function updateCustomer(array $parameters = []) + { + /** @var ConnectUpdateCustomerRequest $request */ + $request = $this->createRequest(ConnectUpdateCustomerRequest::class, $parameters); + + return $request; + } + + /** + * @param array $parameters + * @return ConnectFetchCustomerRequest + */ + public function fetchCustomer(array $parameters = []) + { + /** @var ConnectFetchCustomerRequest $request */ + $request = $this->createRequest(ConnectFetchCustomerRequest::class, $parameters); + + return $request; + } +} diff --git a/src/Message/Request/AbstractMollieRequest.php b/src/Message/Request/AbstractMollieRequest.php index d66d7ae..9ee9cdd 100755 --- a/src/Message/Request/AbstractMollieRequest.php +++ b/src/Message/Request/AbstractMollieRequest.php @@ -41,6 +41,23 @@ public function setApiKey($value) return $this->setParameter('apiKey', $value); } + /** + * @return string + */ + public function getProfileId() + { + return $this->getParameter('profileId'); + } + + /** + * @param string $value + * @return $this + */ + public function setProfileId($value) + { + return $this->setParameter('profileId', $value); + } + /** * @param string $value * @return $this diff --git a/src/Message/Request/ConnectCompletePurchaseRequest.php b/src/Message/Request/ConnectCompletePurchaseRequest.php new file mode 100644 index 0000000..e3e5d5f --- /dev/null +++ b/src/Message/Request/ConnectCompletePurchaseRequest.php @@ -0,0 +1,54 @@ +validate('apiKey'); + + $data = []; + $data['id'] = $this->getTransactionReference(); + + if ($this->getTestMode()) { + $data['testmode'] = $this->getTestMode(); + } + + if (!isset($data['id'])) { + $data['id'] = $this->httpRequest->request->get('id'); + } + + if (empty($data['id'])) { + throw new InvalidRequestException("The transactionReference parameter is required"); + } + + return $data; + } + + /** + * @param array $data + * @return CompletePurchaseResponse + */ + public function sendData($data) + { + $queryString = isset($data['testmode']) ? '?testmode=' . var_export($data['testmode'], true) : ''; + + $response = $this->sendRequest(self::GET, '/payments/' . $data['id'] . $queryString); + + return $this->response = new CompletePurchaseResponse($this, $response); + } +} diff --git a/src/Message/Request/ConnectCreateCustomerRequest.php b/src/Message/Request/ConnectCreateCustomerRequest.php new file mode 100644 index 0000000..4203899 --- /dev/null +++ b/src/Message/Request/ConnectCreateCustomerRequest.php @@ -0,0 +1,51 @@ +validate('apiKey', 'description', 'email'); + + $data = []; + $data['name'] = $this->getDescription(); + $data['email'] = $this->getEmail(); + $data['locale'] = $this->getLocale(); + + if ($this->getMetadata()) { + $data['metadata'] = $this->getMetadata(); + } + + if ($this->getTestMode()) { + $data['testmode'] = $this->getTestMode(); + } + + return $data; + } + + /** + * @param array $data + * @return CreateCustomerResponse + */ + public function sendData($data) + { + $response = $this->sendRequest(self::POST, '/customers', $data); + + return $this->response = new CreateCustomerResponse($this, $response); + } +} diff --git a/src/Message/Request/ConnectFetchCustomerRequest.php b/src/Message/Request/ConnectFetchCustomerRequest.php new file mode 100644 index 0000000..6d8301a --- /dev/null +++ b/src/Message/Request/ConnectFetchCustomerRequest.php @@ -0,0 +1,46 @@ +validate('apiKey', 'customerReference'); + + $data = []; + + if ($this->getTestMode()) { + $data['testmode'] = $this->getTestMode(); + } + + return $data; + } + + /** + * @param array $data + * @return FetchCustomerResponse + */ + public function sendData($data) + { + $queryString = isset($data['testmode']) ? '?testmode=' . var_export($data['testmode'], true) : ''; + + $response = $this->sendRequest(self::GET, '/customers/' . $this->getCustomerReference() . $queryString); + + return $this->response = new FetchCustomerResponse($this, $response); + } +} diff --git a/src/Message/Request/ConnectFetchIssuersRequest.php b/src/Message/Request/ConnectFetchIssuersRequest.php new file mode 100644 index 0000000..32f637a --- /dev/null +++ b/src/Message/Request/ConnectFetchIssuersRequest.php @@ -0,0 +1,52 @@ +validate('apiKey', 'profileId'); + + $data = []; + $data['profileId'] = $this->getProfileId(); + + if ($this->getTestMode()) { + $data['testmode'] = $this->getTestMode(); + } + + if (empty($data['profileId'])) { + throw new InvalidRequestException("The profileId parameter is required"); + } + + return $data; + } + + /** + * @param array $data + * @return ResponseInterface|FetchIssuersResponse + */ + public function sendData($data) + { + $queryString = "&profileId=" . $data['profileId']; + $queryString .= isset($data['testmode']) ? '&testmode=' . var_export($data['testmode'], true) : ''; + + $response = $this->sendRequest(self::GET, $this->endpoint . $queryString); + + return $this->response = new FetchIssuersResponse($this, $response); + } +} diff --git a/src/Message/Request/ConnectFetchPaymentMethodsRequest.php b/src/Message/Request/ConnectFetchPaymentMethodsRequest.php new file mode 100644 index 0000000..987e0f4 --- /dev/null +++ b/src/Message/Request/ConnectFetchPaymentMethodsRequest.php @@ -0,0 +1,52 @@ +validate('apiKey', 'profileId'); + + $data = []; + $data['profileId'] = $this->getProfileId(); + + if ($this->getTestMode()) { + $data['testmode'] = $this->getTestMode(); + } + + if (empty($data['profileId'])) { + throw new InvalidRequestException("The profileId parameter is required"); + } + + return $data; + } + + /** + * @param array $data + * @return ResponseInterface|FetchPaymentMethodsResponse + */ + public function sendData($data) + { + $queryString = "?profileId=" . $data['profileId']; + $queryString .= isset($data['testmode']) ? '&testmode=' . var_export($data['testmode'], true) : ''; + + $response = $this->sendRequest(self::GET, '/methods' . $queryString); + + return $this->response = new FetchPaymentMethodsResponse($this, $response); + } +} diff --git a/src/Message/Request/ConnectFetchTransactionRequest.php b/src/Message/Request/ConnectFetchTransactionRequest.php new file mode 100644 index 0000000..775986e --- /dev/null +++ b/src/Message/Request/ConnectFetchTransactionRequest.php @@ -0,0 +1,47 @@ +validate('apiKey', 'transactionReference'); + + $data = []; + $data['id'] = $this->getTransactionReference(); + + if ($this->getTestMode()) { + $data['testmode'] = $this->getTestMode(); + } + + return $data; + } + + /** + * @param array $data + * @return ResponseInterface|FetchTransactionResponse + */ + public function sendData($data) + { + $queryString = isset($data['testmode']) ? '?testmode=' . var_export($data['testmode'], true) : ''; + + $response = $this->sendRequest(self::GET, '/payments/' . $data['id'] . $queryString); + + return $this->response = new FetchTransactionResponse($this, $response); + } +} diff --git a/src/Message/Request/ConnectPurchaseRequest.php b/src/Message/Request/ConnectPurchaseRequest.php new file mode 100644 index 0000000..1846309 --- /dev/null +++ b/src/Message/Request/ConnectPurchaseRequest.php @@ -0,0 +1,131 @@ +setParameter('applicationFeeAmount', $value); + } + + /** + * @param $value + * @return $this + */ + public function setApplicationFeeDescription($value) + { + return $this->setParameter('applicationFeeDescription', $value); + } + + /** + * @param $value + * @return $this + */ + public function setApplicationFeeCurrency($value) + { + return $this->setParameter('applicationFeeCurrency', $value); + } + + /** + * @return string + */ + public function getApplicationFeeAmount() + { + return $this->getParameter('applicationFeeAmount'); + } + + /** + * @return string + */ + public function getApplicationFeeDescription() + { + return $this->getParameter('applicationFeeDescription'); + } + + /** + * @return string + */ + public function getApplicationFeeCurrency() + { + return $this->getParameter('applicationFeeCurrency'); + } + + /** + * @return array + * @throws InvalidRequestException + */ + public function getData() + { + $this->validate('apiKey', 'amount', 'currency', 'description', 'returnUrl', 'profileId'); + + $data = []; + $data['amount'] = [ + "value" => $this->getAmount(), + "currency" => $this->getCurrency() + ]; + $data['description'] = $this->getDescription(); + $data['redirectUrl'] = $this->getReturnUrl(); + $data['method'] = $this->getPaymentMethod(); + $data['metadata'] = $this->getMetadata(); + $data['profileId'] = $this->getProfileId(); + + if ($this->getTestMode()) { + $data['testmode'] = $this->getTestMode(); + } + + if ($this->getTransactionId()) { + $data['metadata']['transactionId'] = $this->getTransactionId(); + } + + if ($issuer = $this->getIssuer()) { + $data['issuer'] = $issuer; + } + + $webhookUrl = $this->getNotifyUrl(); + if (null !== $webhookUrl) { + $data['webhookUrl'] = $webhookUrl; + } + + if ($locale = $this->getLocale()) { + $data['locale'] = $locale; + } + + if ($billingEmail = $this->getBillingEmail()) { + $data['billingEmail'] = $billingEmail; + } + + if ($this->getApplicationFeeAmount() && + $this->getApplicationFeeCurrency() && + $this->getApplicationFeeDescription() + ) { + $data['applicationFee'] = array( + 'amount' => array( + 'value' => $this->getApplicationFeeAmount(), + 'currency' => $this->getApplicationFeeCurrency(), + ), + 'description' => $this->getApplicationFeeDescription() + ); + } + + if (empty($data['profileId'])) { + throw new InvalidRequestException("The profileId parameter is required"); + } + + return $data; + } +} diff --git a/src/Message/Request/ConnectRefundRequest.php b/src/Message/Request/ConnectRefundRequest.php new file mode 100644 index 0000000..4ffc739 --- /dev/null +++ b/src/Message/Request/ConnectRefundRequest.php @@ -0,0 +1,60 @@ +validate('apiKey', 'transactionReference', 'amount', 'currency'); + + $data = []; + + $data['amount'] = [ + "value" => $this->getAmount(), + "currency" => $this->getCurrency() + ]; + + if ($this->getTestMode()) { + $data['testmode'] = $this->getTestMode(); + } + + if (is_string($this->getParameter('description'))) { + $data['description'] = $this->getParameter('description'); + } + + return $data; + } + + /** + * @param array $data + * @return ResponseInterface|RefundResponse + */ + public function sendData($data) + { + $response = $this->sendRequest( + self::POST, + '/payments/' . $this->getTransactionReference() . '/refunds', + $data + ); + + return $this->response = new RefundResponse($this, $response); + } +} diff --git a/src/Message/Request/ConnectUpdateCustomerRequest.php b/src/Message/Request/ConnectUpdateCustomerRequest.php new file mode 100644 index 0000000..cbcf5f8 --- /dev/null +++ b/src/Message/Request/ConnectUpdateCustomerRequest.php @@ -0,0 +1,51 @@ +validate('apiKey', 'customerReference'); + + $data = []; + $data['name'] = $this->getDescription(); + $data['email'] = $this->getEmail(); + $data['locale'] = $this->getLocale(); + + if ($this->getMetadata()) { + $data['metadata'] = $this->getMetadata(); + } + + if ($this->getTestMode()) { + $data['testmode'] = $this->getTestMode(); + } + + return $data; + } + + /** + * @param array $data + * @return UpdateCustomerResponse + */ + public function sendData($data) + { + $response = $this->sendRequest(self::POST, '/customers/' . $this->getCustomerReference(), $data); + + return $this->response = new UpdateCustomerResponse($this, $response); + } +} diff --git a/tests/ConnectGatewayTest.php b/tests/ConnectGatewayTest.php new file mode 100644 index 0000000..862bf18 --- /dev/null +++ b/tests/ConnectGatewayTest.php @@ -0,0 +1,190 @@ +gateway = new ConnectGateway(); + } + + public function testFetchIssuers() + { + $request = $this->gateway->fetchIssuers(array('profileId' => 'pfl_3RkSN1zuPE', 'testmode' => true)); + + $this->assertInstanceOf(ConnectFetchIssuersRequest::class, $request); + $this->assertSame('pfl_3RkSN1zuPE', $request->getProfileId()); + $this->assertSame(true, $request->getTestMode()); + } + + public function testFetchPaymentMethods() + { + $request = $this->gateway->fetchPaymentMethods(array('profileId' => 'pfl_3RkSN1zuPE', 'testmode' => true)); + + $this->assertInstanceOf(ConnectFetchPaymentMethodsRequest::class, $request); + $this->assertSame('pfl_3RkSN1zuPE', $request->getProfileId()); + $this->assertSame(true, $request->getTestMode()); + } + + /** + * @throws InvalidRequestException + */ + public function testPurchase() + { + $request = $this->gateway->purchase(array('amount' => '10.00', 'currency' => 'EUR', 'profileId' => 'pfl_3RkSN1zuPE', 'testmode' => true)); + + $this->assertInstanceOf(ConnectPurchaseRequest::class, $request); + $this->assertSame('10.00', $request->getAmount()); + $this->assertSame('EUR', $request->getCurrency()); + $this->assertSame('pfl_3RkSN1zuPE', $request->getProfileId()); + $this->assertSame(true, $request->getTestMode()); + } + + /** + * @throws InvalidRequestException + */ + public function testPurchaseReturn() + { + $request = $this->gateway->completePurchase(array('amount' => '10.00', 'currency' => 'EUR', 'testmode' => true)); + + $this->assertInstanceOf(ConnectCompletePurchaseRequest::class, $request); + $this->assertSame('10.00', $request->getAmount()); + $this->assertSame('EUR', $request->getCurrency()); + $this->assertSame(true, $request->getTestMode()); + } + + public function testRefund() + { + $request = $this->gateway->refund( + array( + 'apiKey' => 'key', + 'transactionReference' => 'tr_Qzin4iTWrU', + 'amount' => '10.00', + 'currency' => 'EUR', + 'testmode' => true, + ) + ); + + $this->assertInstanceOf(ConnectRefundRequest::class, $request); + $data = $request->getData(); + $this->assertSame( + [ + 'value' => '10.00', + 'currency' => 'EUR' + ], + $data['amount'] + ); + $this->assertSame(true, $data['testmode']); + } + + /** + * @expectedException \Omnipay\Common\Exception\InvalidRequestException + */ + public function testThatRefundDoesntWorkWithoutAmount() + { + $request = $this->gateway->refund( + array( + 'apiKey' => 'key', + 'transactionReference' => 'tr_Qzin4iTWrU', + 'testmode' => true, + ) + ); + + $this->assertInstanceOf(ConnectRefundRequest::class, $request); + $request->getData(); + } + + public function testFetchTransaction() + { + $request = $this->gateway->fetchTransaction( + array( + 'apiKey' => 'key', + 'transactionReference' => 'tr_Qzin4iTWrU', + 'testmode' => true + ) + ); + + $this->assertInstanceOf(ConnectFetchTransactionRequest::class, $request); + + $data = $request->getData(); + $this->assertSame('tr_Qzin4iTWrU', $data['id']); + $this->assertSame(true, $data['testmode']); + } + + public function testCreateCustomer() + { + $request = $this->gateway->createCustomer( + array( + 'description' => 'Test name', + 'email' => 'test@example.com', + 'metadata' => 'Something something something dark side.', + 'locale' => 'nl_NL', + 'testmode' => true, + ) + ); + + $data = $request->getData(); + + $this->assertInstanceOf(ConnectCreateCustomerRequest::class, $request); + $this->assertSame(true, $data['testmode']); + } + + public function testUpdateCustomer() + { + $request = $this->gateway->updateCustomer( + array( + 'customerReference' => 'cst_bSNBBJBzdG', + 'description' => 'Test name2', + 'email' => 'test@example.com', + 'metadata' => 'Something something something dark side.', + 'locale' => 'nl_NL', + 'testmode' => true, + ) + ); + + $this->assertInstanceOf(ConnectUpdateCustomerRequest::class, $request); + + $data = $request->getData(); + + $this->assertSame('Test name2', $data['name']); + $this->assertSame(true, $data['testmode']); + } + + public function testFetchCustomer() + { + $request = $this->gateway->fetchCustomer( + array( + 'apiKey' => 'key', + 'customerReference' => 'cst_bSNBBJBzdG', + 'testmode' => true, + ) + ); + + $data = $request->getData(); + + $this->assertInstanceOf(ConnectFetchCustomerRequest::class, $request); + + $this->assertSame(true, $data['testmode']); + } +} diff --git a/tests/Message/ConnectCompletePurchaseRequestTest.php b/tests/Message/ConnectCompletePurchaseRequestTest.php new file mode 100644 index 0000000..d9afe5f --- /dev/null +++ b/tests/Message/ConnectCompletePurchaseRequestTest.php @@ -0,0 +1,87 @@ +request = new ConnectCompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize(array( + 'apiKey' => 'mykey', + 'testmode' => true, + )); + + $this->getHttpRequest()->request->replace(array( + 'id' => 'tr_98nUH7v5bT', + )); + } + + /** + * @expectedException \Omnipay\Common\Exception\InvalidRequestException + * @expectedExceptionMessage The transactionReference parameter is required + */ + public function testGetDataWithoutIDParameter() + { + $this->getHttpRequest()->request->remove('id'); + $this->getHttpRequest()->request->remove('testmode'); + + $data = $this->request->getData(); + + $this->assertEmpty($data); + } + + /** + * @throws \Omnipay\Common\Exception\InvalidRequestException + */ + public function testGetData() + { + $data = $this->request->getData(); + + $this->assertSame("tr_98nUH7v5bT", $data['id']); + $this->assertSame(true, $data['testmode']); + $this->assertCount(2, $data); + } + + public function testSendSuccess() + { + $this->setMockHttpResponse('ConnectCompletePurchaseSuccess.txt'); + $response = $this->request->send(); + + $this->assertEqualRequest(new Request("GET", "https://api.mollie.com/v2/payments/tr_98nUH7v5bT?testmode=true"), $this->getMockClient()->getLastRequest()); + + $this->assertInstanceOf(CompletePurchaseResponse::class, $response); + $this->assertTrue($response->isSuccessful()); + $this->assertFalse($response->isOpen()); + $this->assertTrue($response->isPaid()); + $this->assertFalse($response->isRedirect()); + $this->assertSame('tr_98nUH7v5bT', $response->getTransactionReference()); + } + + public function testSendExpired() + { + $this->setMockHttpResponse('ConnectCompletePurchaseExpired.txt'); + $response = $this->request->send(); + + $this->assertEqualRequest(new Request("GET", "https://api.mollie.com/v2/payments/tr_98nUH7v5bT?testmode=true"), $this->getMockClient()->getLastRequest()); + + $this->assertInstanceOf(CompletePurchaseResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertFalse($response->isPaid()); + $this->assertTrue($response->isExpired()); + $this->assertFalse($response->isRedirect()); + $this->assertSame('tr_98nUH7v5bT', $response->getTransactionReference()); + } +} diff --git a/tests/Message/ConnectCreateCustomerRequestTest.php b/tests/Message/ConnectCreateCustomerRequestTest.php new file mode 100644 index 0000000..2dbc411 --- /dev/null +++ b/tests/Message/ConnectCreateCustomerRequestTest.php @@ -0,0 +1,102 @@ +request = new ConnectCreateCustomerRequest($this->getHttpClient(), $this->getHttpRequest()); + + $this->request->initialize(array( + 'apiKey' => 'mykey', + 'description' => 'John Doe - Mollie Connect', + 'email' => 'john@doe.com', + 'locale' => 'nl_NL', + 'metadata' => 'Just some meta data.', + 'testmode' => true, + )); + } + + /** + * @throws InvalidRequestException + */ + public function testData() + { + $this->request->initialize(array( + 'apiKey' => 'mykey', + 'description' => 'John Doe - Mollie Connect', + 'email' => 'john@doe.com', + 'metadata' => 'Just some meta data.', + 'testmode' => true, + )); + $data = $this->request->getData(); + + $this->assertSame("John Doe - Mollie Connect", $data['name']); + $this->assertSame('john@doe.com', $data['email']); + $this->assertSame('Just some meta data.', $data['metadata']); + $this->assertSame(true, $data['testmode']); + $this->assertCount(5, $data); + } + + public function testSendSuccess() + { + $this->setMockHttpResponse('ConnectCreateCustomerSuccess.txt'); + + /** @var ConnectCreateCustomerRequest $response */ + $response = $this->request->send(); + + $this->assertEqualRequest( + new Request( + "POST", + "https://api.mollie.com/v2/customers", + [], + '{ + "name":"John Doe - Mollie Connect", + "email":"john@doe.com", + "metadata":"Just some meta data.", + "locale":"nl_NL", + "testmode":true + }' + ), + $this->getMockClient()->getLastRequest() + ); + + $this->assertInstanceOf(CreateCustomerResponse::class, $response); + $this->assertSame('cst_EEbQf6Q4hM', $response->getCustomerReference()); + + $this->assertTrue($response->isSuccessful()); + $this->assertJsonStringEqualsJsonString( + '{"resource":"customer","id":"cst_EEbQf6Q4hM","mode":"test","name":"John Doe - Mollie Connect","email":"john@doe.com","locale":null,"metadata":"Just some meta data.","createdAt":"2018-07-26T13:44:48+00:00","_links":{"self":{"href":"https://api.mollie.com/v2/customers/cst_EEbQf6Q4hM","type":"application/hal+json"},"documentation":{"href":"https://docs.mollie.com/reference/v2/customers-api/create-customer","type":"text/html"}}}', + $response->getMessage() + ); + } + + public function testSendFailure() + { + $this->setMockHttpResponse('ConnectCreateCustomerFailure.txt'); + $response = $this->request->send(); + + $this->assertEqualRequest(new Request("POST", "https://api.mollie.com/v2/customers"), $this->getMockClient()->getLastRequest()); + + $this->assertInstanceOf(CreateCustomerResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertFalse($response->isRedirect()); + $this->assertNull($response->getTransactionReference()); + $this->assertSame('{"status":401,"title":"Unauthorized Request","detail":"Missing authentication, or failed to authenticate","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/authentication","type":"text\/html"}}}', $response->getMessage()); + } +} \ No newline at end of file diff --git a/tests/Message/ConnectFetchCustomerRequestTest.php b/tests/Message/ConnectFetchCustomerRequestTest.php new file mode 100644 index 0000000..02ef377 --- /dev/null +++ b/tests/Message/ConnectFetchCustomerRequestTest.php @@ -0,0 +1,78 @@ +request = new ConnectFetchCustomerRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize( + array( + 'apiKey' => 'mykey', + 'customerReference' => 'cst_EEbQf6Q4hM', + 'testmode' => true + ) + ); + } + + /** + * @throws InvalidRequestException + */ + public function testGetData() + { + $data = $this->request->getData(); + + $this->assertCount(1, $data); + + $this->assertSame(true, $data['testmode']); + } + + public function testSendSuccess() + { + $this->setMockHttpResponse('ConnectFetchCustomerSuccess.txt'); + + /** @var ConnectFetchCustomerRequest $response */ + $response = $this->request->send(); + + $this->assertEqualRequest(new Request("GET", "https://api.mollie.com/v2/customers/cst_EEbQf6Q4hM?testmode=true"), $this->getMockClient()->getLastRequest()); + + $this->assertInstanceOf(FetchCustomerResponse::class, $response); + $this->assertSame('cst_EEbQf6Q4hM', $response->getCustomerReference()); + + $this->assertTrue($response->isSuccessful()); + $this->assertJsonStringEqualsJsonString( + '{"resource":"customer","id":"cst_EEbQf6Q4hM","mode":"test","name":"Jane Roe - Mollie Connect","email":"john@doe.com","locale":null,"metadata":"Just some meta data.","createdAt":"2018-07-26T13:44:48+00:00","_links":{"self":{"href":"https://api.mollie.com/v2/customers/cst_EEbQf6Q4hM?testmode=true","type":"application/hal+json"},"documentation":{"href":"https://docs.mollie.com/reference/v2/customers-api/get-customer","type":"text/html"}}}', + $response->getMessage() + ); + } + + public function testSendFailure() + { + $this->setMockHttpResponse('ConnectFetchCustomerFailure.txt'); + + /** @var ConnectFetchCustomerRequest $response */ + $response = $this->request->send(); + + $this->assertEqualRequest(new Request("GET", "https://api.mollie.com/v2/customers/cst_EEbQf6Q4hM?testmode=true"), $this->getMockClient()->getLastRequest()); + + $this->assertInstanceOf(FetchCustomerResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertFalse($response->isRedirect()); + $this->assertNull($response->getCustomerReference()); + $this->assertSame('{"status":404,"title":"Not Found","detail":"No customer exists with token cst_EEbQf6Q4hM.","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/handling-errors","type":"text\/html"}}}', $response->getMessage()); + } +} diff --git a/tests/Message/ConnectFetchIssuersRequestTest.php b/tests/Message/ConnectFetchIssuersRequestTest.php new file mode 100644 index 0000000..a111402 --- /dev/null +++ b/tests/Message/ConnectFetchIssuersRequestTest.php @@ -0,0 +1,94 @@ +request = new ConnectFetchIssuersRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize(array( + 'apiKey' => 'mykey', + 'profileId' => 'pfl_3RkSN1zuPE', + 'testmode' => true, + )); + } + + /** + * @throws InvalidRequestException + */ + public function testGetData() + { + $data = $this->request->getData(); + + $this->assertCount(2, $data); + + $this->assertSame('pfl_3RkSN1zuPE', $data['profileId']); + $this->assertSame(true, $data['testmode']); + } + + public function testSendSuccess() + { + $this->setMockHttpResponse('ConnectFetchIssuersSuccess.txt'); + $response = $this->request->send(); + + $this->assertEqualRequest( + new Request("GET", "https://api.mollie.com/v2/methods/ideal?include=issuers&profileId=pfl_3RkSN1zuPE&testmode=true"), + $this->getMockClient()->getLastRequest() + ); + + $this->assertInstanceOf(FetchIssuersResponse::class, $response); + $this->assertTrue($response->isSuccessful()); + $this->assertFalse($response->isRedirect()); + $this->assertNull($response->getTransactionReference()); + + $expectedIssues = array( + new Issuer('ideal_ABNANL2A', 'ABN AMRO', 'ideal'), + new Issuer('ideal_ASNBNL21', 'ASN Bank', 'ideal'), + new Issuer('ideal_BUNQNL2A', 'bunq', 'ideal'), + new Issuer('ideal_INGBNL2A', 'ING', 'ideal'), + new Issuer('ideal_KNABNL2H', 'Knab', 'ideal'), + new Issuer('ideal_MOYONL21', 'Moneyou', 'ideal'), + new Issuer('ideal_RABONL2U', 'Rabobank', 'ideal'), + new Issuer('ideal_RBRBNL21', 'RegioBank', 'ideal'), + new Issuer('ideal_SNSBNL2A', 'SNS Bank', 'ideal'), + new Issuer('ideal_TRIONL2U', 'Triodos Bank', 'ideal'), + new Issuer('ideal_FVLBNL22', 'van Lanschot', 'ideal') + ); + + $this->assertEquals($expectedIssues, $response->getIssuers()); + } + + public function testSendFailure() + { + $this->setMockHttpResponse('ConnectFetchIssuersFailure.txt'); + $response = $this->request->send(); + + $this->assertEqualRequest( + new Request("GET", "https://api.mollie.com/v2/methods/ideal?include=issuers&profileId=pfl_3RkSN1zuPE&testmode=true"), + $this->getMockClient()->getLastRequest() + ); + + $this->assertInstanceOf(FetchIssuersResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertFalse($response->isRedirect()); + $this->assertNull($response->getTransactionReference()); + $this->assertSame('{"status":401,"title":"Unauthorized Request","detail":"Missing authentication, or failed to authenticate","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/authentication","type":"text\/html"}}}', $response->getMessage()); + $this->assertEmpty($response->getIssuers()); + } + +} diff --git a/tests/Message/ConnectFetchPaymentMethodsRequestTest.php b/tests/Message/ConnectFetchPaymentMethodsRequestTest.php new file mode 100644 index 0000000..2e15d3f --- /dev/null +++ b/tests/Message/ConnectFetchPaymentMethodsRequestTest.php @@ -0,0 +1,80 @@ +request = new ConnectFetchPaymentMethodsRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize(array( + 'apiKey' => 'mykey', + 'profileId' => 'pfl_3RkSN1zuPE', + 'testmode' => true, + )); + } + + /** + * @throws InvalidRequestException + */ + public function testGetData() + { + $data = $this->request->getData(); + + $this->assertCount(2, $data); + + $this->assertSame('pfl_3RkSN1zuPE', $data['profileId']); + $this->assertSame(true, $data['testmode']); + } + + public function testSendSuccess() + { + $this->setMockHttpResponse('ConnectFetchPaymentMethodsSuccess.txt'); + $response = $this->request->send(); + + $this->assertEqualRequest(new Request("GET", "https://api.mollie.com/v2/methods?profileId=pfl_3RkSN1zuPE&testmode=true"), $this->getMockClient()->getLastRequest()); + + $this->assertInstanceOf(FetchPaymentMethodsResponse::class, $response); + $this->assertTrue($response->isSuccessful()); + $this->assertFalse($response->isRedirect()); + $this->assertNull($response->getTransactionReference()); + $paymentMethods = $response->getPaymentMethods(); + $this->assertCount(2, $paymentMethods); + + $expectedPaymentMethod = array( + new PaymentMethod('ideal', 'iDEAL'), + new PaymentMethod('banktransfer', 'Bank transfer') + ); + + $this->assertEquals($expectedPaymentMethod, $paymentMethods); + } + + public function testSendFailure() + { + $this->setMockHttpResponse('ConnectFetchPaymentMethodsFailure.txt'); + $response = $this->request->send(); + + $this->assertEqualRequest(new Request("GET", "https://api.mollie.com/v2/methods?profileId=pfl_3RkSN1zuPE&testmode=true"), $this->getMockClient()->getLastRequest()); + + $this->assertInstanceOf(FetchPaymentMethodsResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertFalse($response->isRedirect()); + $this->assertNull($response->getTransactionReference()); + $this->assertSame('{"status":401,"title":"Unauthorized Request","detail":"Missing authentication, or failed to authenticate","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/authentication","type":"text\/html"}}}', $response->getMessage()); + $this->assertEmpty($response->getPaymentMethods()); + } +} diff --git a/tests/Message/ConnectFetchTransactionRequestTest.php b/tests/Message/ConnectFetchTransactionRequestTest.php new file mode 100644 index 0000000..9ebbc84 --- /dev/null +++ b/tests/Message/ConnectFetchTransactionRequestTest.php @@ -0,0 +1,109 @@ +request = new ConnectFetchTransactionRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize( + array( + 'apiKey' => 'mykey', + 'transactionReference' => 'tr_98nUH7v5bT', + 'testmode' => true, + ) + ); + } + + /** + * @throws InvalidRequestException + */ + public function testGetData() + { + $data = $this->request->getData(); + + $this->assertSame("tr_98nUH7v5bT", $data['id']); + $this->assertSame(true, $data['testmode']); + $this->assertCount(2, $data); + } + + public function testSendSuccess() + { + $this->setMockHttpResponse('ConnectFetchTransactionSuccess.txt'); + /** @var ConnectFetchTransactionRequest $response */ + $response = $this->request->send(); + + $this->assertEqualRequest( + new Request( + "GET", + "https://api.mollie.com/v2/payments/tr_98nUH7v5bT?testmode=true" + ), + $this->getMockClient()->getLastRequest() + ); + + $this->assertInstanceOf(FetchTransactionResponse::class, $response); + $this->assertTrue($response->isSuccessful()); + $this->assertTrue($response->isPaid()); + $this->assertFalse($response->isCancelled()); + $this->assertFalse($response->isPaidOut()); + $this->assertFalse($response->isRefunded()); + $this->assertFalse($response->isPartialRefunded()); + $this->assertSame("paid", $response->getStatus()); + $this->assertSame('tr_98nUH7v5bT', $response->getTransactionReference()); + $this->assertSame("10.00", $response->getAmount()); + } + + public function testSendExpired() + { + $this->setMockHttpResponse('ConnectFetchTransactionExpired.txt'); + $response = $this->request->send(); + + $this->assertEqualRequest( + new Request( + "GET", + "https://api.mollie.com/v2/payments/tr_98nUH7v5bT?testmode=true" + ), + $this->getMockClient()->getLastRequest() + ); + + $this->assertInstanceOf(FetchTransactionResponse::class, $response); + $this->assertTrue($response->isSuccessful()); + $this->assertSame('tr_98nUH7v5bT', $response->getTransactionReference()); + $this->assertTrue($response->isExpired()); + } + + public function testSendFailure() + { + $this->setMockHttpResponse('ConnectFetchTransaction404Failure.txt'); + $response = $this->request->send(); + + $this->assertEqualRequest( + new Request( + "GET", + "https://api.mollie.com/v2/payments/tr_98nUH7v5bT?testmode=true" + ), + $this->getMockClient()->getLastRequest() + ); + + $this->assertInstanceOf(FetchTransactionResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertFalse($response->isRedirect()); + $this->assertNull($response->getTransactionReference()); + $this->assertEquals(404, $response->getStatus()); + $this->assertNull($response->getAmount()); + } +} diff --git a/tests/Message/ConnectPurchaseRequestTest.php b/tests/Message/ConnectPurchaseRequestTest.php new file mode 100644 index 0000000..c462fcf --- /dev/null +++ b/tests/Message/ConnectPurchaseRequestTest.php @@ -0,0 +1,170 @@ +request = new ConnectPurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize(array( + 'apiKey' => 'mykey', + "amount" => "10.00", + "currency" => "EUR", + "description" => "My first Payment", + "returnUrl" => "https://webshop.example.org/mollie-return.php", + "profileId" => "pfl_3RkSN1zuPE", + 'testmode' => true, + )); + } + + /** + * @throws InvalidRequestException + */ + public function testGetData() + { + $this->request->initialize([ + 'apiKey' => 'mykey', + "amount" => "10.00", + "currency" => "EUR", + "description" => "My first Payment", + "returnUrl" => "https://webshop.example.org/mollie-return.php", + "profileId" => "pfl_3RkSN1zuPE", + 'testmode' => true, + ]); + + $data = $this->request->getData(); + + $this->assertSame(["value" => "10.00", "currency" => "EUR"], $data['amount']); + $this->assertSame("My first Payment", $data['description']); + $this->assertSame('https://webshop.example.org/mollie-return.php', $data['redirectUrl']); + $this->assertCount(7, $data); + } + + /** + * @throws InvalidRequestException + */ + public function testGetDataWithWebhook() + { + $this->request->initialize(array( + 'apiKey' => 'mykey', + "amount" => "10.00", + "currency" => "EUR", + "description" => "My first Payment", + "returnUrl" => "https://webshop.example.org/mollie-return.php", + "profileId" => "pfl_3RkSN1zuPE", + 'testmode' => true, + 'notifyUrl' => 'https://www.example.com/hook', + )); + + $data = $this->request->getData(); + + $this->assertSame(["value" => "10.00", "currency" => "EUR"], $data['amount']); + $this->assertSame('My first Payment', $data['description']); + $this->assertSame('https://webshop.example.org/mollie-return.php', $data['redirectUrl']); + $this->assertSame('https://www.example.com/hook', $data['webhookUrl']); + $this->assertCount(8, $data); + } + + public function testGetDataWithApplicationFee() + { + $this->request->initialize(array( + 'apiKey' => 'mykey', + "amount" => "10.00", + "currency" => "EUR", + "description" => "My first Payment", + "returnUrl" => "https://webshop.example.org/mollie-return.php", + "profileId" => "pfl_3RkSN1zuPE", + 'testmode' => true, + 'notifyUrl' => 'https://www.example.com/hook', + 'applicationFeeAmount' => '0.37', + 'applicationFeeCurrency' => 'EUR', + 'applicationFeeDescription' => 'applicationFee to use Mollie Connect' + )); + + $data = $this->request->getData(); + + $this->assertSame(["value" => "10.00", "currency" => "EUR"], $data['amount']); + $this->assertSame('My first Payment', $data['description']); + $this->assertSame('https://webshop.example.org/mollie-return.php', $data['redirectUrl']); + $this->assertSame('https://www.example.com/hook', $data['webhookUrl']); + $this->assertSame(["amount" => ["value" => "0.37", "currency" => "EUR"], "description" => "applicationFee to use Mollie Connect"], $data['applicationFee']); + $this->assertCount(9, $data); + } + + public function testSendSuccess() + { + $this->setMockHttpResponse('ConnectPurchaseSuccess.txt'); + $response = $this->request->send(); + + $this->assertEqualRequest( + new Request( + "POST", + "https://api.mollie.com/v2/payments", + [], + '{ + "amount":{ + "value":"10.00", + "currency":"EUR" + }, + "description":"My first Payment", + "redirectUrl":"https:\/\/webshop.example.org\/mollie-return.php", + "method":null, + "metadata":null, + "profileId":"pfl_3RkSN1zuPE", + "testmode":true + }' + ), + $this->getMockClient()->getLastRequest() + ); + + $this->assertInstanceOf(PurchaseResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertTrue($response->isRedirect()); + $this->assertSame('GET', $response->getRedirectMethod()); + $this->assertSame('https://www.mollie.com/payscreen/select-method/jdsTnrTT3R', $response->getRedirectUrl()); + $this->assertNull($response->getRedirectData()); + $this->assertSame('tr_jdsTnrTT3R', $response->getTransactionReference()); + $this->assertTrue($response->isOpen()); + $this->assertFalse($response->isPaid()); + $this->assertNull($response->getCode()); + $this->assertJsonStringEqualsJsonString( + '{"resource":"payment","id":"tr_jdsTnrTT3R","mode":"test","createdAt":"2018-07-27T07:10:14+00:00","amount":{"value":"10.00","currency":"EUR"},"description":"My first Payment","method":null,"metadata":null,"status":"open","isCancelable":false,"expiresAt":"2018-07-27T07:25:14+00:00","profileId":"pfl_3RkSN1zuPE","sequenceType":"oneoff","redirectUrl":"https://webshop.example.org/mollie-return.php","_links":{"self":{"href":"https://api.mollie.com/v2/payments/tr_jdsTnrTT3R","type":"application/hal+json"},"checkout":{"href":"https://www.mollie.com/payscreen/select-method/jdsTnrTT3R","type":"text/html"},"documentation":{"href":"https://docs.mollie.com/reference/v2/payments-api/create-payment","type":"text/html"}}}', + $response->getMessage() + ); + } + + public function testIssuerFailure() + { + $this->setMockHttpResponse('ConnectPurchaseIssuerFailure.txt'); + $response = $this->request->send(); + + $this->assertEqualRequest( + new Request( + "POST", + "https://api.mollie.com/v2/payments" + ), + $this->getMockClient()->getLastRequest() + ); + + $this->assertInstanceOf(PurchaseResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertFalse($response->isRedirect()); + $this->assertNull($response->getTransactionReference()); + $this->assertNull($response->getRedirectUrl()); + $this->assertNull($response->getRedirectData()); + $this->assertSame('{"status":422,"title":"Unprocessable Entity","detail":"The payment method is invalid","field":"method","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/handling-errors","type":"text\/html"}}}', $response->getMessage()); + } +} diff --git a/tests/Message/ConnectRefundRequestTest.php b/tests/Message/ConnectRefundRequestTest.php new file mode 100644 index 0000000..d0d7c3d --- /dev/null +++ b/tests/Message/ConnectRefundRequestTest.php @@ -0,0 +1,129 @@ +request = new ConnectRefundRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize([ + 'apiKey' => 'mykey', + 'transactionReference' => 'tr_98nUH7v5bT', + 'amount' => '10.00', + 'currency' => 'EUR', + 'testmode' => true, + ]); + } + + /** + * @throws \Omnipay\Common\Exception\InvalidRequestException + */ + public function testGetData() + { + $this->request->initialize([ + 'apiKey' => 'mykey', + 'amount' => '10.00', + 'currency' => 'EUR', + 'transactionReference' => 'tr_98nUH7v5bT', + 'testmode' => true, + ]); + + $data = $this->request->getData(); + + $this->assertSame(["value" => "10.00", "currency" => "EUR"], $data['amount']); + $this->assertSame(true, $data['testmode']); + $this->assertCount(2, $data); + } + + /** + * @expectedException \Omnipay\Common\Exception\InvalidRequestException + */ + public function testGetDataWithoutAmount() + { + $this->request->initialize( + [ + 'apiKey' => 'mykey', + 'transactionReference' => 'tr_98nUH7v5bT', + 'testmode' => true, + ] + ); + + $data = $this->request->getData(); + + $this->assertCount(0, $data); + } + + public function testSendSuccess() + { + $this->setMockHttpResponse('ConnectRefundSuccess.txt'); + /** @var ConnectRefundResponse $response */ + $response = $this->request->send(); + + $this->assertEqualRequest( + new Request( + "POST", + "https://api.mollie.com/v2/payments/tr_98nUH7v5bT/refunds", + [], + '{"amount":{"value":"10.00","currency":"EUR"},"testmode":true}' + ), + $this->getMockClient()->getLastRequest() + ); + + + $this->assertInstanceOf(RefundResponse::class, $response); + $this->assertTrue($response->isSuccessful()); + $this->assertFalse($response->isRedirect()); + $this->assertSame('tr_98nUH7v5bT', $response->getTransactionReference()); + $this->assertSame('re_c5rGsnjbxz', $response->getTransactionId()); + } + + public function test401Failure() + { + $this->setMockHttpResponse('ConnectRefund401Failure.txt'); + /** @var ConnectRefund401Failure $response */ + $response = $this->request->send(); + + $this->assertEqualRequest( + new Request("POST", "https://api.mollie.com/v2/payments/tr_98nUH7v5bT/refunds", [], ''), + $this->getMockClient()->getLastRequest() + ); + + $this->assertInstanceOf(RefundResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertEquals('{"status":401,"title":"Unauthorized Request","detail":"Missing authentication, or failed to authenticate","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/authentication","type":"text\/html"}}}', $response->getMessage()); + } + + public function test422Failure() + { + $this->setMockHttpResponse('ConnectRefund422Failure.txt'); + /** @var ConnectRefundResponse $response */ + $response = $this->request->send(); + + $this->assertEqualRequest( + new Request( + "POST", + "https://api.mollie.com/v2/payments/tr_98nUH7v5bT/refunds", + [], + '{"amount":{"value":"10.00","currency":"EUR"},"testmode":true}' + ), + $this->getMockClient()->getLastRequest() + ); + + $this->assertInstanceOf(RefundResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertEquals('{"status":422,"title":"Unprocessable Entity","detail":"The payment method is invalid","field":"method","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/handling-errors","type":"text\/html"}}}', $response->getMessage()); + } +} diff --git a/tests/Message/ConnectUpdateCustomerRequestTest.php b/tests/Message/ConnectUpdateCustomerRequestTest.php new file mode 100644 index 0000000..7c0c3c6 --- /dev/null +++ b/tests/Message/ConnectUpdateCustomerRequestTest.php @@ -0,0 +1,107 @@ +request = new ConnectUpdateCustomerRequest($this->getHttpClient(), $this->getHttpRequest()); + + $this->request->initialize(array( + 'apiKey' => 'mykey', + 'customerReference' => 'cst_EEbQf6Q4hM', + 'description' => 'Jane Doe - Mollie Connect', + 'email' => 'john@doe.com', + 'locale' => 'nl_NL', + 'metadata' => 'Just some meta data.', + 'testmode' => true + )); + } + + /** + * @throws InvalidRequestException + */ + public function testData() + { + $this->request->initialize(array( + 'apiKey' => 'mykey', + 'customerReference' => 'cst_EEbQf6Q4hM', + 'description' => 'Jane Doe - Mollie Connect', + 'email' => 'john@doe.com', + 'metadata' => 'Just some meta data.', + 'testmode' => true, + )); + + $data = $this->request->getData(); + + $this->assertSame("Jane Doe - Mollie Connect", $data['name']); + $this->assertSame('john@doe.com', $data['email']); + $this->assertSame('Just some meta data.', $data['metadata']); + $this->assertSame(true, $data['testmode']); + $this->assertCount(5, $data); + } + + public function testSendSuccess() + { + $this->setMockHttpResponse('ConnectUpdateCustomerSuccess.txt'); + + /** @var ConnectUpdateCustomerRequest $response */ + $response = $this->request->send(); + + $this->assertEqualRequest( + new Request( + "POST", + "https://api.mollie.com/v2/customers/cst_EEbQf6Q4hM", + [], + '{ + "name": "Jane Doe - Mollie Connect", + "email": "john@doe.com", + "metadata": "Just some meta data.", + "locale": "nl_NL", + "testmode": true + }' + ), + $this->getMockClient()->getLastRequest() + ); + + $this->assertInstanceOf(UpdateCustomerResponse::class, $response); + $this->assertSame('cst_EEbQf6Q4hM', $response->getCustomerReference()); + + $this->assertTrue($response->isSuccessful()); + $this->assertJsonStringEqualsJsonString( + '{"resource":"customer","id":"cst_EEbQf6Q4hM","mode":"test","name":"Jane Roe - Mollie Connect","email":"john@doe.com","locale":null,"metadata":"Just some meta data.","createdAt":"2018-07-26T13:44:48+00:00","_links":{"self":{"href":"https://api.mollie.com/v2/customers/cst_EEbQf6Q4hM","type":"application/hal+json"},"documentation":{"href":"https://docs.mollie.com/reference/v2/customers-api/update-customer","type":"text/html"}}}', + $response->getMessage() + ); + } + + public function testSendFailure() + { + $this->setMockHttpResponse('ConnectUpdateCustomerFailure.txt'); + + /** @var UpdateCustomerResponse $response */ + $response = $this->request->send(); + + $this->assertEqualRequest(new Request("POST", "https://api.mollie.com/v2/customers/cst_EEbQf6Q4hM"), $this->getMockClient()->getLastRequest()); + + $this->assertInstanceOf(UpdateCustomerResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertFalse($response->isRedirect()); + $this->assertNull($response->getCustomerReference()); + $this->assertSame('{"status":401,"title":"Unauthorized Request","detail":"Missing authentication, or failed to authenticate","_links":{"documentation":{"href":"https:\/\/docs.mollie.com\/guides\/authentication","type":"text\/html"}}}', $response->getMessage()); + } +} diff --git a/tests/Mock/ConnectCompletePurchaseExpired.txt b/tests/Mock/ConnectCompletePurchaseExpired.txt new file mode 100644 index 0000000..2ab32d3 --- /dev/null +++ b/tests/Mock/ConnectCompletePurchaseExpired.txt @@ -0,0 +1,31 @@ +HTTP/1.1 200 OK +Content-Type: application/hal+json; charset=utf-8 + +{ + "resource":"payment", + "id":"tr_98nUH7v5bT", + "mode":"test", + "createdAt":"2018-07-27T07:10:14+00:00", + "amount":{ + "value":"10.00", + "currency":"EUR" + }, + "description":"My first Payment", + "method":null, + "metadata":null, + "status":"expired", + "expiredAt":"2018-07-27T07:27:04+00:00", + "profileId":"pfl_3RkSN1zuPE", + "sequenceType":"oneoff", + "redirectUrl":"https://webshop.example.org/mollie-return.php", + "_links":{ + "self":{ + "href":"https://api.mollie.com/v2/payments/tr_98nUH7v5bT?testmode=true", + "type":"application/hal+json" + }, + "documentation":{ + "href":"https://docs.mollie.com/reference/v2/payments-api/get-payment", + "type":"text/html" + } + } +} \ No newline at end of file diff --git a/tests/Mock/ConnectCompletePurchaseSuccess.txt b/tests/Mock/ConnectCompletePurchaseSuccess.txt new file mode 100644 index 0000000..57e66ee --- /dev/null +++ b/tests/Mock/ConnectCompletePurchaseSuccess.txt @@ -0,0 +1,50 @@ +HTTP/1.1 200 OK +Content-Type: application/hal+json; charset=utf-8 + +{ + "resource":"payment", + "id":"tr_98nUH7v5bT", + "mode":"test", + "createdAt":"2018-07-26T11:22:27+00:00", + "amount":{ + "value":"10.00", + "currency":"EUR" + }, + "description":"My first Payment", + "method":"ideal", + "metadata":null, + "status":"paid", + "paidAt":"2018-07-26T11:22:42+00:00", + "amountRefunded":{ + "value":"0.00", + "currency":"EUR" + }, + "amountRemaining":{ + "value":"35.00", + "currency":"EUR" + }, + "locale":"nl_NL", + "countryCode":"NL", + "profileId":"pfl_3RkSN1zuPE", + "sequenceType":"oneoff", + "redirectUrl":"https://webshop.example.org/mollie-return.php", + "settlementAmount":{ + "value":"10.00", + "currency":"EUR" + }, + "details":{ + "consumerName":"T. TEST", + "consumerAccount":"NL17RABO0213698412", + "consumerBic":"ABNANL2A" + }, + "_links":{ + "self":{ + "href":"https://api.mollie.com/v2/payments/tr_98nUH7v5bT?testmode=true", + "type":"application/hal+json" + }, + "documentation":{ + "href":"https://docs.mollie.com/reference/v2/payments-api/get-payment", + "type":"text/html" + } + } +} \ No newline at end of file diff --git a/tests/Mock/ConnectCreateCustomerFailure.txt b/tests/Mock/ConnectCreateCustomerFailure.txt new file mode 100644 index 0000000..1fc3cd6 --- /dev/null +++ b/tests/Mock/ConnectCreateCustomerFailure.txt @@ -0,0 +1,14 @@ +HTTP/1.1 401 Unauthorized Request +Content-Type: application/hal+json; charset=utf-8 + +{ + "status": 401, + "title": "Unauthorized Request", + "detail": "Missing authentication, or failed to authenticate", + "_links": { + "documentation": { + "href": "https://docs.mollie.com/guides/authentication", + "type": "text/html" + } + } +} \ No newline at end of file diff --git a/tests/Mock/ConnectCreateCustomerSuccess.txt b/tests/Mock/ConnectCreateCustomerSuccess.txt new file mode 100644 index 0000000..38d25c9 --- /dev/null +++ b/tests/Mock/ConnectCreateCustomerSuccess.txt @@ -0,0 +1,23 @@ +HTTP/1.1 201 Created +Content-Type: application/hal+json; charset=utf-8 + +{ + "resource":"customer", + "id":"cst_EEbQf6Q4hM", + "mode":"test", + "name":"John Doe - Mollie Connect", + "email":"john@doe.com", + "locale":null, + "metadata":"Just some meta data.", + "createdAt":"2018-07-26T13:44:48+00:00", + "_links":{ + "self":{ + "href":"https://api.mollie.com/v2/customers/cst_EEbQf6Q4hM", + "type":"application/hal+json" + }, + "documentation":{ + "href":"https://docs.mollie.com/reference/v2/customers-api/create-customer", + "type":"text/html" + } + } +} \ No newline at end of file diff --git a/tests/Mock/ConnectFetchCustomerFailure.txt b/tests/Mock/ConnectFetchCustomerFailure.txt new file mode 100644 index 0000000..4815d0d --- /dev/null +++ b/tests/Mock/ConnectFetchCustomerFailure.txt @@ -0,0 +1,14 @@ +HTTP/1.1 404 Not Found +Content-Type: application/hal+json; charset=utf-8 + +{ + "status": 404, + "title": "Not Found", + "detail": "No customer exists with token cst_EEbQf6Q4hM.", + "_links": { + "documentation": { + "href": "https://docs.mollie.com/guides/handling-errors", + "type": "text/html" + } + } +} \ No newline at end of file diff --git a/tests/Mock/ConnectFetchCustomerSuccess.txt b/tests/Mock/ConnectFetchCustomerSuccess.txt new file mode 100644 index 0000000..9109853 --- /dev/null +++ b/tests/Mock/ConnectFetchCustomerSuccess.txt @@ -0,0 +1,23 @@ +HTTP/1.1 201 Created +Content-Type: application/hal+json; charset=utf-8 + +{ + "resource":"customer", + "id":"cst_EEbQf6Q4hM", + "mode":"test", + "name":"Jane Roe - Mollie Connect", + "email":"john@doe.com", + "locale":null, + "metadata":"Just some meta data.", + "createdAt":"2018-07-26T13:44:48+00:00", + "_links":{ + "self":{ + "href":"https://api.mollie.com/v2/customers/cst_EEbQf6Q4hM?testmode=true", + "type":"application/hal+json" + }, + "documentation":{ + "href":"https://docs.mollie.com/reference/v2/customers-api/get-customer", + "type":"text/html" + } + } +} \ No newline at end of file diff --git a/tests/Mock/ConnectFetchIssuersFailure.txt b/tests/Mock/ConnectFetchIssuersFailure.txt new file mode 100644 index 0000000..04cdb9d --- /dev/null +++ b/tests/Mock/ConnectFetchIssuersFailure.txt @@ -0,0 +1,14 @@ +HTTP/1.1 401 Unauthorized Request +Content-Type: application/hal+json; charset=utf-8 + +{ + "status": 401, + "title": "Unauthorized Request", + "detail": "Missing authentication, or failed to authenticate", + "_links": { + "documentation": { + "href": "https://docs.mollie.com/guides/authentication", + "type": "text/html" + } + } +} diff --git a/tests/Mock/ConnectFetchIssuersSuccess.txt b/tests/Mock/ConnectFetchIssuersSuccess.txt new file mode 100644 index 0000000..335ffc3 --- /dev/null +++ b/tests/Mock/ConnectFetchIssuersSuccess.txt @@ -0,0 +1,123 @@ +HTTP/1.1 200 OK +Content-Type: application/hal+json; charset=utf-8 + +{ + "resource":"method", + "id":"ideal", + "description":"iDEAL", + "image":{ + "size1x":"https://www.mollie.com/images/payscreen/methods/ideal.png", + "size2x":"https://www.mollie.com/images/payscreen/methods/ideal%402x.png" + }, + "issuers":[ + { + "resource":"issuer", + "id":"ideal_ABNANL2A", + "name":"ABN AMRO", + "image":{ + "size1x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/ABNANL2A.png", + "size2x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/ABNANL2A.png" + } + }, + { + "resource":"issuer", + "id":"ideal_ASNBNL21", + "name":"ASN Bank", + "image":{ + "size1x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/ASNBNL21.png", + "size2x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/ASNBNL21.png" + } + }, + { + "resource":"issuer", + "id":"ideal_BUNQNL2A", + "name":"bunq", + "image":{ + "size1x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/BUNQNL2A.png", + "size2x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/BUNQNL2A.png" + } + }, + { + "resource":"issuer", + "id":"ideal_INGBNL2A", + "name":"ING", + "image":{ + "size1x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/INGBNL2A.png", + "size2x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/INGBNL2A.png" + } + }, + { + "resource":"issuer", + "id":"ideal_KNABNL2H", + "name":"Knab", + "image":{ + "size1x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/KNABNL2H.png", + "size2x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/KNABNL2H.png" + } + }, + { + "resource":"issuer", + "id":"ideal_MOYONL21", + "name":"Moneyou", + "image":{ + "size1x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/MOYONL21.png", + "size2x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/MOYONL21.png" + } + }, + { + "resource":"issuer", + "id":"ideal_RABONL2U", + "name":"Rabobank", + "image":{ + "size1x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/RABONL2U.png", + "size2x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/RABONL2U.png" + } + }, + { + "resource":"issuer", + "id":"ideal_RBRBNL21", + "name":"RegioBank", + "image":{ + "size1x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/RBRBNL21.png", + "size2x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/RBRBNL21.png" + } + }, + { + "resource":"issuer", + "id":"ideal_SNSBNL2A", + "name":"SNS Bank", + "image":{ + "size1x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/SNSBNL2A.png", + "size2x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/SNSBNL2A.png" + } + }, + { + "resource":"issuer", + "id":"ideal_TRIONL2U", + "name":"Triodos Bank", + "image":{ + "size1x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/TRIONL2U.png", + "size2x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/TRIONL2U.png" + } + }, + { + "resource":"issuer", + "id":"ideal_FVLBNL22", + "name":"van Lanschot", + "image":{ + "size1x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/FVLBNL22.png", + "size2x":"https://www.mollie.com/images/checkout/v2/ideal-issuer-icons/FVLBNL22.png" + } + } + ], + "_links":{ + "self":{ + "href":"https://api.mollie.com/v2/methods/ideal?include=issuers&profileId=pfl_3RkSN1zuPE&testmode=true", + "type":"application/hal+json" + }, + "documentation":{ + "href":"https://docs.mollie.com/reference/v2/methods-api/get-method", + "type":"text/html" + } + } +} \ No newline at end of file diff --git a/tests/Mock/ConnectFetchPaymentMethodsFailure.txt b/tests/Mock/ConnectFetchPaymentMethodsFailure.txt new file mode 100644 index 0000000..1fc3cd6 --- /dev/null +++ b/tests/Mock/ConnectFetchPaymentMethodsFailure.txt @@ -0,0 +1,14 @@ +HTTP/1.1 401 Unauthorized Request +Content-Type: application/hal+json; charset=utf-8 + +{ + "status": 401, + "title": "Unauthorized Request", + "detail": "Missing authentication, or failed to authenticate", + "_links": { + "documentation": { + "href": "https://docs.mollie.com/guides/authentication", + "type": "text/html" + } + } +} \ No newline at end of file diff --git a/tests/Mock/ConnectFetchPaymentMethodsSuccess.txt b/tests/Mock/ConnectFetchPaymentMethodsSuccess.txt new file mode 100644 index 0000000..7b48ed8 --- /dev/null +++ b/tests/Mock/ConnectFetchPaymentMethodsSuccess.txt @@ -0,0 +1,50 @@ +HTTP/1.1 200 OK +Content-Type: application/hal+json; charset=utf-8 + +{ + "_embedded":{ + "methods":[ + { + "resource":"method", + "id":"ideal", + "description":"iDEAL", + "image":{ + "size1x":"https://www.mollie.com/images/payscreen/methods/ideal.png", + "size2x":"https://www.mollie.com/images/payscreen/methods/ideal%402x.png" + }, + "_links":{ + "self":{ + "href":"https://api.mollie.com/v2/methods/ideal", + "type":"application/hal+json" + } + } + }, + { + "resource":"method", + "id":"banktransfer", + "description":"Bank transfer", + "image":{ + "size1x":"https://www.mollie.com/images/payscreen/methods/banktransfer.png", + "size2x":"https://www.mollie.com/images/payscreen/methods/banktransfer%402x.png" + }, + "_links":{ + "self":{ + "href":"https://api.mollie.com/v2/methods/banktransfer", + "type":"application/hal+json" + } + } + } + ] + }, + "count":2, + "_links":{ + "documentation":{ + "href":"https://docs.mollie.com/reference/v2/methods-api/list-methods", + "type":"text/html" + }, + "self":{ + "href":"https://api.mollie.com/v2/methods?profileId=pfl_3RkSN1zuPE&testmode=true", + "type":"application/hal+json" + } + } +} \ No newline at end of file diff --git a/tests/Mock/ConnectFetchTransaction404Failure.txt b/tests/Mock/ConnectFetchTransaction404Failure.txt new file mode 100644 index 0000000..3068ac2 --- /dev/null +++ b/tests/Mock/ConnectFetchTransaction404Failure.txt @@ -0,0 +1,14 @@ +HTTP/1.1 404 Not Found +Content-Type: application/hal+json; charset=utf-8 + +{ + "status": 404, + "title": "Not Found", + "detail": "No transaction exists with token tr_98nUH7v5bT.", + "_links": { + "documentation": { + "href": "https://docs.mollie.com/guides/handling-errors", + "type": "text/html" + } + } +} \ No newline at end of file diff --git a/tests/Mock/ConnectFetchTransactionExpired.txt b/tests/Mock/ConnectFetchTransactionExpired.txt new file mode 100644 index 0000000..b7bd099 --- /dev/null +++ b/tests/Mock/ConnectFetchTransactionExpired.txt @@ -0,0 +1,31 @@ +HTTP/1.1 200 OK +Content-Type: application/hal+json; charset=utf-8 + +{ + "resource":"payment", + "id":"tr_98nUH7v5bT", + "mode":"test", + "createdAt":"2018-07-26T14:53:02+00:00", + "amount":{ + "value":"10.00", + "currency":"EUR" + }, + "description":"My first Payment", + "method":null, + "metadata":null, + "status":"expired", + "expiredAt":"2018-07-26T15:09:04+00:00", + "profileId":"pfl_3RkSN1zuPE", + "sequenceType":"oneoff", + "redirectUrl":"https://webshop.example.org/mollie-return.php", + "_links":{ + "self":{ + "href":"https://api.mollie.com/v2/payments/tr_98nUH7v5bT?testmode=true", + "type":"application/hal+json" + }, + "documentation":{ + "href":"https://docs.mollie.com/reference/v2/payments-api/get-payment", + "type":"text/html" + } + } +} \ No newline at end of file diff --git a/tests/Mock/ConnectFetchTransactionSuccess.txt b/tests/Mock/ConnectFetchTransactionSuccess.txt new file mode 100644 index 0000000..57e66ee --- /dev/null +++ b/tests/Mock/ConnectFetchTransactionSuccess.txt @@ -0,0 +1,50 @@ +HTTP/1.1 200 OK +Content-Type: application/hal+json; charset=utf-8 + +{ + "resource":"payment", + "id":"tr_98nUH7v5bT", + "mode":"test", + "createdAt":"2018-07-26T11:22:27+00:00", + "amount":{ + "value":"10.00", + "currency":"EUR" + }, + "description":"My first Payment", + "method":"ideal", + "metadata":null, + "status":"paid", + "paidAt":"2018-07-26T11:22:42+00:00", + "amountRefunded":{ + "value":"0.00", + "currency":"EUR" + }, + "amountRemaining":{ + "value":"35.00", + "currency":"EUR" + }, + "locale":"nl_NL", + "countryCode":"NL", + "profileId":"pfl_3RkSN1zuPE", + "sequenceType":"oneoff", + "redirectUrl":"https://webshop.example.org/mollie-return.php", + "settlementAmount":{ + "value":"10.00", + "currency":"EUR" + }, + "details":{ + "consumerName":"T. TEST", + "consumerAccount":"NL17RABO0213698412", + "consumerBic":"ABNANL2A" + }, + "_links":{ + "self":{ + "href":"https://api.mollie.com/v2/payments/tr_98nUH7v5bT?testmode=true", + "type":"application/hal+json" + }, + "documentation":{ + "href":"https://docs.mollie.com/reference/v2/payments-api/get-payment", + "type":"text/html" + } + } +} \ No newline at end of file diff --git a/tests/Mock/ConnectPurchaseIssuerFailure.txt b/tests/Mock/ConnectPurchaseIssuerFailure.txt new file mode 100644 index 0000000..d8051e4 --- /dev/null +++ b/tests/Mock/ConnectPurchaseIssuerFailure.txt @@ -0,0 +1,15 @@ +HTTP/1.1 422 Unprocessable Entity +Content-Type: application/hal+json; charset=utf-8 + +{ + "status": 422, + "title": "Unprocessable Entity", + "detail": "The payment method is invalid", + "field": "method", + "_links": { + "documentation": { + "href": "https://docs.mollie.com/guides/handling-errors", + "type": "text/html" + } + } +} diff --git a/tests/Mock/ConnectPurchaseSuccess.txt b/tests/Mock/ConnectPurchaseSuccess.txt new file mode 100644 index 0000000..4038892 --- /dev/null +++ b/tests/Mock/ConnectPurchaseSuccess.txt @@ -0,0 +1,36 @@ +HTTP/1.1 201 Created +Content-Type: application/hal+json; charset=utf-8 + +{ + "resource":"payment", + "id":"tr_jdsTnrTT3R", + "mode":"test", + "createdAt":"2018-07-27T07:10:14+00:00", + "amount":{ + "value":"10.00", + "currency":"EUR" + }, + "description":"My first Payment", + "method":null, + "metadata":null, + "status":"open", + "isCancelable":false, + "expiresAt":"2018-07-27T07:25:14+00:00", + "profileId":"pfl_3RkSN1zuPE", + "sequenceType":"oneoff", + "redirectUrl":"https://webshop.example.org/mollie-return.php", + "_links":{ + "self":{ + "href":"https://api.mollie.com/v2/payments/tr_jdsTnrTT3R", + "type":"application/hal+json" + }, + "checkout":{ + "href":"https://www.mollie.com/payscreen/select-method/jdsTnrTT3R", + "type":"text/html" + }, + "documentation":{ + "href":"https://docs.mollie.com/reference/v2/payments-api/create-payment", + "type":"text/html" + } + } +} \ No newline at end of file diff --git a/tests/Mock/ConnectRefund401Failure.txt b/tests/Mock/ConnectRefund401Failure.txt new file mode 100644 index 0000000..1e9011e --- /dev/null +++ b/tests/Mock/ConnectRefund401Failure.txt @@ -0,0 +1,13 @@ +HTTP/1.1 401 Authorization Required + +{ + "status": 401, + "title": "Unauthorized Request", + "detail": "Missing authentication, or failed to authenticate", + "_links": { + "documentation": { + "href": "https://docs.mollie.com/guides/authentication", + "type": "text/html" + } + } +} diff --git a/tests/Mock/ConnectRefund422Failure.txt b/tests/Mock/ConnectRefund422Failure.txt new file mode 100644 index 0000000..d8051e4 --- /dev/null +++ b/tests/Mock/ConnectRefund422Failure.txt @@ -0,0 +1,15 @@ +HTTP/1.1 422 Unprocessable Entity +Content-Type: application/hal+json; charset=utf-8 + +{ + "status": 422, + "title": "Unprocessable Entity", + "detail": "The payment method is invalid", + "field": "method", + "_links": { + "documentation": { + "href": "https://docs.mollie.com/guides/handling-errors", + "type": "text/html" + } + } +} diff --git a/tests/Mock/ConnectRefundSuccess.txt b/tests/Mock/ConnectRefundSuccess.txt new file mode 100644 index 0000000..62f51a8 --- /dev/null +++ b/tests/Mock/ConnectRefundSuccess.txt @@ -0,0 +1,33 @@ +HTTP/1.1 201 Created +Content-Type: application/hal+json; charset=utf-8 + +{ + "resource":"refund", + "id":"re_c5rGsnjbxz", + "amount":{ + "value":"10.00", + "currency":"EUR" + }, + "status":"pending", + "createdAt":"2018-07-27T07:39:21+00:00", + "description":"My first Payment", + "paymentId":"tr_98nUH7v5bT", + "settlementAmount":{ + "value":"-10.00", + "currency":"EUR" + }, + "_links":{ + "self":{ + "href":"https://api.mollie.com/v2/payments/tr_98nUH7v5bT/refunds/re_c5rGsnjbxz", + "type":"application/hal+json" + }, + "payment":{ + "href":"https://api.mollie.com/v2/payments/tr_98nUH7v5bT", + "type":"application/hal+json" + }, + "documentation":{ + "href":"https://docs.mollie.com/reference/v2/refunds-api/create-refund", + "type":"text/html" + } + } +} \ No newline at end of file diff --git a/tests/Mock/ConnectUpdateCustomerFailure.txt b/tests/Mock/ConnectUpdateCustomerFailure.txt new file mode 100644 index 0000000..04cdb9d --- /dev/null +++ b/tests/Mock/ConnectUpdateCustomerFailure.txt @@ -0,0 +1,14 @@ +HTTP/1.1 401 Unauthorized Request +Content-Type: application/hal+json; charset=utf-8 + +{ + "status": 401, + "title": "Unauthorized Request", + "detail": "Missing authentication, or failed to authenticate", + "_links": { + "documentation": { + "href": "https://docs.mollie.com/guides/authentication", + "type": "text/html" + } + } +} diff --git a/tests/Mock/ConnectUpdateCustomerSuccess.txt b/tests/Mock/ConnectUpdateCustomerSuccess.txt new file mode 100644 index 0000000..fb58ddd --- /dev/null +++ b/tests/Mock/ConnectUpdateCustomerSuccess.txt @@ -0,0 +1,23 @@ +HTTP/1.1 201 Created +Content-Type: application/hal+json; charset=utf-8 + +{ + "resource":"customer", + "id":"cst_EEbQf6Q4hM", + "mode":"test", + "name":"Jane Roe - Mollie Connect", + "email":"john@doe.com", + "locale":null, + "metadata":"Just some meta data.", + "createdAt":"2018-07-26T13:44:48+00:00", + "_links":{ + "self":{ + "href":"https://api.mollie.com/v2/customers/cst_EEbQf6Q4hM", + "type":"application/hal+json" + }, + "documentation":{ + "href":"https://docs.mollie.com/reference/v2/customers-api/update-customer", + "type":"text/html" + } + } +} \ No newline at end of file