Li

Delete

Are you sure you want to delete this?

ProgrammingModel


Date
20220304
Target
C_094
Title
doing Javascript SDK of PayPal after selecting country javascript
Contents
문)두 번 째 클릭은 안되는건가? CheckoutNoneMember에서 select해서 국가를 선택하면 배송비와 배송비를 포함한 상품금액이 산출된다. 이후 PayPal버튼으로 배송비를 포함한 상품금액을 운용하려고 버튼을 클릭하면 PayPal Script amount {value: } 답)아니 된다 hidden 이 문제였다. input type='hidden'의 경우 자바스크립트 사용시 보이지 않을 뿐 아니라 계산에서도 null이 된다. 두번 째 클릭도 된다. 페이팔 버튼을 누르면 실행이 된다. 그리고 span 태그의 경우 innerText로 가져와야 한다. PayPal javascript를 사용할 경우 다시 한 번 총정리해보자. 1. javascript의 경우 header로 와야 한다. script src=https://www.paypal.com/sdk/js?client-id=..." /script Is loading after you try to render the buttons, so the paypal object doesn't exist when the button tries to render. You need to ensure the script loads before you try to render the buttons, i.e. it needs to appear first on the page. One way to do this is to load the resource from head 2. In my case, selecting country makes the total price to pay for the customer, so after selecting country, the total price will be determined, at the moment the final price is determined by javascript checkDeliveryPrice.js. And then, PayPal javascript SDK is on the line waiting for pay. When click the PayPal btn. paypal.Buttons createOrder: function (data, actions) return actions.order.create purchase_units: amount: //value: document.getElementById('idDeliverPricePlusProductPrice').value value: document.getElementById('idNoneMemberTotalPriceWhenSelectedCountry'.innerText //value: @cartdata.ComputeTotalValue().ToString() //위에 있는 총액을 여기에 넣었다. 원화를 달라로 1200으로 나누어. onApprove: function (data, actions) return actions.order.capture().then(function (details) alert('Transaction completed by ' + details.payer.name.given_name); .render('#paypal-button-container // Display payment options on your web page are working. In this working 'value: document.getElementById('idNoneMemberTotalPriceWhenSelectedCountry').innerText' is the answer. Wrong doing was input type="hidden" id="idDeliverPricePlusProductPrice" value="" It must be changed input type="text" id="idDeliverPricePlusProductPrice" value="" Because the type styles of input are hidden and text, hidden means null to javascript, so it makes fault. So the type text makes correct work for javascript. Seeing is the answer for HTML.