@@ -331,4 +331,47 @@ public function test_create_customer()
331331 $ this ->assertTrue ($ result ->successful );
332332 $ this ->assertNotNull ($ result ->response ->id );
333333 }
334+
335+ /**
336+ * Test a standalone refund with a valid card token (mocked)
337+ */
338+ public function test_refund_standalone ()
339+ {
340+ $ stubbed_response = '{"successful":true,"response":{"id":"refund123","successful":true,"message":"Refund processed"},"errors":[],"test":true} ' ;
341+ $ stub = $ this ->createMock (FatZebra \Gateway::class);
342+ $ stub ->method ('refund_standalone ' )->willReturn (json_decode ($ stubbed_response ));
343+ $ result = $ stub ->refund_standalone (50.00 , "UNITTEST " . rand (), "TOK123 " );
344+
345+ $ this ->assertTrue ($ result ->successful );
346+ $ this ->assertTrue ($ result ->response ->successful );
347+ $ this ->assertEquals ($ result ->response ->message , "Refund processed " );
348+ }
349+
350+ /**
351+ * Test standalone refund with an invalid card token
352+ */
353+ public function test_refund_standalone_invalid_token ()
354+ {
355+ $ gw = new FatZebra \Gateway ("TEST " , "TEST " , true , GW_URL );
356+ $ gw ->timeout = 30 ;
357+
358+ $ result = $ gw ->refund_standalone (50.00 , "UNITTEST " . rand (), "INVALID_TOKEN " );
359+
360+ $ this ->assertFalse ($ result ->successful );
361+ }
362+
363+ /**
364+ * Test standalone refund with extra parameters (mocked)
365+ */
366+ public function test_refund_standalone_with_extra ()
367+ {
368+ $ stubbed_response = '{"successful":true,"response":{"id":"refund456","successful":true,"message":"Refund processed"},"errors":[],"test":true} ' ;
369+ $ stub = $ this ->createMock (FatZebra \Gateway::class);
370+ $ stub ->method ('refund_standalone ' )->willReturn (json_decode ($ stubbed_response ));
371+ $ extra = array ("metadata " => "test_metadata " );
372+ $ result = $ stub ->refund_standalone (50.00 , "UNITTEST " . rand (), "TOK123 " , $ extra );
373+
374+ $ this ->assertTrue ($ result ->successful );
375+ $ this ->assertTrue ($ result ->response ->successful );
376+ }
334377}
0 commit comments