shopping cart or paypal software ?
lazarus / 38-Networking and Web Programming
----------------------------------------------------------------------
jack616 · 2017-08-30 13:00
Has anyone written either a shopping cart or paypal code with lazarus?
----------------------------------------------------------------------
Leledumbo · 2017-08-30 18:25
Here's an excerpt but working, standalone fpweb program that make a
payment request via paypal after filling a (static size) cart:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i {$mode
objfpc}{$H+} uses
classes,fphttpapp,httpdefs,httpprotocol,httproute; procedure
Index(ARequest : TRequest; AResponse : TResponse);var i: Integer; s:
String;begin with AResponse.Contents do begin Add('');
Add('
'); Add(' Paypal Test Page');
Add(' '); Add(' '); Add(' Paypal Test
Page
'); Add(' '); Add(' ');
Add(''); endend; procedure Pay(ARequest : TRequest; AResponse
: TResponse); function StringListToQueryString(sl: TStrings):
String; var i: Integer; OldDelimiter : Char;
OldStrictDelimiter: Boolean; begin for i := 0 to sl.Count - 1 do
sl.ValueFromIndex[i] := HTTPEncode(sl.ValueFromIndex[i]);
OldDelimiter := sl.Delimiter; OldStrictDelimiter :=
sl.StrictDelimiter; sl.Delimiter := '&';
sl.StrictDelimiter := true; Result :=
sl.DelimitedText; sl.Delimiter := OldDelimiter;
sl.StrictDelimiter := OldStrictDelimiter; end; var PaypalParams:
String;begin with ARequest.ContentFields do begin
Values['business'] := 'put.your@email.here';
Values['cmd'] := '_cart'; Values['upload']
:= '1'; Values['currency_code'] := 'USD';
Values['charset'] := 'utf-8'; Values['custom']
:= 'any custom data you wish to be sent back from notification,
optional of course'; Values['notify_url'] :=
'http://where.paypal.should/fire/back/for/notifying/you';
Values['return'] :=
'http://where.paypal.should/redirect/user/after/payment';
Values['shipping_1'] := 'the chosen shipping method';
Values['discount_amount_cart'] := '0'; Values['tax_cart']
:= '0'; Values['first_name'] := 'receiver first name';
Values['last_name'] := 'receiver last name';
Values['address1'] := 'address line 1';
Values['address2'] := 'address line 2'; Values['zip']
:= '12345'; Values['city'] :=
'Depok'; Values['state'] := 'West Java';
Values['country'] := 'Indonesia';
Values['night_phone_b'] := '021-112911388'; Values['email']
:= 'receiver@email.address'; end; PaypalParams
:= StringListToQueryString(ARequest.ContentFields); AResponse.Code
:= 301; AResponse.CodeText := 'Redirect'; AResponse.Location :=
'https://www.paypal.com/cgi-bin/webscr?' + PaypalParams;end; begin
HTTPRouter.RegisterRoute('/',rmAll,@Index);
HTTPRouter.RegisterRoute('/pay',rmAll,@Pay); Application.Port :=
9999; Application.Initialize; Application.Run;end. Note that I use
the new routing system introduced in FPC trunk, please rewrite in
webmodule system if you're using latest stable (3.0.2).
----------------------------------------------------------------------
jack616 · 2017-10-02 12:53
Thanks lele but I was really looking for a complete solution I could
buy or use.
----------------------------------------------------------------------
avra · 2017-10-02 16:12
Quote from: jack616 on October 02, 2017, 02:53:11 pmI was really
looking for a complete solution I could buy or use.Although I see only
Delphi versions, nSoftware mentions "Support for Lazarus IDE and Free
Pascal" so you might investigate a little. Probably Delphi version
works in Lazarus, but you need to check it out. Anyway, ActiveX
version could also be considered with a little work.
https://www.componentsource.com/product/paypal-integrator-
delphi/compatibilities
https://www.nsoftware.com/platforms/delphi/
https://www.nsoftware.com/ibiz/paypal/download.aspx
TMS Software supports PayPal in their VCL Cloud pack, but not yet in
LCL Cloud Pack which you could use directly from Lazarus. Maybe you
can contact them and show interest in having PayPal in LCL version
too.
http://www.tmssoftware.com/site/cloudpack.asp
http://www.tmssoftware.com/site/tmslclcloudpack.asp
----------------------------------------------------------------------
avra · 2017-10-02 17:26
All right, I looked a little more into PayPal and found that it
supports SOAP and provides WSDL:
https://developer.paypal.com/docs/classic/api/PayPalSOAPAPIArchitectur
e/
We should be able to import that into Lazarus with WST. Unfortunately
WST runs out of memory even on 64-bit Lazarus and 16GB RAM, so I will
report a bug to WST author. Therefore I used Delphi to import WSDL and
generate web service access classes. Unfortunately it is not usable
from Lazarus. I have attached it anyway, maybe someone will find them
useful.
PayPal also provides REST API which could be also used:
https://developer.paypal.com/docs/api/
----------------------------------------------------------------------
jack616 · 2017-10-04 10:57
Thanks for all your work Avra
I'm trying to get a few things done quickly (hence my editor thread)
so I need solutions now
not problems to be fixed - but I'll certainly keep an eye on this for
the future. If I can transfer
stuff out of PHP etc. into lazarus/FPC I'd be a happy bunny though.
----------------------------------------------------------------------
avra · 2017-10-04 22:43
Quote from: jack616 on October 04, 2017, 12:57:18 pmI'm trying to get
a few things done quickly (hence my editor thread) so I need solutions
now
not problems to be fixedThen your best bet would be already mentioned
nSoftware with it's PayPal Integrator or full E-Commerce solutions for
Delphi and Lazarus.
----------------------------------------------------------------------
Graeme · 2017-10-12 15:38
Quote from: jack616 on August 30, 2017, 03:00:55 pmHas anyone written
either a shopping cart or paypal code with lazarus?
I had to implement a shopping cart with multiple types of discounts
(eg: straight % off, buy three for the price of two, buy one get one
free etc.) for a Java contracting job recently - it was part of the
technical test. It wasn't very hard to do. So go for it!! ;-)
----------------------------------------------------------------------
Trenatos · 2017-10-18 19:24
PayPal integration is pretty easy, if you can do the rest of the web
development with FPC the PayPal part shouldn't be a problem.