Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

PHP

<cfset apikey = '000000'>
<cfset apipassword = 'password'>

<!-- call getauthorizenetkey for credentials -->
<cfhttp url="https://www.floristone.com/api/rest/flowershop/getauthorizenetkey" method="get">
  <cfhttpparam type="header" name="Authorization" value="Basic #toBase64(apikey & ":" & apipassword)#">
</cfhttp>
<cfset authorizeneturl = deserializeJSON(cfhttp.filecontent.toString()).AUTHORIZENET_URL>
<cfset username = deserializeJSON(cfhttp.filecontent.toString()).USERNAME>
<cfset authnetkey = deserializeJSON(cfhttp.filecontent.toString()).AUTHORIZENET_KEY>

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <!-- include dynamic accept.js script from getauthorizenetkey --->
  <script type="text/javascript" src="<cfoutput>#authorizeneturl#</cfoutput>" charset="utf-8"></script> 
</head>
<body>  

  <a href="#" onclick="sendPaymentDataToAnet()">create token</a>

  <script type="text/javascript">

    function sendPaymentDataToAnet() {

      var authData = {
        // plug in dynamic authorizenet credentials from getauthorizenetkey
        clientKey: '<cfoutput>#authnetkey#</cfoutput>',
        apiLoginID: '<cfoutput>#username#</cfoutput>'
      }; 

      var cardData = {};
      cardData.cardNumber = "4242424242424242";
      cardData.month = "12";
      cardData.year = "22";
      cardData.cardCode = "123";

      var secureData = {};
      secureData.authData = authData;
      secureData.cardData = cardData;

      Accept.dispatchData(secureData, responseHandler);

    }

    function responseHandler(response){

      console.log(response);
      alert(response);

    }

  </script>

</body>
</html>
Source by florist.one #
 
PREVIOUS NEXT
Tagged: #PHP
ADD COMMENT
Topic
Name
9+2 =