[nycphp-talk] E-Commerce Shopping Carts
PaulCheung
paulcheung at tiscali.co.uk
Tue Oct 7 11:25:42 EDT 2008
Hi Michele
Thanks for your help, it was and still is very much appreciated. Just to let
you know I am using a UK providor named PROTX and they have thing called
VSPxxxxx-KIT which follows a lot of what you discribe plus lots of PHPcoded
examples of all the bits and bobs needed for the shopping cart. So once
again thank you for your help.
Paul
----- Original Message -----
From: "(Margaret) Michele Waldman" <mmwaldman at optonline.net>
To: "'NYPHP Talk'" <talk at lists.nyphp.org>
Sent: Tuesday, September 30, 2008 12:23 PM
Subject: RE: [nycphp-talk] E-Commerce Shopping Carts
> Paul,
>
> Are you writing a shopping cart from scatch.
>
> I don't think this is the easiest way to implement a shopping cart.
>
> There are two open source shopping carts that I know about, oscommerce and
> zencart. Plus, there are many inexpensive shopping carts.
>
> Zencart handles the payment notifications. If you use a non supported or
> merchant that doesn't have a plugin available, you have to write some of
> the
> gateway yourself, but all of the email notifications come canned.
>
> As far as the payment gateway. If I'm correct, via curl or whatever you
> sent connect to the merchant and request a payment, they return a success
> or
> non success value, after which you can send an email.
>
> You get the response right away, so I don't know why you want to poll.
>
> Here's so snippets of code:
>
> $QBMS_XML_Credit_Card_Charge = '<?xml version="1.0"?>
> <?qbmsxml version="2.0"?>
>
> <QBMSXML>
>
> <SignonMsgsRq>'.$QBMS_Auth.'
>
> </SignonMsgsRq>
>
> <QBMSXMLMsgsRq>
>
> <CustomerCreditCardChargeRq>
>
> <TransRequestID>'.$QBMS_TransRequestID.'</TransRequestID>
>
> <CreditCardNumber>'.$_POST['CreditCardNumber'].'</CreditCardNumber>
>
> <ExpirationMonth>'.$_POST['ExpirationMonth'].'</ExpirationMonth>
>
> <ExpirationYear>'.$_POST['ExpirationYear'].'</ExpirationYear>
>
> <IsECommerce>true</IsECommerce>
>
> <Amount>'.$_POST['Amount'].'</Amount>
>
> <NameOnCard>'.$_POST['CreditCardOwner'].'</NameOnCard>
>
> <CreditCardAddress>'.$_POST['CreditCardAddress'].'</CreditCardAddress>
>
> <CreditCardPostalCode>'.$_POST['CreditCardPostalCode'].'</CreditCardPostalCo
> de>
>
> <CardSecurityCode>'.$_POST['CardSecurityCode'].'</CardSecurityCode>
>
> </CustomerCreditCardChargeRq>
>
> </QBMSXMLMsgsRq>
>
> </QBMSXML>';
> $QBMS_chargeRq = $this->qbms_call($QBMS_ApplicationPath,
> $QBMS_XML_Credit_Card_Charge, MODULE_PAYMENT_QBMS_SSL_CERT);
>
> // Get the statusCode
> $QBMS_ChargeRq_Status = 1;
> $posLeft = strpos($QBMS_chargeRq, "<CustomerCreditCardChargeRs
> statusCode=\"")+strlen("<CustomerCreditCardChargeRs statusCode=\"");
> $posRight = strpos($QBMS_chargeRq, "\"", $posLeft+1);
> $QBMS_ChargeRq_Status = intval(substr($QBMS_chargeRq, $posLeft,
> $posRight-$posLeft));
>
> // QBMS will return statusCode="0" or "10100" if charge was
> successful
> switch ($QBMS_ChargeRq_Status)
> {
> case 0:
> case 10100:
> $this->qbms_charge_success($QBMS_chargeRq);
> return;
> case 10301:
> case 10400:
> case 10401:
> case 10402:
> case 10404:
> case 10407:
> case 10409:
> $error = MODULE_PAYMENT_QBMS_TEXT_DECLINED;
> break;
> default:
> $error = MODULE_PAYMENT_QBMS_TEXT_SYSTEM_ERROR . " " .
> $QBMS_ChargeRq_Status . " <!--" . $QBMS_chargeRq . "-->";
> break;
> }
> $payment_error_return = 'payment_error=' . $this->code . '&error=' .
> urlencode($error) . '&qbms_cc_owner=' .
> urlencode($_POST['CreditCardOwner'])
> . '&qbms_cc_expires_month=' . $_POST['ExpirationMonth'] .
> '&qbms_cc_expires_year=' . $_POST['ExpirationYear'];
> zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT,
> $payment_error_return, 'SSL', true, false));
> }
>
>
> function qbms_call($qbmsURL, $qbmsRequest, $qbmsCert) {
> global $_POST;
> $PHP_Header[] = "Content-type: application/x-qbmsxml";
> $PHP_Header[] = "Content-length: ".strlen($qbmsRequest);
>
> $clientURL = curl_init();
>
> curl_setopt($clientURL, CURLOPT_POST, 1);
> curl_setopt($clientURL, CURLOPT_RETURNTRANSFER, 1);
> curl_setopt($clientURL, CURLOPT_CUSTOMREQUEST, 'POST');
> curl_setopt($clientURL, CURLOPT_URL, $qbmsURL);
> // curl_setopt($clientURL, CURLOPT_TIMEOUT, 60);
> curl_setopt($clientURL, CURLOPT_HTTPHEADER, $PHP_Header);
> curl_setopt($clientURL, CURLOPT_POSTFIELDS, $qbmsRequest);
> curl_setopt($clientURL, CURLOPT_VERBOSE, 1);
> curl_setopt($clientURL, CURLOPT_SSL_VERIFYPEER, 1);
> // if (MODULE_PAYMENT_QBMS_HOSTEDORDESKTOP == 'Hosted') {
> // curl_setopt($clientURL, CURLOPT_SSLCERT, $qbmsCert);
> // }
> curl_setopt($clientURL, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
> //??
> curl_setopt ($clientURL, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
> curl_setopt ($clientURL,
> CURLOPT_PROXY,"http://proxy.shr.secureserver.net:3128");
> // if (MODULE_PAYMENT_QBMS_IP_ADDRESS != '') {
> // curl_setopt($clientURL, CURLOPT_INTERFACE,
> MODULE_PAYMENT_QBMS_IP_ADDRESS);
> // }
>
> $qbmsResponse = curl_exec($clientURL);
>
> if ((curl_errno($clientURL)) || ($qbmsResponse == 1)) {
>
> $curlerrno = curl_errno($clientURL);
> $error = MODULE_PAYMENT_QBMS_TEXT_SYSTEM_ERROR;
> $payment_error_return = 'payment_error=' . $this->code . '&error=' .
> urlencode($error) . '&qbms_cc_owner=' .
> urlencode($_POST['CreditCardOwner'])
> . '&qbms_cc_expires_month=' . $_POST['ExpirationMonth'] .
> '&qbms_cc_expires_year=' . $_POST['ExpirationYear'];
> zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT,
> $payment_error_return, 'SSL', true, false));
> } else {
> curl_close($clientURL);
> }
>
> return $qbmsResponse;
> }
>
> Michele
>
> -----Original Message-----
> From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
> On
> Behalf Of PaulCheung
> Sent: Tuesday, September 30, 2008 4:49 AM
> To: NYPHP Talk
> Subject: [nycphp-talk] E-Commerce Shopping Carts
>
> Hi,
>
> Can anybody help?? I have run into a major problem, I do not understand
> how
> shopping carts work. I have tried asking technical support of the likes of
> PayPal, while they are all very knowledgeable businesswise, they are not
> PHP
>
> developers. I was told that I should check my email periodically.
>
> As a shopping cart newbie using PHP, I am lost. I understand it is develop
> myself or much the easiest and best way is to use a shopping cart, which I
> agree with.
>
>>From a merchant's point of view, here is what I want. Once payment has
>>been
>
> made and confirmed, I want a token confirming payment (payment info) to be
> sent to my site and then, without manual intervention, I want to dispatch
> a
> confirmation email to the customer an invoice and then the goods/services
> to
>
> the customer.
>
> Is there a way of automatically polling for this info?? Is there a better
> of doing things??
>
> Cheers
>
> Paul
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
More information about the talk
mailing list