Created
December 14, 2011 17:08
-
-
Save SidneyAllen/1477483 to your computer and use it in GitHub Desktop.
jqm-cf-subscribe-04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Our method, credentials, and api version | |
data.METHOD = "SetExpressCheckout"; | |
data.USER = request.UID; | |
data.PWD = request.PASSWORD; | |
data.SIGNATURE = request.SIG; | |
data.METHOD = "SetExpressCheckout"; | |
data.VERSION = request.VER; | |
// Our api endpoint | |
data.URLBASE = request.URLBASE; | |
data.USEPROXY = false; | |
// Our required parameters for a subscription | |
data.PAYMENTREQUEST_0_CURRENCYCODE="USD"; | |
data.L_BILLINGTYPE0 ="RecurringPayments"; | |
data.L_BILLINGAGREEMENTDESCRIPTION0 ="Full access to content ..."; | |
data.ITEMAMT="19.99"; | |
data.amt = data.ITEMAMT; | |
// Our return and cancel url | |
data.serverName = SERVER_NAME; | |
data.serverPort = CGI.SERVER_PORT; | |
data.contextPath = GetDirectoryFromPath(#SCRIPT_NAME#); | |
data.protocol = CGI.SERVER_PROTOCOL; | |
var cancelPage = "index.html"; | |
var returnPage = "paid.cfm?1=1"; | |
data.cancelURL = "http://" & serverName & ":" & serverPort & contextPath & cancelPage; | |
data.returnURL = "http://" & serverName & ":" & serverPort & contextPath & returnPage & "&amt=#data.amt#¤cycode=#data.PAYMENTREQUEST_0_CURRENCYCODE#"; | |
// Our helper method for making the API call | |
response = helper.doHttppost(data); | |
//URL Decode the response from PayPal | |
responseStruct = callerService.getNVPResponse(#URLDecode(response)#); | |
token = responseStruct.token; | |
// Add the redirect URL to our Structure | |
redirecturl = request.URLREDIRECT & token; | |
returnObj['success'] = true; | |
returnObj['redirecturl'] = redirecturl; | |
// Serialize our object and return it to our app | |
return serializeJSON(returnObj); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment