From: gavino
Subject: Can i take credit card payments securely using lisp website?
Date: 
Message-ID: <1163705741.268813.40760@k70g2000cwa.googlegroups.com>
If so how?

From: Vagif Verdi
Subject: Re: Can i take credit card payments securely using lisp website?
Date: 
Message-ID: <1163717756.448979.80070@h54g2000cwb.googlegroups.com>
gavino wrote:
> If so how?

You cannot.
When all langauges were created, it was decided upfront what tasks can
be programmed with each particular language.
Enterprise languages got all the business and commercial stuff. So
languages like java and csharp took credit card payments. But there was
no commercial lisp  representative on that big meeting. Only bunch of
eggheads from universities who did not give a shit about such things as
credit card payments.
So thanks to them, you cannot use lisp for this particular task, as
well as many other very usefull business tasks.
I think this is the time when you give up on lisp.
From: gavino
Subject: Re: Can i take credit card payments securely using lisp website?
Date: 
Message-ID: <1163803145.870082.185230@f16g2000cwb.googlegroups.com>
On Nov 16, 2:55 pm, "Vagif Verdi" <···········@gmail.com> wrote:
> gavino wrote:
> > If so how?You cannot.
> When all langauges were created, it was decided upfront what tasks can
> be programmed with each particular language.
> Enterprise languages got all the business and commercial stuff. So
> languages like java and csharp took credit card payments. But there was
> no commercial lisp  representative on that big meeting. Only bunch of
> eggheads from universities who did not give a shit about such things as
> credit card payments.
> So thanks to them, you cannot use lisp for this particular task, as
> well as many other very usefull business tasks.
> I think this is the time when you give up on lisp.

vote republican
From: Drew Crampsie
Subject: Re: Can i take credit card payments securely using lisp website?
Date: 
Message-ID: <1163742460.036728.241480@j44g2000cwa.googlegroups.com>
On Nov 16, 11:35 am, "gavino" <········@yahoo.com> wrote:
> If so how?

Like this :

(cl:defpackage :cl-charge
  (:use :common-lisp
	:trivial-https
	:it.bese.arnesi
	:cl-ppcre)
  (:import-from :split-sequence
		:split-sequence))

(cl:in-package :cl-charge)

(defclass merchant () ())

(defclass http-merchant-mixin ()
  ((url :accessor url :initform
"https://www3.moneris.com/HPPDP/index.php")))

(defclass payment-method () ())

(defclass credit-card (payment-method)
  ((card-number :accessor card-number :initarg :card-number)
   (expiry-month :accessor expiry-month :initarg :expiry-month)
   (expiry-year :accessor expiry-year :initarg :expiry-year)))

(defparameter *test-mastercard*
  (make-instance 'credit-card
		 :card-number 4242424242424242
		 :expiry-month 12
		 :expiry-year 10))

(defclass transaction ()
  ((items :accessor items :initarg :items :initform nil
	  :documentation
	  "list of transaction items ")))

(defclass transaction-item ()
  ((total-charge :accessor total-charge :initform 0 :initarg
:total-charge)))

(defmethod total-charge ((transaction transaction))
  (reduce #'+ (mapcar #'total-charge (items transaction))))

(defparameter *test-transaction*
  (make-instance
   'transaction
   :items (list (make-instance 'transaction-item
			       :total-charge 50.00))))

(defgeneric make-request (merchant payment-method transaction))

;;;; * Moneris Implementation
;;;; Based on the Moneris DirectPost implementation guide
;;;; Section 7 Sending a Transaction to the DirectPost solution

(defclass moneris (merchant http-merchant-mixin)
  ((store-id :accessor store-id :initform "xxxxxxx")
   (key :accessor key :initform "xxxxxx")))

(defparameter *moneris* (make-instance 'moneris))

(defun list->http-get-parameters (list &key (prefix "?"))
  (when list
    (with-output-to-string (s)
      (when prefix
	(write-string prefix s)
	(loop for (key val &rest  rest) on list
	      by #'cddr
	      if val
	      do (format s "~A=~A~:[~;&~]"
			 (escape-as-uri (strcat key))
			 (escape-as-uri (strcat val))
			 rest))))))

(defmethod make-http-get-url (merchant &rest parameters)
  (with-output-to-string (s)
    (write-string (url merchant) s)
    (write-string (list->http-get-parameters
	   `("ps_store_id" ,(store-id merchant)
	     "hpp_key" ,(key merchant))) s)
    (when parameters
      (write-string (list->http-get-parameters parameters :prefix "&")
s))))

(defun parse-moneris-response (response-text)
  (mapcar #'(lambda (line)
	      (setf line (mapcar #'trim-string (split-sequence #\= line)))
	      (cons (intern (string-upcase (first line))
			    (find-package :cl-charge)) (second line)))
	  (split "<br>" response-text)))

(defmethod make-request ((merchant moneris) (card credit-card)
transaction)
  (apply #'make-http-get-url merchant `("charge_total" ,(format nil
"~$" (total-charge transaction))
					"cc_num" ,(card-number card)
					"expMonth" ,(expiry-month card)
					"expYear" ,(expiry-year card))))
(defmethod perform-request (request)
  (let* ((response (trivial-https:HTTP-GET request))
	 (http-code (car response))
	 (stream (caddr
		   response))
	 (response-text
	  (with-output-to-string (s)
	    (loop for line = (read-line stream nil)
		  while line do (write-string line s)))))
    (when (eql 200 http-code)
	(parse-moneris-response response-text))))

(defmethod charge-transaction ((merchant moneris) payment-method
transaction)
  (let* ((results (perform-request (make-request merchant
payment-method transaction)))
	 (response-code (cdr (assoc 'response_code results :test #'equal)))
	 (response-number (and response-code
			       (parse-integer response-code :junk-allowed t))))

    (if (and response-code response-number
	     (> 50 response-number))
	(values t results)
	(values nil results))))

(defvar *fields*
  '(("charge_total" :required t)
    ("cc_num" :required t)
    ("expMonth" :required t)
    ("expYear" :requried t)))

  
Now will you kindly piss off.

Cheers, 

drewc
From: Lars Rune Nøstdal
Subject: Re: Can i take credit card payments securely using lisp website?
Date: 
Message-ID: <pan.2006.11.16.21.08.56.367596@gmail.com>
On Thu, 16 Nov 2006 11:35:41 -0800, gavino wrote:

> If so how?

Depends, but in general you can just use standard web-stuff:
  http://www.paymentonline.com/ecommerce-software/payment-gateway.html#gateway

(first thing I found on google)

-- 
Lars Rune Nøstdal
http://lars.nostdal.org/
From: Alex Mizrahi
Subject: Re: Can i take credit card payments securely using lisp website?
Date: 
Message-ID: <455cc709$0$49208$14726298@news.sunsite.dk>
(message (Hello 'gavino)
(you :wrote  :on '(16 Nov 2006 11:35:41 -0800))
(

 g> If so how?

just like with any other language, it's kinda irrelevant. either use SSL at 
Apache side, or use some SSL lib.

)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"People who lust for the Feel of keys on their fingertips (c) Inity") 
From: Dmitry V. Gorbatovsky
Subject: Re: Can i take credit card payments securely using lisp website?
Date: 
Message-ID: <ejim78$36e$1@aioe.server.aioe.org>
gavino wrote:

> If so how?
Why don't you easy your voice.
Nobody owe you here :).

Cheers, Dmitry
From: gavino
Subject: Re: Can i take credit card payments securely using lisp website?
Date: 
Message-ID: <1163803241.352091.233700@h48g2000cwc.googlegroups.com>
On Nov 16, 1:46 pm, "Dmitry V. Gorbatovsky" <·········@midasitech.com>
wrote:
> gavino wrote:
> > If so how?Why don't you easy your voice.
> Nobody owe you here :).
> 
> Cheers, Dmitry

owe?
voice? ? ...