php - authorize.net laravel empty response -
i trying integrate authorize.net laravel shopping cart using php sdk. in sandbox environment currently. have processing transaction (i can see in admin , email) returned response null values.
code still little dirty
namespace app\http\controllers; use illuminate\http\request; use app\http\requests; use net\authorize\api\contract\v1 anetapi; use net\authorize\api\controller anetcontroller; class paymentcontroller extends controller { // public function authnet_chargecard() { $merchantauthentication = new anetapi\merchantauthenticationtype(); $merchantauthentication->setname(env('authnet_id')); $merchantauthentication->settransactionkey(env('authnet_key')); $refid = 'ref' . time(); define("authorizenet_log_file", "phplog"); // create payment data credit card $creditcard = new anetapi\creditcardtype(); $creditcard->setcardnumber("4111111111111111"); $creditcard->setexpirationdate("1226"); $creditcard->setcardcode("123"); $paymentone = new anetapi\paymenttype(); $paymentone->setcreditcard($creditcard); $order = new anetapi\ordertype(); $order->setinvoicenumber("cow-100"); $order->setdescription("new item"); //create transaction $amount=100; $transactionrequesttype = new anetapi\transactionrequesttype(); $transactionrequesttype->settransactiontype( "authcapturetransaction"); $transactionrequesttype->setamount($amount); $transactionrequesttype->setorder($order); $transactionrequesttype->setpayment($paymentone); $request = new anetapi\createtransactionrequest(); $request->setmerchantauthentication($merchantauthentication); $request->setrefid( $refid); $request->settransactionrequest($transactionrequesttype); $controller = new anetcontroller\createtransactioncontroller($request); $response = $controller->executewithapiresponse( \net\authorize\api\constants\anetenvironment::sandbox); //dd($response); if ($response != null) { $tresponse = $response->gettransactionresponse(); if (($tresponse != null) && ($tresponse->getresponsecode()== \samplecode\constants::response_ok) ) { echo "charge credit card auth code : " . $tresponse->getauthcode() . "\n"; echo "charge credit card trans id : " . $tresponse->gettransid() . "\n"; } else { echo "charge credit card error : invalid response\n"; } } else { echo "charge credit card null response returned"; } } }
every time response looks like:
createtransactionresponse {#352 ▼ -transactionresponse: null -profileresponse: null -refid: null -messages: null -sessiontoken: null }
i have tried temporarily setting $verify_peer false
not sure went wrong... cleaned composer file ... updated , boom go. sorry waste virtual space , time one.
Comments
Post a Comment