2015-01-04 4 views
0

나는 신용 카드 지불을 설정하고 균형 지불 테스트 마켓 플레이스를 사용하는 방법을 배우려고 시도했습니다. 이전에 try catch 구문을 설정하지 않았으며 응답 처리에 문제가 있습니다.Balanced-Payments 캐치 응답 시도

try{ 
     $card->debits->create(array(
     "amount" => $amount, 
     "appears_on_statement_as" => "test", 
     "description" => $invoiceId, 
     "order" => $order, 
     )); 

     } catch (Balanced\Errors\Declined $e) { 
      $this->arrResponse['status'] = $e->getMessage(); 
      return Response::json($this->arrResponse); 
     } 
     $invoice->save(); 

     // send email function... 
     //redirect 
     $this->arrResponse['status'] = SUCCESS; 
      return Response::json($this->arrResponse); 

내가 크롬 개발자 도구에 대한 오류를 볼 수 있습니다,하지만 난 내보기에 표시 할 수 없습니다 :

여기 내 컨트롤러 시도/catch 문이다.

크롬 개발 도구 (500) 내부 서버 오류 문 :

error: {type: "Balanced\Errors\Declined", message: "",…} 
file: "/Applications/MAMP/htdocs/testcc/vendor/balanced/balanced/src/Balanced/Errors/Error.php" 
line: 42 
message: "" 
type: "Balanced\Errors\Declined 

processpayment.js 파일 : 테스트 카드가 성공적으로 처리 될 때

jQuery.post(baseURL+'/processPayment', { 
      uri: fundingInstrument.href, 
      amount: amount, 
      invoiceId: invoiceId, 
     }, function(r) { 
      // backend response 
      if (r.status === 200) { 
       $('#msgSection').empty().removeClass('alert-error alert-success').addClass('alert-success').text(' payment has been received').show(); 

      } else { 
       // failure from backend 
       $('#msgSection').empty().removeClass('alert-success').addClass('alert-warning').text('error').show(); 
      } 
     }); 

, 모든 작품과 성공 메시지가 내보기에 나타납니다. 그러나 거부 된 테스트 카드를 사용하면 내보기로 메시지가 전송되지 않습니다. 누구든지 내가 뭘 잘못하고 있는지 알아?

답변

2

는 그들이 그렇게 코드가 같은 것 here

에서의 try catch 블록을 사용하는 방식을 볼 수 평형 PHP 클라이언트있는 TestSuite를 확인하려고합니다.

try{ 
     $card->debits->create(array(
      "amount" => $amount, 
      "appears_on_statement_as" => "test", 
      "description" => $invoiceId, 
      "order" => $order, 
     )); 

    } catch (Balanced\Errors\Declined $e) { 
     $this->arrResponse['status'] = $e->category_code; 
     return Response::json($this->arrResponse); 
    } 
    $invoice->save(); 

    // send email function... 
    //redirect 
    $this->arrResponse['status'] = SUCCESS; 
    return Response::json($this->arrResponse); 

$e->category_code 중 하나 funding-destination-declined 또는 authorization-failed 또는 card-declined

될 것입니다