0

내 개발중인 wordpress 플러그인에 paypal express checkout 버튼을 구현하고 있습니다.페이팔 체크 아웃 자바 스크립트 오류 - this20.getParentTemplate이 함수가 아닙니다.

나는 "주문 확인"버튼이있는 편집 주문 페이지가 있습니다. 여기에는 체크 아웃 버튼이 렌더링되는 총 지불 금액을 확인하는 팝업 모달 메시지가 있습니다.

$("#mdp-order-button").click(function(e){ 
    e.preventDefault(); 
    mdp_render_confirm_modal(); 
}); 

function mdp_render_confirm_modal(){ 
    if (!$("#mdp_upload_image")[0].files[0]){ 
     alert("please upload an image first"); 
    }else{ 
     if(mdp_check_overlap()){ 
      alert("the block is either out of the grid or overlapped with other block, please place it again"); 
     }else{ 
      var current_block = $('.current_block'); 
      var cost = current_block.width() * current_block.height(); 
      $('#mdp-show-size').html("Your block is "+current_block.width()+"px X "+current_block.height()+"px"); 
      $('#mdp-show-cost').html("Total: "+cost); 
      $('#mdp-modal').show(); 
      $('#mdp-close').click(function(){ 
       $('mdp-modal').hide(); 
      }) 
      mdp_render_paypal_button(cost) 
     } 
    } 
} 

function mdp_render_paypal_button(charge) { 

    paypal.Button.render({ 

     env: 'sandbox', // Or 'sandbox' 

     commit: true, // Show a 'Pay Now' button 

     client: { 
      sandbox: 'censored xxxxx' 
     }, 

     payment: function() { 
      return paypal.rest.payment.create(this.props.env, this.props.client, { 
       transactions: [ 
        { 
         amount: { 
          total: charge, 
          currency: 'USD' 
         } 
        } 
       ] 
      }); 
     }, 

     onAuthorize: function(data, actions) { 
      return actions.payment.execute().then(function(response) { 
       console.log(response); 
      }); 
     } 
    }, '#paypal-button'); 
} 

내가 체크 아웃 버튼, 페이팔 창 팝업을 클릭하고 바로 종료, 에러가 나는 웹 검색을 시도

checkout.js:4225 ppxo_xc_ppcheckout_destroy Object {timestamp: 1494405598944, windowID: "53bb903148", pageID: "84e2908f4a", host: "www.sandbox.paypal.com", path: "/webapps/hermes/button"…} 
checkout.js:2021 Uncaught Error: _this20.getParentTemplate is not a function 
TypeError: _this20.getParentTemplate is not a function 
    at Object.onSuccess (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:9346:40) 
    at _loop2 (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1077:62) 
    at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1107:29) 
    at SyncPromise.then (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1125:18) 
    at Function.syncPromiseTry [as try] (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1170:42) 
    at DelegateComponent.openContainer (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:9342:55) 
    at Object.onSuccess (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:8556:35) 
    at _loop2 (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1077:62) 
    at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1107:29) 
    at SyncPromise.then (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1125:18) 
    at Object.onSuccess (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:9346:40) 
    at _loop2 (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1077:62) 
    at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1107:29) 
    at SyncPromise.then (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1125:18) 
    at Function.syncPromiseTry [as try] (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1170:42) 
    at DelegateComponent.openContainer (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:9342:55) 
    at Object.onSuccess (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:8556:35) 
    at _loop2 (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1077:62) 
    at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1107:29) 
    at SyncPromise.then (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1125:18) 
    at Object._RECEIVE_MESSAGE_TYPE.(anonymous function) [as postrobot_message_response] (https://www.paypalobjects.com/api/checkout.js:2021:118) 
    at receiveMessage (https://www.paypalobjects.com/api/checkout.js:1929:73) 
    at messageListener (https://www.paypalobjects.com/api/checkout.js:1949:13) 

콘솔에 표시되지만

나는 더 비슷한 질문을 찾을 수 없습니다 도큐멘테이션이 아니며 실제로 이런 일이 발생하는 이유에 대한 아이디어가 없습니다. 도움에 미리, 전체 역

+0

어떻게로드 checkout.js입니까? 특정 버전을로드하고 있습니까? 당신은 당신의 콘솔에'paypal.version'을 입력 해 보시고 알려주세요. – bluepnume

+0

PayPal에서 제공하는 URL에서 추천대로 직접로드 할 수 있습니다. 집에 한번 확인해 보겠습니다. –

+0

"https : // www. paypalobjects.com/api/checkout.js "샘플 코드를 복사하여 수정했지만 확인하고 확인합니다. –

답변

0

에서

덕분에 @bluepnume 도와 주셔서 너무 감사드립니다.

기본적으로로드되는 스크립트에 쿼리 문자열 "ver = 'current_wordpress_version'을 추가하면 해당 스크립트가로드되는 방식에 문제가 있습니다.이 스크립트는 기본적으로 checkout.js의 최신 버전을 사용하고 있습니다. 대신

wp_enqueue_script('paypal_checkout', 'https://www.paypalobjects.com/api/checkout.js'); 

지금

wp_enqueue_script('paypal_checkout', 'https://www.paypalobjects.com/api/checkout.js',array(),null);