Skip to content

Commit

Permalink
Merge pull request #74 from twiking/incorrect-data-sent-when-updating…
Browse files Browse the repository at this point in the history
…-card

Incorrect data sent when updating card
  • Loading branch information
delatbabel committed May 12, 2017
2 parents 6b05b89 + e145173 commit e11b40d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
16 changes: 4 additions & 12 deletions src/Message/UpdateCardRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,11 @@ public function getData()
$this->validate('cardReference');
$this->validate('customerReference');

$data = array();
$data['description'] = $this->getDescription();

if ($this->getSource()) {
$data['source'] = $this->getSource();
} elseif ($this->getToken()) {
$data['source'] = $this->getToken();
} elseif ($this->getCard()) {
$data['source'] = $this->getCardData();
$data['email'] = $this->getCard()->getEmail();
if ($this->getCard()) {
return $this->getCardData();
} else {
return array();
}

return $data;
}

public function getEndpoint()
Expand Down
20 changes: 2 additions & 18 deletions tests/Message/UpdateCardRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,14 @@ public function testEndpoint()
$this->assertSame('https://api.stripe.com/v1/customers/cus_1MZSEtqSghKx99/cards/card_15Wg7vIobxWFFmzdvC5fVY67', $this->request->getEndpoint());
}

public function testDataWithToken()
{
$this->request->setToken('xyz');
$data = $this->request->getData();

$this->assertSame('xyz', $data['source']);
}

public function testDataWithSource()
{
$this->request->setSource('xyz');
$data = $this->request->getData();

$this->assertSame('xyz', $data['source']);
}

public function testDataWithCard()
{
$card = $this->getValidCard();
$this->request->setCard($card);
$data = $this->request->getData();

$this->assertSame($card['billingAddress1'], $data['source']['address_line1']);
$this->assertSame($card['number'], $data['source']['number']);
$this->assertSame($card['billingAddress1'], $data['address_line1']);
$this->assertSame($card['number'], $data['number']);
}

public function testSendSuccess()
Expand Down

0 comments on commit e11b40d

Please sign in to comment.