<% GatewayHost = "https://www.paypal.com/webscr&cmd=_express-checkout&token=" '"https://pilot-payflowpro.paypal.com" Password = "2JXY3TSZPKLVDAXZ " UserID = "rhondas_api1.spiritfitness.com" ' Start out declaring our variables. signature="A0YjT6a847CLajwdjrFZRObk41D7A5GNs953V9RfqZdcc3qTrUl68t6s" Dim objWinHttp Dim strHTML Dim parmList Dim requestID PAYPAL_URL = PAYPAL_EC_URL ' Need to generate a unique id for the request id response.write "hello
" if request.querystring("token")="" then response.write "empty token
" currencyCodeType="USD" paymenttype="Sale" 'Build the parameter list ' 'This a very, very basic implementation to just how how you can post data. What data 'you decide to send and how your react to the response is a business decision that you 'must make. set conn = Server.Createobject("adodb.connection") set rs = server.createobject("adodb.recordset") conn.open connstr if session("orderid") = "" then orderid="0" else orderid = session("orderid") end if if orderid = "0" then session("errmsg")="Your shopping cart is empty" response.redirect "http://www.spiritfitness.com/shop/form.asp" else response.write "retrieving order
" rs.open "select * from orders where id = " & orderid, conn,3,1 if rs.eof then rs.close conn.close session("errmsg")="Order has not been created, can't update, please try again" response.redirect "http://www.spiritfitness.com/shop/abandon.asp" end if if rs("approved") then rs.close conn.close session("errmsg")="Order has been completed and paid for, can't update" response.redirect "http://www.spiritfitness.com/shop/abandon.asp" end if end if paymentamount = rs("ordertotal") if paymentamount=0 then paymentamount =rs("subtotalprice")-rs("discount") if paymentamount =0 then paymentamount = request("subtotal") end if end if rs.close conn.close response.write "gathering params
" parmList = "&" parmList = parmList & Server.URLEncode("AMT")&"=" & (replace(formatnumber(paymentamount,2),",",""))&"&" parmList = parmList & Server.URLEncode("PAYMENTACTION")&"=" &Server.URLEncode("Sale")&"&" parmList = parmList & Server.URLEncode("DESC")&"=" &Server.URLEncode("Purchase From Spirit Fitness")&"&" parmList = parmList & Server.URLEncode("CANCELURL")&"=" &Server.URLEncode("http://www.spiritfitness.com/shop/cart_alpha.asp")&"&" ' parmList = parmList & Server.URLEncode("RETURNURL")&"=" &Server.URLEncode("https://www.spiritfitness.com/checkout/exp_ch2.asp") parmList = parmList & Server.URLEncode("RETURNURL")&"=" &Server.URLEncode("https://www.spiritfitness.com/checkout/exp_ch2.asp?currencyCodeType=" & currencyCodeType & _ "&paymentAmount=" & paymentAmount & _ "&paymentType=" &paymentType) response.write parmlist & "

" response.write "hashcall
" Set resArray=hash_call("SetExpressCheckout",parmList) Set SESSION("nvpResArray")=resArray response.write "resarray="& resarray.count & "
" for i = 0 to resarray.count response.write i & " - " & resarray(i)& "
" next ack = UCase(resArray("ACK")) If ack="SUCCESS" Then response.write "success - redirect
" ' Redirect to paypal.com here token = resArray("TOKEN") session("token")=token payPalURL = PAYPAL_URL & "?cmd=_express-checkout&token=" & token set conn = Server.Createobject("adodb.connection") conn.open connstr conn.execute "update orders set token = '" & token & "' where id = " & session("orderid") conn.close ReDirectURL(payPalURL) Else response.write "failed
" 'Redirecting to APIError.asp to display errors. message="PayPal API has returned an error!" & ack SESSION("msg")=message response.write message 'Response.Redirect "APIError.asp" End If else SESSION("token") = Request.Querystring("TOKEN") SESSION("currencyCodeType") = Request.Querystring("currencyCodeType") SESSION("paymentAmount") = Request.Querystring("paymentAmount") SESSION("PaymentType")= Request.Querystring("PaymentType") SESSION("PayerID")= Request.Querystring("PayerID") '--------------------------------------------------------------------------- 'Build a second API request to PayPal, using the token as the 'ID to get the details on the payment authorization '--------------------------------------------------------------------------- nvpstr="&TOKEN="&Request.Querystring("TOKEN") '--------------------------------------------------------------------------- ' Make the API call and store the results in an array. If the 'call was a success, show the authorization details, and provide ' an action to complete the payment. If failed, show the error '--------------------------------------------------------------------------- Set resArray=hash_call("GetExpressCheckoutDetails",nvpstr) ack = UCase(resArray("ACK")) Set SESSION("nvpResArray")=resArray If UCase(ack)="SUCCESS" Then Response.Redirect "GetExpressCheckoutDetails.asp" Else SESSION("msg")="Review Order.PayPal API has returned an error!" 'Response.Redirect "APIError.asp" End If end if %>