2016-07-28 3 views
0

Laravel 5.2와 함께 작동하는 Authorize.net SDK를 얻을 수 없으며 문제점을 다루는 데 많은 시간을 할애했습니다. 나는() 응답을 위해서 var_dump 때Authorize.net SDK with Laravel

... 내가 할 모든

object(net\authorize\api\contract\v1\ARBCreateSubscriptionResponse)#413 (4) `{ ["subscriptionId":"net\authorize\api\contract\v1\ARBCreateSubscriptionResponse":private]=> NULL ["refId":"net\authorize\api\contract\v1\ANetApiResponseType":private]=> NULL ["messages":"net\authorize\api\contract\v1\ANetApiResponseType":private]=> NULL ["sessionToken":"net\authorize\api\contract\v1\ANetApiResponseType":private]=> NULL }` 

사람이 Laravel 작업 authorize.net를 얻을 수 있었다 그들이 그것을 어떻게 잠재적으로 저를 보여줄 수있다? 간단한에서

내 시도 충전

$merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); 
     $merchantAuthentication->setName("snip"); 
     $merchantAuthentication->setTransactionKey("snip"); 
     $refId = 'ref' . time(); 

     $creditCard = new AnetAPI\CreditCardType(); 
     $creditCard->setCardNumber("6011000000000012"); 
     $creditCard->setExpirationDate("2028-12"); 
     $paymentOne = new AnetAPI\PaymentType(); 
     $paymentOne->setCreditCard($creditCard); 

     // Create a transaction 
     $transactionRequestType = new AnetAPI\TransactionRequestType(); 
$transactionRequestType->setTransactionType("authCaptureTransaction"); 
     $transactionRequestType->setAmount(151.51); 
     $transactionRequestType->setPayment($paymentOne); 

     $request = new AnetAPI\CreateTransactionRequest(); 
     $request->setMerchantAuthentication($merchantAuthentication); 
     $request->setTransactionRequest($transactionRequestType); 
     $controller = new AnetController\CreateTransactionController($request); 
     $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); 
     var_dump($response); 
     echo "<br><br>"; 
     if ($response != null) 
     { 
      $tresponse = $response->getTransactionResponse(); 

if (($tresponse != null) && ($tresponse->getResponseCode()=="1")) 
      { 
       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"; 
     } 

내 composer.json

{ 
    "name": "laravel/laravel", 
    "description": "The Laravel Framework.", 
    "keywords": ["framework", "laravel"], 
    "license": "MIT", 
    "type": "project", 
    "require": { 
     "php": ">=5.5.9", 
     "laravel/framework": "5.2.*", 
     "guzzlehttp/guzzle": "^6.0", 
     "ext-curl": "^0.0.0", 
     "authorizenet/authorizenet": "^1.8" 
    }, 
    "require-dev": { 
     "fzaninotto/faker": "~1.4", 
     "mockery/mockery": "0.9.*", 
     "phpunit/phpunit": "~4.0", 
     "symfony/css-selector": "2.8.*|3.0.*", 
     "symfony/dom-crawler": "2.8.*|3.0.*", 
     "goetas/xsd2php": "2.0.x-dev#fdc2ab0bb3f2b3ab796ca567cf8c0f3446a7ea3a" 
    }, 
    "autoload": { 
     "classmap": [ 
      "database" 
     ], 
     "psr-4": { 
      "App\\": "app/" 
     }, 
     "files": ["app/Http/helpers.php"] 
    }, 
    "autoload-dev": { 
     "classmap": [ 
      "tests/TestCase.php" 
     ] 
    }, 
    "scripts": { 
     "post-root-package-install": [ 
      "php -r \"copy('.env.example', '.env');\"" 
     ], 
     "post-create-project-cmd": [ 
      "php artisan key:generate" 
     ], 
     "post-install-cmd": [ 
      "Illuminate\\Foundation\\ComposerScripts::postInstall", 
      "php artisan optimize" 
     ], 
     "post-update-cmd": [ 
      "Illuminate\\Foundation\\ComposerScripts::postUpdate", 
      "php artisan optimize" 
     ] 
    }, 
    "config": { 
     "preferred-install": "dist" 
    }, 
    "repositories": [{ 
     "type": "vcs", 
     "url": "https://github.com/goetas/serializer.git" 
    }] 
} 
+0

으로 테스트 자격 증명을 만들어? –

+0

@JeremyHarris 최소한 트랜잭션 ID. 요청이 null이 아닌 경우 if() 문을 참조하십시오. –

+0

코드가 프로덕션 모드에서 사용 가능한 응답을 제공하지만 샌드 박스 모드가 아닌 것처럼 보입니다. @JeremyHarris –

답변

1

우리는 우리의 Laravel 5.2 프로젝트에서 Authorize.net SDK을 사용합니까. 우리의 작곡가 패키지는 귀하의 것과 동일합니다. 그러나 우리는 단순히 AuthorizeNetAIM과 직접 상호 작용합니다. Google의 지불 처리는 Job에서도 발생합니다. 우리의 모습은 다음과 같습니다.

public function handle() 
{ 
    $this->aim = new AuthorizeNetAIM(); 

    //functionality to add line items: 
    $this->aim->addLineItem($identifier, $name, null, $quantity, $price_per_item); 

    $this->aim->amount = $this->order->total; 
    $this->aim->card_num = $this->card_ref->card_num 
    $this->aim->exp_date = $this->card_ref->exp_date 
    $this->aim->first_name = $this->card_ref->first_name; 
    $this->aim->last_name = $this->card_ref->last_name; 
    $this->aim->address = $this->order->billing_address_1 . ' ' . $this->order->billing_address_2; 
    $this->aim->city = $this->order->billing_city; 
    $this->aim->state = $this->order->billing_state; 
    $this->aim->zip = $this->order->billing_zip_code; 
    $this->aim->country = $this->order->billing_country; 
    $this->aim->email = $this->order->contact->email; 
    $this->aim->phone = $this->order->contact->phone; 
    $this->aim->ship_to_address = $this->order->shipping_address_1 . ' ' . $this->order->shipping_address_2; 
    $this->aim->ship_to_city = $this->order->shipping_city; 
    $this->aim->ship_to_country = $this->order->shipping_country; 
    $this->aim->ship_to_first_name = $this->order->first_name; 
    $this->aim->ship_to_last_name = $this->order->last_name; 
    $this->aim->ship_to_state = $this->order->shipping_state; 
    $this->aim->ship_to_zip = $this->order->shipping_zip_code; 

    //You may also need to assign additional fields required by your Gateway configuration, do so here: 
    $this->aim->setField('card_code', $this->card_ref->cvc); 
    $this->aim->setField('invoice_num', $this->order->invoice_num); 
    $this->aim->setField('po_num', $this->order->id); 

    //now we assign our "ref" as value so we can rerun the transaction in the event of failure. 
    $this->aim->setCustomField('ref', 'ref' . time()); 

    //Finally we auth and capture 
    $response = $this->aim->authorizeAndCapture(); 

    //now you can dump the response 
    dd($response); 

} 

바라건대 이것은 당신에게 도움이되기를 바랍니다.

1

향후 누군가에게이 문제가 발생하면 답을 쓰고 있습니다.

내 authorize.net 계정이 TEST 대신 LIVE로 설정되었으므로 코드가 작동하지 않았습니다. 계정을 LIVE로 설정하면

$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); 

까지 코드를 테스트 할 수 없습니다.

나는 this link 당신이 얻을 기대하고 무엇 응답