Forum OpenACS Development: Has anyone written a Paypal gateway?

Request notifications

Collapse
Posted by Janine Ohmer on
And if not, why not? I've done some searching and have seen several people mentioning they were thinking of working on one, and a bunch of people looking for one, but no-one actually announcing anything. Is it really hard to get it working or something? Any insight would be very much appreciated before I dig myself a really deep hole. ;)
Collapse
Posted by Frank Bergmann on
Hi Janine,

we've been thinking about it, but have not started any work on it yet.

I guess a fully automatic integration is going to be difficult because of security etc. We actually thought of reading in a PayPal CSV or something similar.

Bests,
Frank

Collapse
Posted by Torben Brosten on
AFAICT, more features need to be added to the ecommerce package before a paypal gateway would meet the requirements of the business rules on page 17 of the Paypal Integration Guide[1]. Some of the requirements have been added to the bugtracker as suggestions/"to do"s (for other reasons).

Alternatively, one could add a parameter to ecommerce, that when set, passes the shopping-cart data to paypal for processing[2]. You would need to create a thank-you page to go with it. This is the quickest implementation method, but has many drawbacks.

1. https://www.paypal.com/en_US/pdf/PP_WebsitePaymentsPro_IntegrationGuide.pdf

2. http://www.paypal.com/cgi-bin/webscr?cmd=_pdn_howto_checkout_outside

Collapse
Posted by Andrew Grumet on
I haven't attempted any beautiful abstractions but here is some nuts and bolts code for anyone who's interested:
    set success_p 0
    set tx [ns_queryget tx]
    if { [string equal $tx ""] } {
        #No paypal data!  Take appropriate action, probably
        #return or error.
    }

    set token "(your token)"

    #Retrieve transaction data from paypal.
    set qsset [ns_set new qsset]
    ns_set put $qsset tx "$tx"
    ns_set put $qsset at $token
    ns_set put $qsset cmd "_notify-synch"
    set results [ns_httpspost https://www.paypal.com/cgi-bin/webscr "" $qsset]
    ns_set free $qsset

    set vars [list txn_id mc_currency payment_gross first_name last_name payer_email custom]

    #Extract transaction data.
    foreach line [split $results \n] {
        if { [string equal $line SUCCESS] } {
            set success_p 1
        }
        set info [split $line \=]
        if { [llength $info] == 2 && [lsearch $vars [lindex $info 0]] >= 0 } {
            set [lindex $info 0] [lindex $info 1]
        }
        if { [string equal [lindex $info 0] payer_email] } {
            set payer_email [ns_urldecode $payer_email]
        }
    }

    #Validate transaction data and pack local data structure, a list suitable for use with array get.
    set txn_vars [list]
    foreach var $vars {
        if { ![info exists $var] } {
            set success_p 0
        } else {
            lappend txn_vars $var [set $var]
            if { [string equal $var custom] } {
                #take whatever special actions needed for
                #your custom var (e.g. database key)
            }
        }
    }

    return [list $success_p $txn_vars]

Collapse
Posted by Monica Jenner on
I am using paypal for my online store, it is working fine, but some of my customers says that paypal does not work in some regions, well i bought the payment gateway from here, you can also check your business.

https://payment-gateways.net/

Collapse
Posted by Gustaf Neumann on
you are picking up here a very old thread. Do you have an OpenACS integration, or is you posting not related with OpenACS?