diff --git a/readme.md b/readme.md index e4934e1..e27823f 100644 --- a/readme.md +++ b/readme.md @@ -133,6 +133,7 @@ Spreedly::transaction()->purchase(); Spreedly::transaction()->void(); Spreedly::transaction()->credit(); Spreedly::transaction()->capture(); +Spreedly::transaction()->complete(); ``` ## Changelog diff --git a/spec/Tuurbo/Spreedly/TransactionSpec.php b/spec/Tuurbo/Spreedly/TransactionSpec.php index dcd433e..a8e95a5 100644 --- a/spec/Tuurbo/Spreedly/TransactionSpec.php +++ b/spec/Tuurbo/Spreedly/TransactionSpec.php @@ -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') diff --git a/src/Transaction.php b/src/Transaction.php index c1a6b6d..4e00363 100644 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -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. + * + * + * // Completes a 3DS 2 transaction in the device fingerprint stage. + * Spreedly::transaction($transactionToken)->complete(); + * + * + * + * @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