-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from RentMoola/UpdatePaymentMethod
Update payment method
- Loading branch information
Showing
6 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Omnipay\RentMoola\Message; | ||
|
||
class UpdateCCPaymentMethodRequest extends AbstractRequest | ||
{ | ||
public function getData() | ||
{ | ||
$this->validate('userId'); | ||
$this->validate('paymentMethodId'); | ||
|
||
$data = array(); | ||
|
||
return $data; | ||
} | ||
|
||
public function sendData($data) | ||
{ | ||
$httpResponse = $this->sendRequest( | ||
'PUT', | ||
'/users/'.$this->getUserId().'/payments/'.$this->getPaymentMethodId().'/cc', | ||
$data | ||
); | ||
|
||
if ($httpResponse->isSuccessful()) { | ||
return $this->response = new Response($this, json_decode('[]')); | ||
} | ||
return $this->response = new Response($this, $httpResponse->json()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Omnipay\RentMoola\Message; | ||
|
||
use Omnipay\Tests\TestCase; | ||
|
||
class UpdateCCPaymentMethodRequestTest extends TestCase | ||
{ | ||
public function setUp() | ||
{ | ||
$this->request = new UpdateCCPaymentMethodRequest( | ||
$this->getHttpClient(), | ||
$this->getHttpRequest() | ||
); | ||
$this->request->initialize( | ||
array( | ||
'userId' => '24a58d3c-4774-48bb-803a-b0ccc6b2d8d5', | ||
'paymentMethodId' => 'd502ad2d-e103-4e04-b2a2-fdd7c547eb06', | ||
'name' => 'Joe Smith', | ||
'number' => '4444333322221111', | ||
'cvc' => '212', | ||
'expiryMonth' => '09', | ||
'expiryYear' => '2018', | ||
'destinationAccountId' => '41fcd0ff-7c57-403a-9bd5-e850056fdc2a', | ||
'state' => 'WA', | ||
'country' => 'USA', | ||
'zip' => '90210', | ||
'city' => 'Tampa', | ||
'address1' => '124 West Street', | ||
'address2' => '126 West Street', | ||
) | ||
); | ||
} | ||
|
||
public function testSendSuccess() | ||
{ | ||
$this->setMockHttpResponse('UpdateCCPaymentMethodSuccess.txt'); | ||
$response = $this->request->send(); | ||
|
||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertFalse($response->isRedirect()); | ||
$this->assertNull($response->getErrorMessage()); | ||
$this->assertNull($response->getErrorCode()); | ||
} | ||
|
||
public function testSendFailure() | ||
{ | ||
$this->setMockHttpResponse('UpdateCCPaymentMethodFailure.txt'); | ||
$response = $this->request->send(); | ||
|
||
$this->assertFalse($response->isSuccessful()); | ||
$this->assertFalse($response->isRedirect()); | ||
$this->assertEquals("may not be empty", $response->getErrorMessage()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
HTTP/1.1 400 Bad Request | ||
Connection = keep-alive | ||
Content-Encoding = gzip | ||
Content-Length = 154 | ||
Content-Type = application/json | ||
Date = Tue, 10 May 2016 16:32:47 GMT | ||
Vary = Accept-Encoding | ||
X-Frame-Options = SAMEORIGIN | ||
|
||
{ | ||
"error": [ | ||
{ | ||
"path": "updatePaymentMethodCC.arg3.name", | ||
"message": "may not be empty", | ||
"value": "" | ||
}, | ||
{ | ||
"path": "updatePaymentMethodCC.arg3.number", | ||
"message": "Enter your credit card number", | ||
"value": "" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
HTTP/1.1 200 OK | ||
Connection = keep-alive | ||
Content-Encoding = gzip | ||
Content-Length = 154 | ||
Content-Type = application/json | ||
Date = Tue, 10 May 2016 16:32:47 GMT | ||
Vary = Accept-Encoding | ||
X-Frame-Options = SAMEORIGIN |