I'm looking at PayPal to add a simple payment mechanism to my web site.
I only have one fixed product to sell, so I don't think I need to create an order form other than a page to put the button on.
PayPal's Express Checkout setup looks like it gives you the HTML to add the button on your page.
All I need to do now is get back an immediate authorization.
I'm just using Rick's base classes. Are there any examples of a simple approach for this?
Thanks,
Rod
Express checkout relies on an order flow that requires that your application make a number of HTTP calls to PayPals servers.
This link has the details:
https://developer.paypal.com/docs/classic/express-checkout/ht_ec-singleItemPayment-curl-etc/
You can use wwHttp to make these HTTP calls and you'll need to implement the Cancel and Success endpoints as Web Connection handlers to receive the results from PayPal.
This isn't really very different from the way the old classic PayPal process worked - but it is uses different attribute names and the flow is slightly different with one more intermediate step to review the order on your site (which IMHO makes this process even more annoying), so it is different.
FWIW, I would recommend looking into standard Credit Card checkout solutions like BrainTree, Stripe or MerchantPlus's flat rate checkout solutions. These tend to be really easy to get setup with (no merchant bank approval process etc.), but more importantly they are server driven so you don't have to deal with the funky PayPal flow through the PayPal site.
Not saying that PayPal can't work, but I tend to think of PayPal as an 'add-on' solution rather than a primary pay platform.
+++ Rick ---
Hi All,
I'm looking at PayPal to add a simple payment mechanism to my web site.
I only have one fixed product to sell, so I don't think I need to create an order form other than a page to put the button on.
PayPal's Express Checkout setup looks like it gives you the HTML to add the button on your page.
All I need to do now is get back an immediate authorization.
I'm just using Rick's base classes. Are there any examples of a simple approach for this?
Thanks,
Rod
West Wind Technologies
Making waves on the Web
from Maui
Can anyone show me some code that implements the PayPal express checkout using wwHttp?
I've looked at it long and hard, but could sure use a leg-up!
Thanks.
Rod,
Express checkout relies on an order flow that requires that your application make a number of HTTP calls to PayPals servers.
This link has the details:
https://developer.paypal.com/docs/classic/express-checkout/ht_ec-singleItemPayment-curl-etc/
You can use wwHttp to make these HTTP calls and you'll need to implement the Cancel and Success endpoints as Web Connection handlers to receive the results from PayPal.
This isn't really very different from the way the old classic PayPal process worked - but it is uses different attribute names and the flow is slightly different with one more intermediate step to review the order on your site (which IMHO makes this process even more annoying), so it is different.
FWIW, I would recommend looking into standard Credit Card checkout solutions like BrainTree, Stripe or MerchantPlus's flat rate checkout solutions. These tend to be really easy to get setup with (no merchant bank approval process etc.), but more importantly they are server driven so you don't have to deal with the funky PayPal flow through the PayPal site.
Not saying that PayPal can't work, but I tend to think of PayPal as an 'add-on' solution rather than a primary pay platform.
+++ Rick ---
Hi All,
I'm looking at PayPal to add a simple payment mechanism to my web site.
I only have one fixed product to sell, so I don't think I need to create an order form other than a page to put the button on.
PayPal's Express Checkout setup looks like it gives you the HTML to add the button on your page.
All I need to do now is get back an immediate authorization.
I'm just using Rick's base classes. Are there any examples of a simple approach for this?
Thanks,
Rod
He also includes the VFP code in wwStore if you have or purchase a copy of that.
--hm
Thanks, Rick.
Can anyone show me some code that implements the PayPal express checkout using wwHttp?
I've looked at it long and hard, but could sure use a leg-up!
Thanks.
Rod,
Express checkout relies on an order flow that requires that your application make a number of HTTP calls to PayPals servers.
This link has the details:
https://developer.paypal.com/docs/classic/express-checkout/ht_ec-singleItemPayment-curl-etc/
You can use wwHttp to make these HTTP calls and you'll need to implement the Cancel and Success endpoints as Web Connection handlers to receive the results from PayPal.
This isn't really very different from the way the old classic PayPal process worked - but it is uses different attribute names and the flow is slightly different with one more intermediate step to review the order on your site (which IMHO makes this process even more annoying), so it is different.
FWIW, I would recommend looking into standard Credit Card checkout solutions like BrainTree, Stripe or MerchantPlus's flat rate checkout solutions. These tend to be really easy to get setup with (no merchant bank approval process etc.), but more importantly they are server driven so you don't have to deal with the funky PayPal flow through the PayPal site.
Not saying that PayPal can't work, but I tend to think of PayPal as an 'add-on' solution rather than a primary pay platform.
+++ Rick ---
Hi All,
I'm looking at PayPal to add a simple payment mechanism to my web site.
I only have one fixed product to sell, so I don't think I need to create an order form other than a page to put the button on.
PayPal's Express Checkout setup looks like it gives you the HTML to add the button on your page.
All I need to do now is get back an immediate authorization.
I'm just using Rick's base classes. Are there any examples of a simple approach for this?
Thanks,
Rod
--hm--
Yes, I looked at that but assumed it was the older PayPal API due to the date of the article. Also I don't know ASP.NET. Only VFP and HTML.
I was hoping someone out there had done the simplest possible PayPal integration using wwHTML and PayPal's new Express CheckOut API.
Rod
Rick is offline for a week or so but I know he wrote a whitepaper on interfacing to PayPal several years ago. Here is a link:
He also includes the VFP code in wwStore if you have or purchase a copy of that.
--hm
Thanks, Rick.
Can anyone show me some code that implements the PayPal express checkout using wwHttp?
I've looked at it long and hard, but could sure use a leg-up!
Thanks.
Rod,
Express checkout relies on an order flow that requires that your application make a number of HTTP calls to PayPals servers.
This link has the details:
https://developer.paypal.com/docs/classic/express-checkout/ht_ec-singleItemPayment-curl-etc/
You can use wwHttp to make these HTTP calls and you'll need to implement the Cancel and Success endpoints as Web Connection handlers to receive the results from PayPal.
This isn't really very different from the way the old classic PayPal process worked - but it is uses different attribute names and the flow is slightly different with one more intermediate step to review the order on your site (which IMHO makes this process even more annoying), so it is different.
FWIW, I would recommend looking into standard Credit Card checkout solutions like BrainTree, Stripe or MerchantPlus's flat rate checkout solutions. These tend to be really easy to get setup with (no merchant bank approval process etc.), but more importantly they are server driven so you don't have to deal with the funky PayPal flow through the PayPal site.
Not saying that PayPal can't work, but I tend to think of PayPal as an 'add-on' solution rather than a primary pay platform.
+++ Rick ---
Hi All,
I'm looking at PayPal to add a simple payment mechanism to my web site.
I only have one fixed product to sell, so I don't think I need to create an order form other than a page to put the button on.
PayPal's Express Checkout setup looks like it gives you the HTML to add the button on your page.
All I need to do now is get back an immediate authorization.
I'm just using Rick's base classes. Are there any examples of a simple approach for this?
Thanks,
Rod
Thanks, Harvey.
Yes, I looked at that but assumed it was the older PayPal API due to the date of the article. Also I don't know ASP.NET. Only VFP and HTML.
I was hoping someone out there had done the simplest possible PayPal integration using wwHTML and PayPal's new Express CheckOut API.
Rod
Rick is offline for a week or so but I know he wrote a whitepaper on interfacing to PayPal several years ago. Here is a link:
He also includes the VFP code in wwStore if you have or purchase a copy of that.
--hm
Thanks, Rick.
Can anyone show me some code that implements the PayPal express checkout using wwHttp?
I've looked at it long and hard, but could sure use a leg-up!
Thanks.
Rod,
Express checkout relies on an order flow that requires that your application make a number of HTTP calls to PayPals servers.
This link has the details:
https://developer.paypal.com/docs/classic/express-checkout/ht_ec-singleItemPayment-curl-etc/
You can use wwHttp to make these HTTP calls and you'll need to implement the Cancel and Success endpoints as Web Connection handlers to receive the results from PayPal.
This isn't really very different from the way the old classic PayPal process worked - but it is uses different attribute names and the flow is slightly different with one more intermediate step to review the order on your site (which IMHO makes this process even more annoying), so it is different.
FWIW, I would recommend looking into standard Credit Card checkout solutions like BrainTree, Stripe or MerchantPlus's flat rate checkout solutions. These tend to be really easy to get setup with (no merchant bank approval process etc.), but more importantly they are server driven so you don't have to deal with the funky PayPal flow through the PayPal site.
Not saying that PayPal can't work, but I tend to think of PayPal as an 'add-on' solution rather than a primary pay platform.
+++ Rick ---
Hi All,
I'm looking at PayPal to add a simple payment mechanism to my web site.
I only have one fixed product to sell, so I don't think I need to create an order form other than a page to put the button on.
PayPal's Express Checkout setup looks like it gives you the HTML to add the button on your page.
All I need to do now is get back an immediate authorization.
I'm just using Rick's base classes. Are there any examples of a simple approach for this?
Thanks,
Rod
As for PayPal, it wants an "empty" HTTP 200 post to start off the confirmation process, but I don't know how to do that in WWWC and the pages in the help file I've looked at so far don't seem to be leading me to the solution. Can you offer some help on that?
Rod,
Express checkout relies on an order flow that requires that your application make a number of HTTP calls to PayPals servers.
This link has the details:
https://developer.paypal.com/docs/classic/express-checkout/ht_ec-singleItemPayment-curl-etc/
You can use wwHttp to make these HTTP calls and you'll need to implement the Cancel and Success endpoints as Web Connection handlers to receive the results from PayPal.
This isn't really very different from the way the old classic PayPal process worked - but it is uses different attribute names and the flow is slightly different with one more intermediate step to review the order on your site (which IMHO makes this process even more annoying), so it is different.
FWIW, I would recommend looking into standard Credit Card checkout solutions like BrainTree, Stripe or MerchantPlus's flat rate checkout solutions. These tend to be really easy to get setup with (no merchant bank approval process etc.), but more importantly they are server driven so you don't have to deal with the funky PayPal flow through the PayPal site.
Not saying that PayPal can't work, but I tend to think of PayPal as an 'add-on' solution rather than a primary pay platform.
+++ Rick ---
Hi All,
I'm looking at PayPal to add a simple payment mechanism to my web site.
I only have one fixed product to sell, so I don't think I need to create an order form other than a page to put the button on.
PayPal's Express Checkout setup looks like it gives you the HTML to add the button on your page.
All I need to do now is get back an immediate authorization.
I'm just using Rick's base classes. Are there any examples of a simple approach for this?
Thanks,
Rod
Empty POST operation? That's kind of pointless, but you can do that easily with wwHttp. Just add an empty string to the POST buffer. Make sure to explicitly set cHttpVerb to POST. Otherwise I think it wouldn't work because it wouldn't use post for an empty POST buffer.
+++ Rick ---
Looking at the docs on those systems you suggest, I'm not really seeing them as any easier. Also, I'm not sure what you mean when you say they are "server driven."
As for PayPal, it wants an "empty" HTTP 200 post to start off the confirmation process, but I don't know how to do that in WWWC and the pages in the help file I've looked at so far don't seem to be leading me to the solution. Can you offer some help on that?
Rod,
Express checkout relies on an order flow that requires that your application make a number of HTTP calls to PayPals servers.
This link has the details:
https://developer.paypal.com/docs/classic/express-checkout/ht_ec-singleItemPayment-curl-etc/
You can use wwHttp to make these HTTP calls and you'll need to implement the Cancel and Success endpoints as Web Connection handlers to receive the results from PayPal.
This isn't really very different from the way the old classic PayPal process worked - but it is uses different attribute names and the flow is slightly different with one more intermediate step to review the order on your site (which IMHO makes this process even more annoying), so it is different.
FWIW, I would recommend looking into standard Credit Card checkout solutions like BrainTree, Stripe or MerchantPlus's flat rate checkout solutions. These tend to be really easy to get setup with (no merchant bank approval process etc.), but more importantly they are server driven so you don't have to deal with the funky PayPal flow through the PayPal site.
Not saying that PayPal can't work, but I tend to think of PayPal as an 'add-on' solution rather than a primary pay platform.
+++ Rick ---
Hi All,
I'm looking at PayPal to add a simple payment mechanism to my web site.
I only have one fixed product to sell, so I don't think I need to create an order form other than a page to put the button on.
PayPal's Express Checkout setup looks like it gives you the HTML to add the button on your page.
All I need to do now is get back an immediate authorization.
I'm just using Rick's base classes. Are there any examples of a simple approach for this?
Thanks,
Rod
West Wind Technologies
Making waves on the Web
from Maui
Here's the code to make the initial connection from our site to the PP page:
loHTTP = This.PayPalCaller([SetExpressCheckout])
lcReturnURL = Config.cACEWebURL + [PayServiceHandler] + MapExt
lcCancelURL = Config.cACEWebURL + [PayServiceCancel] + MapExt
loHTTP.AddPostkey([RETURNURL],lcReturnURL)
loHTTP.AddPostkey([CANCELURL],lcCancelURL)
loHTTP.AddPostkey([PAYMENTREQUEST_0_AMT],pcAmount)
loHTTP.AddPostkey([PAYMENTREQUEST_0_PAYMENTACTION],[Sale])
loHTTP.AddPostkey([PAYMENTREQUEST_0_CURRENCYCODE],[USD])
loHTTP.AddPostkey([BUTTONSOURCE],lcBNCode)
lcPostBuffer = loHTTP.cPostBuffer
lcData = loHTTP.HttpGet(GETWORDNUM(pcPCCPath,1,[,]))
loHTTP = NULL
lcToken = nvpParse(lcData,[Token])
IF !EMPTY(lcToken)
lcServerURL = GETWORDNUM(pcPCCPath,2,[,])+[&token=]+lcToken
Response.redirect(lcServerURL)
RETURN
ELSE
ERROR [Failed to make connection with PayPal server]
ENDIF
Below are some of the helper functions used. PayPalCaller instantiates the WWHTTP object and assigns standard properties, including the credentials which are read from a config file using INIParse. In production, we encrypt those entries; I left out the code that handles the decryption. The trace method optionally writes info to a log for debugging purposes.
FUNCTION PayPalCaller ( lcMethod )LOCAL loHTTP AS 'wwHTTP'
LOCAL lcAPIUser, lcINI, lcPwd, lcServerURL, lcSignature
lcINI = [AWSYS]
lcAPIUser = iniParse(@lcINI, [APIUsername], , .T.)
lcSignature = iniParse(lcINI, [APISignature], , .T.)
lcPwd = iniParse(lcINI, [APIPassword], , .T.)
DO wwHTTP
loHTTP = CREATEOBJECT('wwHTTP')
loHTTP.nhttpPostmode = 1
loHTTP.chttpProxyname = []
loHTTP.AddPostkey([METHOD], lcMethod)
IF !EMPTY(lcPwd)
loHTTP.AddPostkey([PWD], lcPwd)
ENDIF
IF !EMPTY(lcSignature)
loHTTP.AddPostkey([SIGNATURE], lcSignature)
ENDIF
loHTTP.AddPostkey([USER], lcAPIUser)
loHTTP.AddPostkey([VERSION], [117])
RETURN loHTTPENDFUNC && PayPalCaller
FUNCTION nvpParse(lcString,lcTag)
IF EMPTY(lcString)
RETURN []
ENDIF
RETURN STREXTRACT(lcString,lcTag+[=],[&],1,3)
ENDFUNCFUNCTION iniParse(lcINI,lcTag,lcSection,llDecrypt,lcCloser)
LOCAL lcResult, i, llDoneIF EMPTY(lcINI) OR EMPTY(lcTag)
RETURN []
ENDIF
IF [=]$lcINI
* Assume INI contents are being passed in
ELSE
* Assume it's the file name
IF EMPTY(JUSTEXT(lcINI))
lcINI = lcINI + [.INI]
ENDIF
IF EMPTY(JUSTPATH(lcINI))
lcINI = pcSysHome + lcINI
ENDIF
IF !FILE(lcINI)
RETURN []
ELSE
lcINI = FILETOSTR(lcIni)
ENDIF
ENDIF
IF !EMPTY(lcSection)
lcINI = STREXTRACT(lcINI,'['+lcSection+']','',1,1)
ENDIF
IF !VARTYPE(lcCloser)=[C]
lcCloser = CHR(13)
ENDIF
i = 1
lcResult = STREXTRACT(lcINI,lcTag+[=],lcCloser,i,3)
IF !EMPTY(lcResult)
DO WHILE ! llDone && Make sure entry was not commented out
llDone = (ATC([;]+lcTag+[=]+lcResult,lcINI)=0) OR i > 99
IF !llDone
i = i + 1
lcResult = STREXTRACT(lcINI,lcTag+[=],lcCloser,i,3)
ENDIF
ENDDO
ENDIFENDFUNC
Here's the routine that handles the return call from PayPal. Note that we have to make two more calls back to the PP server in order to get the details and finalize the payment...
lcServerURL = GETWORDNUM(lcPccpath,1,[,])
loHTTP = This.PayPalCaller([GetExpressCheckoutDetails])
lcToken = Request.Params([Token])
loHTTP.AddPostKey([TOKEN],lcToken)
lcPostBuffer = loHTTP.cPostBuffer
This.trace('PYSRVDETAILS',[GetExpressCheckoutDetails at ]+lcServerURL+[ Buffer=]+lcPostBuffer) &&STRTRAN(STRTRAN(lcPostBuffer,lcPwd,[#########]),lcSignature,[#########]))
lcData = loHTTP.HttpGet(lcServerURL)
This.trace('PYSRVDETAILS',[Result: ]+lcData)
loHTTP = NULL
lcStatus = UPPER(NVPParse(lcData,[ACK]))
IF lcStatus = [SUCCESS]
lcPayerID = NVPParse(lcData,[PayerID])
loHTTP = This.PayPalCaller([DoExpressCheckoutPayment])
loHTTP.AddPostKey([TOKEN],lcToken)
loHTTP.AddPostKey([PAYERID],lcPayerID)
lcAmount = Desanitize(NVPParse(lcData,[Amt]),[%2E])
loHTTP.AddPostkey([PAYMENTREQUEST_0_AMT],lcAmount)
loHTTP.AddPostkey([PAYMENTREQUEST_0_PAYMENTACTION],[Sale])
loHTTP.AddPostkey([PAYMENTREQUEST_0_CURRENCYCODE],[USD])
lcBNCode = iniParse([AWSYS],[BNCode], ,.T.)
loHTTP.AddPostkey([BUTTONSOURCE],lcBNCode)
lcPostBuffer = loHTTP.cPostBuffer
This.trace('PYSRVDETAILS',[DoExpressCheckoutPayment at ]+lcServerURL+[ Buffer=]+lcPostBuffer) &&STRTRAN(STRTRAN(lcPostBuffer,lcPwd,[#########]),lcSignature,[#########]))
lcResult = loHTTP.HttpGet(lcServerURL)
This.trace('PYSRVDETAILS',[Result: ]+lcResult)
lcStatus = UPPER(NVPParse(lcResult,[ACK]))
lcMsg = Desanitize(NVPParse(lcResult,[L_LONGMESSAGE0]),,.T.)
IF lcStatus = [SUCCESS]
lcTransid = NVPParse(lcResult,[PAYMENTINFO_0_TRANSACTIONID])
lcAuthnum = NVPParse(lcResult,[CORRELATIONID])
lnAmount = VAL(lcAmount)
lcPayType = EVL(STREXTRACT(lcPCCPath,[PayType:],[:],1,1),lcDefaultPayType)
ENDIF
loHTTP = NULL
ELSE
ERROR [Failed to get checkout details from PayPal server]
ENDIF
HTH.
--stein
Looking at the docs on those systems you suggest, I'm not really seeing them as any easier. Also, I'm not sure what you mean when you say they are "server driven."
As for PayPal, it wants an "empty" HTTP 200 post to start off the confirmation process, but I don't know how to do that in WWWC and the pages in the help file I've looked at so far don't seem to be leading me to the solution. Can you offer some help on that?
Rod,
Express checkout relies on an order flow that requires that your application make a number of HTTP calls to PayPals servers.
This link has the details:
https://developer.paypal.com/docs/classic/express-checkout/ht_ec-singleItemPayment-curl-etc/
You can use wwHttp to make these HTTP calls and you'll need to implement the Cancel and Success endpoints as Web Connection handlers to receive the results from PayPal.
This isn't really very different from the way the old classic PayPal process worked - but it is uses different attribute names and the flow is slightly different with one more intermediate step to review the order on your site (which IMHO makes this process even more annoying), so it is different.
FWIW, I would recommend looking into standard Credit Card checkout solutions like BrainTree, Stripe or MerchantPlus's flat rate checkout solutions. These tend to be really easy to get setup with (no merchant bank approval process etc.), but more importantly they are server driven so you don't have to deal with the funky PayPal flow through the PayPal site.
Not saying that PayPal can't work, but I tend to think of PayPal as an 'add-on' solution rather than a primary pay platform.
+++ Rick ---
Hi All,
I'm looking at PayPal to add a simple payment mechanism to my web site.
I only have one fixed product to sell, so I don't think I need to create an order form other than a page to put the button on.
PayPal's Express Checkout setup looks like it gives you the HTML to add the button on your page.
All I need to do now is get back an immediate authorization.
I'm just using Rick's base classes. Are there any examples of a simple approach for this?
Thanks,
Rod
I just wrote a module to integrate PayPal Express into our ecommerce app. We haven't run it in production yet, but it does work with their Sandbox servers.
Here's the code to make the initial connection from our site to the PP page:
loHTTP = This.PayPalCaller([SetExpressCheckout])
lcReturnURL = Config.cACEWebURL + [PayServiceHandler] + MapExt
lcCancelURL = Config.cACEWebURL + [PayServiceCancel] + MapExt
loHTTP.AddPostkey([RETURNURL],lcReturnURL)
loHTTP.AddPostkey([CANCELURL],lcCancelURL)
loHTTP.AddPostkey([PAYMENTREQUEST_0_AMT],pcAmount)
loHTTP.AddPostkey([PAYMENTREQUEST_0_PAYMENTACTION],[Sale])
loHTTP.AddPostkey([PAYMENTREQUEST_0_CURRENCYCODE],[USD])
loHTTP.AddPostkey([BUTTONSOURCE],lcBNCode)
lcPostBuffer = loHTTP.cPostBuffer
lcData = loHTTP.HttpGet(GETWORDNUM(pcPCCPath,1,[,]))
loHTTP = NULL
lcToken = nvpParse(lcData,[Token])
IF !EMPTY(lcToken)
lcServerURL = GETWORDNUM(pcPCCPath,2,[,])+[&token=]+lcToken
Response.redirect(lcServerURL)
RETURN
ELSE
ERROR [Failed to make connection with PayPal server]
ENDIF
Below are some of the helper functions used. PayPalCaller instantiates the WWHTTP object and assigns standard properties, including the credentials which are read from a config file using INIParse. In production, we encrypt those entries; I left out the code that handles the decryption. The trace method optionally writes info to a log for debugging purposes.
FUNCTION PayPalCaller ( lcMethod )LOCAL loHTTP AS 'wwHTTP'
LOCAL lcAPIUser, lcINI, lcPwd, lcServerURL, lcSignature
lcINI = [AWSYS]
lcAPIUser = iniParse(@lcINI, [APIUsername], , .T.)
lcSignature = iniParse(lcINI, [APISignature], , .T.)
lcPwd = iniParse(lcINI, [APIPassword], , .T.)
DO wwHTTP
loHTTP = CREATEOBJECT('wwHTTP')
loHTTP.nhttpPostmode = 1
loHTTP.chttpProxyname = []
loHTTP.AddPostkey([METHOD], lcMethod)
IF !EMPTY(lcPwd)
loHTTP.AddPostkey([PWD], lcPwd)
ENDIF
IF !EMPTY(lcSignature)
loHTTP.AddPostkey([SIGNATURE], lcSignature)
ENDIF
loHTTP.AddPostkey([USER], lcAPIUser)
loHTTP.AddPostkey([VERSION], [117])
RETURN loHTTPENDFUNC && PayPalCaller
FUNCTION nvpParse(lcString,lcTag)
IF EMPTY(lcString)
RETURN []
ENDIF
RETURN STREXTRACT(lcString,lcTag+[=],[&],1,3)
ENDFUNCFUNCTION iniParse(lcINI,lcTag,lcSection,llDecrypt,lcCloser)
LOCAL lcResult, i, llDoneIF EMPTY(lcINI) OR EMPTY(lcTag)
RETURN []
ENDIF
IF [=]$lcINI
* Assume INI contents are being passed in
ELSE
* Assume it's the file name
IF EMPTY(JUSTEXT(lcINI))
lcINI = lcINI + [.INI]
ENDIF
IF EMPTY(JUSTPATH(lcINI))
lcINI = pcSysHome + lcINI
ENDIF
IF !FILE(lcINI)
RETURN []
ELSE
lcINI = FILETOSTR(lcIni)
ENDIF
ENDIF
IF !EMPTY(lcSection)
lcINI = STREXTRACT(lcINI,'['+lcSection+']','',1,1)
ENDIF
IF !VARTYPE(lcCloser)=[C]
lcCloser = CHR(13)
ENDIF
i = 1
lcResult = STREXTRACT(lcINI,lcTag+[=],lcCloser,i,3)
IF !EMPTY(lcResult)
DO WHILE ! llDone && Make sure entry was not commented out
llDone = (ATC([;]+lcTag+[=]+lcResult,lcINI)=0) OR i > 99
IF !llDone
i = i + 1
lcResult = STREXTRACT(lcINI,lcTag+[=],lcCloser,i,3)
ENDIF
ENDDO
ENDIFENDFUNC
Here's the routine that handles the return call from PayPal. Note that we have to make two more calls back to the PP server in order to get the details and finalize the payment...
lcServerURL = GETWORDNUM(lcPccpath,1,[,])
loHTTP = This.PayPalCaller([GetExpressCheckoutDetails])
lcToken = Request.Params([Token])
loHTTP.AddPostKey([TOKEN],lcToken)
lcPostBuffer = loHTTP.cPostBuffer
This.trace('PYSRVDETAILS',[GetExpressCheckoutDetails at ]+lcServerURL+[ Buffer=]+lcPostBuffer) &&STRTRAN(STRTRAN(lcPostBuffer,lcPwd,[#########]),lcSignature,[#########]))
lcData = loHTTP.HttpGet(lcServerURL)
This.trace('PYSRVDETAILS',[Result: ]+lcData)
loHTTP = NULL
lcStatus = UPPER(NVPParse(lcData,[ACK]))
IF lcStatus = [SUCCESS]
lcPayerID = NVPParse(lcData,[PayerID])
loHTTP = This.PayPalCaller([DoExpressCheckoutPayment])
loHTTP.AddPostKey([TOKEN],lcToken)
loHTTP.AddPostKey([PAYERID],lcPayerID)
lcAmount = Desanitize(NVPParse(lcData,[Amt]),[%2E])
loHTTP.AddPostkey([PAYMENTREQUEST_0_AMT],lcAmount)
loHTTP.AddPostkey([PAYMENTREQUEST_0_PAYMENTACTION],[Sale])
loHTTP.AddPostkey([PAYMENTREQUEST_0_CURRENCYCODE],[USD])
lcBNCode = iniParse([AWSYS],[BNCode], ,.T.)
loHTTP.AddPostkey([BUTTONSOURCE],lcBNCode)
lcPostBuffer = loHTTP.cPostBuffer
This.trace('PYSRVDETAILS',[DoExpressCheckoutPayment at ]+lcServerURL+[ Buffer=]+lcPostBuffer) &&STRTRAN(STRTRAN(lcPostBuffer,lcPwd,[#########]),lcSignature,[#########]))
lcResult = loHTTP.HttpGet(lcServerURL)
This.trace('PYSRVDETAILS',[Result: ]+lcResult)
lcStatus = UPPER(NVPParse(lcResult,[ACK]))
lcMsg = Desanitize(NVPParse(lcResult,[L_LONGMESSAGE0]),,.T.)
IF lcStatus = [SUCCESS]
lcTransid = NVPParse(lcResult,[PAYMENTINFO_0_TRANSACTIONID])
lcAuthnum = NVPParse(lcResult,[CORRELATIONID])
lnAmount = VAL(lcAmount)
lcPayType = EVL(STREXTRACT(lcPCCPath,[PayType:],[:],1,1),lcDefaultPayType)
ENDIF
loHTTP = NULL
ELSE
ERROR [Failed to get checkout details from PayPal server]
ENDIF
HTH.
--stein
Looking at the docs on those systems you suggest, I'm not really seeing them as any easier. Also, I'm not sure what you mean when you say they are "server driven."
As for PayPal, it wants an "empty" HTTP 200 post to start off the confirmation process, but I don't know how to do that in WWWC and the pages in the help file I've looked at so far don't seem to be leading me to the solution. Can you offer some help on that?
Rod,
Express checkout relies on an order flow that requires that your application make a number of HTTP calls to PayPals servers.
This link has the details:
https://developer.paypal.com/docs/classic/express-checkout/ht_ec-singleItemPayment-curl-etc/
You can use wwHttp to make these HTTP calls and you'll need to implement the Cancel and Success endpoints as Web Connection handlers to receive the results from PayPal.
This isn't really very different from the way the old classic PayPal process worked - but it is uses different attribute names and the flow is slightly different with one more intermediate step to review the order on your site (which IMHO makes this process even more annoying), so it is different.
FWIW, I would recommend looking into standard Credit Card checkout solutions like BrainTree, Stripe or MerchantPlus's flat rate checkout solutions. These tend to be really easy to get setup with (no merchant bank approval process etc.), but more importantly they are server driven so you don't have to deal with the funky PayPal flow through the PayPal site.
Not saying that PayPal can't work, but I tend to think of PayPal as an 'add-on' solution rather than a primary pay platform.
+++ Rick ---
Hi All,
I'm looking at PayPal to add a simple payment mechanism to my web site.
I only have one fixed product to sell, so I don't think I need to create an order form other than a page to put the button on.
PayPal's Express Checkout setup looks like it gives you the HTML to add the button on your page.
All I need to do now is get back an immediate authorization.
I'm just using Rick's base classes. Are there any examples of a simple approach for this?
Thanks,
Rod