Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
add ability to complete 3DS 2 transaction, closes #28
Browse files Browse the repository at this point in the history
  • Loading branch information
tuurbo committed Jul 9, 2019
1 parent 55e63c9 commit fed3af5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ Spreedly::transaction()->purchase();
Spreedly::transaction()->void();
Spreedly::transaction()->credit();
Spreedly::transaction()->capture();
Spreedly::transaction()->complete();
```

## Changelog
Expand Down
9 changes: 9 additions & 0 deletions spec/Tuurbo/Spreedly/TransactionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ public function it_captures_a_specific_authorized_amount($client)
$this->capture($amount)->shouldReturnAnInstanceOf('Tuurbo\Spreedly\Client');
}

public function it_completes_a_3ds2_transaction($client)
{
$client->post('v1/transactions/'.self::TRANSACTION_TOKEN.'/complete.json')
->shouldBeCalled()
->willReturn($client);

$this->complete()->shouldReturnAnInstanceOf('Tuurbo\Spreedly\Client');
}

public function it_throws_invalid_method_exception()
{
$this->shouldThrow('Tuurbo\Spreedly\Exceptions\InvalidPaymentMethodException')
Expand Down
23 changes: 23 additions & 0 deletions src/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,29 @@ public function void(array $data = [])
return $this->client->post('v1/transactions/'.$this->transactionToken.'/void.json', $data);
}

/**
* Can be used to Completes a 3DS 2 transaction in the device fingerprint stage
* See docs for more information.
*
* <code>
* // Completes a 3DS 2 transaction in the device fingerprint stage.
* Spreedly::transaction($transactionToken)->complete();
* </code>
*
*
* @return mixed
*
* @throws Exceptions\MissingTransactionTokenException
*/
public function complete()
{
if (!$this->transactionToken) {
throw new Exceptions\MissingTransactionTokenException();
}

return $this->client->post('v1/transactions/'.$this->transactionToken.'/complete.json');
}

/**
* @param string $method
* @param array $parameters
Expand Down

0 comments on commit fed3af5

Please sign in to comment.