diff --git a/lib/Gr4vyConfig.php b/lib/Gr4vyConfig.php index 2c8eb7f..e8d6b5a 100644 --- a/lib/Gr4vyConfig.php +++ b/lib/Gr4vyConfig.php @@ -119,7 +119,7 @@ public static function getToken($private_key, $scopes = array(), $embed = array( $now = new DateTimeImmutable(); $tokenBuilder = $config->builder() // Configures the issuer (iss claim) - ->issuedBy('Gr4vy SDK 0.20.0') + ->issuedBy('Gr4vy SDK 0.21.0') // Configures the id (jti claim) ->identifiedBy(self::gen_uuid()) // Configures the time that the token was issue (iat claim) @@ -415,6 +415,10 @@ public function refundTransaction($transaction_id, $refund_request) { $response = $this->post("/transactions/" . $transaction_id . "/refunds", $refund_request); return $response; } + public function voidTransaction($transaction_id, $request = array()) { + $response = $this->post("/transactions/" . $transaction_id . "/void", $request); + return $response; + } public function newCheckoutSession($request = array()) { $response = $this->post("/checkout/sessions", $request); return $response; diff --git a/test/Api/TransactionsApiTest.php b/test/Api/TransactionsApiTest.php index c03b8c2..18fcf12 100644 --- a/test/Api/TransactionsApiTest.php +++ b/test/Api/TransactionsApiTest.php @@ -201,4 +201,29 @@ public function testRefundTransaction() $this->fail("Exception thrown: " . $e->getMessage()); } } + + /** + * Test case for voidTransaction + * + * Void transaction. + * + */ + public function testVoidTransaction() + { + + try { + $config = new Gr4vyConfig(self::$gr4vyId, self::$privateKeyLocation); + $transaction_request = array("amount"=>100,"currency"=>"USD", "intent"=>"authorize", "payment_method"=>array("method"=>"card", "number"=>"4111111111111111", "expiration_date"=> "01/28", "security_code"=>"555")); + $result = $config->authorizeNewTransaction($transaction_request); + $this->assertArrayHasKey("id", $result); + $this->assertEquals($result["type"], "transaction"); + + $result = $config->voidTransaction($result["id"]); + $this->assertArrayHasKey("id", $result); + $this->assertEquals($result["status"], "authorization_voided"); + // print_r($result); + } catch (Exception $e) { + $this->fail("Exception thrown: " . $e->getMessage()); + } + } }