public function testOverrideParams() { $params = array('vtweb' => array('extra' => 'param')); VT_Tests::$stubHttp = true; VT_Tests::$stubHttpResponse = '{ "status_code": 200, "redirect_url": "http://host.com/pay" }'; $paymentUrl = Veritrans_Vtweb::getRedirectionUrl($params); $this->assertEquals(VT_Tests::$lastHttpRequest['data_hash']["vtweb"], array("credit_card_3d_secure" => false, "extra" => "param")); }
public function testConfigOptionsOverrideCurlOptions() { VT_Tests::$stubHttp = true; VT_Tests::$stubHttpResponse = '{ "status_code": "200" }'; Veritrans_Config::$curlOptions = array(CURLOPT_HTTPHEADER => array("User-Agent: testing lib"), CURLOPT_PROXY => "http://proxy.com"); $resp = Veritrans_ApiRequestor::post("http://example.com", "", ""); $fields = VT_Tests::lastReqOptions(); $this->assertTrue(in_array("User-Agent: testing lib", $fields["HTTPHEADER"])); $this->assertTrue(in_array('Content-Type: application/json', $fields["HTTPHEADER"])); $this->assertEquals($fields["PROXY"], "http://proxy.com"); }
public function testCanWorkWithJSON() { $tmpfname = tempnam(sys_get_temp_dir(), "veritrans_test"); file_put_contents($tmpfname, TEST_CAPTURE_JSON); VT_Tests::$stubHttp = true; VT_Tests::$stubHttpResponse = TEST_CAPTURE_JSON; $notif = new Veritrans_Notification($tmpfname); $this->assertEquals($notif->transaction_status, "capture"); $this->assertEquals($notif->payment_type, "credit_card"); $this->assertEquals($notif->order_id, "2014040745"); $this->assertEquals($notif->gross_amount, "2700"); unlink($tmpfname); }
public function testCapture() { VT_Tests::$stubHttp = true; VT_Tests::$stubHttpResponse = '{ "status_code": "200", "status_message": "Success, Credit Card capture transaction is successful", "transaction_id": "1ac1a089d-a587-40f1-a936-a7770667d6dd", "order_id": "A27550", "payment_type": "credit_card", "transaction_time": "2014-08-25 10:20:54", "transaction_status": "capture", "fraud_status": "accept", "masked_card": "481111-1114", "bank": "bni", "approval_code": "1408937217061", "gross_amount": "55000.00" }'; $capture = Veritrans_VtDirect::capture("A27550"); $this->assertEquals($capture->status_code, "200"); $this->assertEquals(VT_Tests::$lastHttpRequest["url"], "https://api.sandbox.veritrans.co.id/v2/capture"); $fields = VT_Tests::lastReqOptions(); $this->assertEquals($fields["POST"], 1); $this->assertEquals($fields["POSTFIELDS"], '{"transaction_id":"A27550"}'); }
public function testExpire() { VT_Tests::$stubHttp = true; VT_Tests::$stubHttpResponse = '{ "status_code": "407", "status_message": "Success, transaction has expired", "transaction_id": "2af158d4-b82e-46ac-808b-be19aaa96ce3", "order_id": "Order-111", "payment_type": "echannel", "transaction_time": "2014-11-27 10:05:10", "transaction_status": "expire", "gross_amount": "10000.00" }'; $expire = Veritrans_Transaction::expire("Order-111"); $this->assertEquals($expire->status_code, "407"); $this->assertEquals($expire->status_message, "Success, transaction has expired"); $this->assertEquals(VT_Tests::$lastHttpRequest["url"], "https://api.sandbox.veritrans.co.id/v2/Order-111/expire"); $fields = VT_Tests::lastReqOptions(); $this->assertEquals($fields["POST"], 1); $this->assertEquals($fields["POSTFIELDS"], null); }
public static function reset() { VT_Tests::$stubHttp = false; VT_Tests::$stubHttpResponse = null; VT_Tests::$lastHttpRequest = null; }
public function testCancel() { VT_Tests::$stubHttp = true; VT_Tests::$stubHttpResponse = '{ "status_code": "200", "status_message": "Success, transaction is canceled", "transaction_id": "2af158d4-b82e-46ac-808b-be19aaa96ce3", "masked_card": "451111-1117", "order_id": "Order-111", "payment_type": "credit_card", "transaction_time": "2014-11-27 10:05:10", "transaction_status": "cancel", "fraud_status": "accept", "approval_code": "1416550071152", "bank": "bni", "gross_amount": "10000.00" }'; $cancel = Veritrans_Transaction::cancel("Order-111"); $this->assertEquals($cancel, "200"); $this->assertEquals(VT_Tests::$lastHttpRequest["url"], "https://api.sandbox.veritrans.co.id/v2/Order-111/cancel"); $fields = VT_Tests::lastReqOptions(); $this->assertEquals($fields["POST"], 1); $this->assertEquals($fields["POSTFIELDS"], null); }