.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Vend::Payment::PaypalExpress 3pm" .TH Vend::Payment::PaypalExpress 3pm "2016-08-31" "perl v5.22.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Vend::Payment::PaypalExpress \- Interchange Paypal Express Payments Module .SH "PREREQUISITES" .IX Header "PREREQUISITES" .Vb 7 \& SOAP::Lite \& XML::Parser \& MIME::Base64 \& URI \& libwww\-perl \& Crypt::SSLeay \& IO::Socket::SSL (version 0.97 until 0.99x is fixed for the "illegal seek" error, or a later one that works) .Ve .PP Test for current installations with: perl \-MSOAP::Lite \-e 'print \*(L"It works\en\*(R"' .SH "DESCRIPTION" .IX Header "DESCRIPTION" The Vend::Payment::PaypalExpress module implements the \fIpaypalexpress()\fR routine for use with Interchange. .PP #========================= .SH "SYNOPSIS" .IX Header "SYNOPSIS" Quick start: .PP Place this module in /lib/Vend/Payment, and call it in /interchange.cfg with Require module Vend::Payment::PaypalExpress. Ensure that your perl installation contains the modules listed above and their pre-requisites. .PP Logon to your Paypal Business (not Personal) account and go to 'Profile' \-> '\s-1API\s0 access' \-> \&'Request \s-1API\s0 Credentials' \-> 'Signature'. This will generate a user id, password and signature. .PP Add to catalog.cfg all marked 'required', optionally the others: Route paypalexpress id xxx (required_ Route paypalexpress password xxx (required) Route paypalexpress signature xxx (required: use the 3\-token system, not the certificate system at Paypal) Route paypalexpress returnurl your_full_URL/paypalgetrequest (required) Route paypalexpress cancelurl your_full_URL/your_cancellation_page (required) Route paypalexpress host api\-3t.sandbox.paypal.com (for testing) Route paypalexpress host api\-3t.paypal.com (required: live host, one of this or the above but not both) Route paypalexpress currency EUR|GBP|USD|CAD|AUD (optional, defaults to \s-1USD\s0) Route paypalexpress pagestyle (optional, set up at Paypal) Route paypalexpress paymentaction Sale (optional, defaults to 'Sale') Route paypalexpress headerimg 'secure \s-1URL\s0' (optional, though must be served from a secure \s-1URL\s0 if used) .PP Optionally, you may set the return \s-1URL\s0 in the page as , and similarly the cancelurl may be set in the page. .PP To have Paypal co-operate with your normal payment service provider, eg Authorizenet, do the following: .PP Leave the \s-1MV_PAYMENT_MODE\s0 variable in catalog.cfg and products/variable.txt set to your normal payment processor. .PP Add to etc/profiles.order: _\|_NAME_\|_ paypalexpress _\|_COMMON_ORDER_PROFILE_\|_ &fatal = yes email=required email=email &set=mv_payment PaypalExpress &set=psp Paypal &set=mv_payment_route paypalexpress &final = yes &setcheck = payment_method paypalexpress _\|_END_\|_ or, if you want to use Paypal as a 'Buy now' button without taking any customer details, then omit the _\|_COMMON_ORDER_PROFILE_\|_ and the two 'email=...' lines above. .PP Within the 'credit_card' section of etc/profiles.order leave \*(L"\s-1MV_PAYMENT_MODE\*(R"\s0 as set, and add &set=psp _\|_MV_PAYMENT_PSP_\|_ &set=mv_payment_route authorizenet (or your preferred gateway instead of authorizenet) as the last entries in the section. .PP and then add Variable \s-1MV_PAYMENT_PSP \s0\*(L"foo\*(R" to catalog.cfg, where \*(L"foo\*(R" is the name of your gateway or acquirer, formatted as you want it to appear on the receipt. Eg, \*(L"Bank of America\*(R" (rather than boa), \*(L"AuthorizeNet\*(R" (rather than authorizenet). .PP In etc/log_transction, immediately after the [elsif variable \s-1MV_PAYMENT_MODE\s0] [calc] insert this line: undef \f(CW$Session\fR\->{payment_result}{MStatus}; .PP and leave [elsif variable \s-1MV_PAYMENT_MODE\s0] as set (contrary to previous revisions of this document) but within the same section change the following two instances of [var \s-1MV_PAYMENT_MODE\s0] to [value mv_payment_route]. In particular, the setting inside the [charge route=\*(L"..] line will specify which payment processor is used for each particular case, and you need to further modify this line so that it ends up like this: [tmp name=\*(R"charge_succeed\*(L"][charge route=\*(R"[value mv_payment_route]\*(L" pprequest=\*(R"dorequest\*(L" amount=\*(R"[scratch tmp_remaining]\*(L" order_id=\*(R"[value mv_transaction_id]"][/tmp] If the value of 'mv_payment_route' is set to 'paypalexpress', then this is the one that is run. It is only called via log_transaction after the customer has returned from Paypal and clicks the 'final' pay button, hence this is where the final 'pprequest=dorequest' value is sent. .PP Add into the end of the \*(L"[import table=transactions type=LINE continue=NOTES no\-commit=1]\*(R" section of etc/log_transaction: .PP psp: [value psp] pptransactionid: [calc]$Session\->{payment_result}{TransactionID}[/calc] pprefundtransactionid: [calc]$Session\->{payment_result}{RefundTransactionID}[/calc] ppcorrelationid: [calc]$Session\->{payment_result}{CorrelationID};[/calc] pppayerstatus: [value payerstatus] ppaddressstatus: [value address_status] .PP and add these 6 new columns into your transactions table as type varchar(256). You will have records of which transactions went through which payment service providers, as well as Paypal's returned IDs. The CorrelationID is the one you need in any dispute with them. The payerstatus and addressstatus results may be useful in the order fulfillment process. .PP Add these lines into the body of the 'submit' button that sends the customer to Paypal. [run\-profile name=paypalexpress] [if type=explicit compare=\*(L"[error all=1 show_var=1 keep=1]\*(R"] mv_nextpage=ord/checkout [/if] [charge route=\*(L"paypalexpress\*(R" pprequest=\*(L"setrequest\*(R"] mv_todo=return .PP Create a page 'ord/paypalgetrequest.html', and make it the target of the returnURL from Paypal: [charge route=\*(L"paypalexpress\*(R" pprequest=\*(L"getrequest\*(R"] [bounce href=\*(L"[area ord/paypalcheckout]\*(R"] .PP Create a page 'paypalcheckout.html' in the pages/ord folder. This should display just the basket and address or whatever you choose for the final pages, plus an \s-1IC\s0 button with: mv_order_profile=paypalexpress mv_todo=submit in the body part as the submit button to finalise the order. 'dorequest' is set in log_transaction. .PP You may then use PaypalExpress for any transaction where the 'mv_order_profile' is set to paypalexpress but still use the \*(L"credit_card\*(R" 'mv_order_profile' for other transactions, eg for Authorizenet. Of course, if PaypalExpress is to be your only payment method, then simply add: Variable \s-1MV_PAYMENT_MODE\s0 paypalexpress to catalog.cfg just before the paypalexpress Route entries, and this route will be the default. .PP Note that because Paypal do not recognise \s-1UK\s0 as a country, only \s-1GB,\s0 you need to set up shipping in your country.txt for \s-1GB\s0 as well as \s-1UK.\s0 Note also that Paypal do not return the customer's telephone number by default, so you may need to adjust your order profiles to compensate. .PP Also note that Paypal requires the user to have cookies enabled, and if they're not will return an error page with no indication of the real problem. You may want to warn users of this. .PP The flow is: the first button for Paypal sends a request to Paypal to initialise the transaction and gets a token back in return. If Paypal fails to send back a token, then the module refreshes that page with an error message suggesting that the customer should use your normal payment service provider and shows the cards that you accept. Once the token is read, then your customer is taken to Paypal to login and choose his payment method. Once that is done, he returns to us and hits the 'paypalgetrequest' page. This gets his full address as held by Paypal, bounces to the final 'paypalcheckout' page and populates the form with his address details. If you have both shipping and billing forms on that page, the shipping address will be populated by default but you may force the billing form to be populated instead by sending at the initial stage. Then the customer clicks the final 'pay now' button and the transaction is done. .PP Options that may be set either in the route or in the page: * reqconfirmshipping \- this specifies that a Paypal customer must have his address 'confirmed' * addressoverride \- this specifies that you will ship only to the address \s-1IC\s0 has on file (including the name and email); your customer needs to login to \s-1IC\s0 first before going to Paypal * use_billing_override \- sends billing address instead of shipping to PayPal (use with addressoverride) * other options are also settable. .PP Testing: while the obvious test choice is to use their sandbox, I've always found it a bit of a dog's breakfast and never trusted it. Much better to test on the live site, and just recyle money between your personal and business accounts at minimal cost to yourself, but with the confidence of knowing that test results are correct. .SH "Changelog" .IX Header "Changelog" version 1.0.7 December 2009 \- another variation in Canadian Province names has just come to light, whereby they sometimes send the 2 letter code with periods, eg B.C. as well as \s-1BC.\s0 Thanks to Steve Graham for finding this \- patch to allow use of the [assign] tag in shipping \- patch to allow 'use_billing_override' to send billing addresses \- patch to display Long rather than Short \s-1PP\s0 error message to customers Thanks to Josh Lavin for these last three .PP version 1.0.6 September 2009 \- added 'use strict' and fixed odd errors (and removed giropay vestiges that belong in next version) \- made itemdetails loop through basket properly \- added Fraud Management Filters return messages to optional charge parameters version 1.0.5, June 2009 \- fixed bug with Canadian provinces: \s-1PP\s0 were sending shortened versions of 2 province names, and also sometimes sending the 2 letter code (possibly from older a/cs) rather than the full name. Thanks to Steve Graham for finding this. version 1.0.4, May 2009 \- re-wrote documentation, including revised and simplified method of co-operating with other payment systems in log_transaction. .PP version 1.0.3, 1.02.2009 \- fixed bug in handling of thousands separator .PP version 1.0.2, 22.01.2009 \- conversion of Canadian province names to 2 letter variant is now the default \- fixed bug with conversion of Canadian province names to 2 letter variant \- changed method of reading value of pprequest \- added failsafe logging to orders/paypal/ in case of order route failure \- fixed bug whereby \s-1PP\s0 returns billing name in a shipping address \- added note to docs re \s-1PP\s0 requiring cookie \- altered internal redirection code to better handle absence of cookies (thanks to Peter Ajamian for heads-up) \- altered docs to reflect the new sandbox (thanks to Josh Lavin for the heads-up on that) \- \s-1TODO:\s0 as the new \s-1API\s0 now includes a \s-1SOAP\s0 integration of recurring/subscription billing, need to convert existing name=value pair \s-1IPN\s0 module and integrate into this module. Will add masspay, refund and other functions at the same time. .PP version 1.0.1, 24.05.2008 \- added error message to \s-1IC\s0 session for when Paypal returns error message instead of token. \- added option to convert Canadian state/province names to an uppercased 2 letter variant, so as to agree with Interchange's de facto requirement for this. =back .SH "AUTHORS" .IX Header "AUTHORS" Lyn St George Based on original code by Mike Heins