From 2e8596c1e5f2e9d9146846d291ae398a8b02b650 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 14 Jul 2016 16:16:38 -0400 Subject: [PATCH] JBAS-1494 PayFlow Hosted Pages for CC payments https://developer.paypal.com/docs/classic/payflow/gs_ppa_hosted_pages/ * Library settings to configure and activate. * New TPAC templates and WWW perl for processing payments. Signed-off-by: Bill Erickson --- .../var/templates_kcls/opac/biblio/main_fines.tt2 | 8 +- .../opac/parts/myopac/payment_xacts.tt2 | 46 +++ .../var/templates_kcls/opac/payflow/errors.tt2 | 41 +++ .../var/templates_kcls/opac/payflow/footer.tt2 | 9 + .../var/templates_kcls/opac/payflow/form1.tt2 | 105 +++++++ .../var/templates_kcls/opac/payflow/form2.tt2 | 32 +++ .../var/templates_kcls/opac/payflow/pay_form.tt2 | 96 +++++++ .../templates_kcls/opac/payflow/pay_receipt.tt2 | 58 ++++ .../templates_kcls/opac/payflow/pay_response.tt2 | 95 +++++++ .../schema/deploy/payflow-hosted-org-settings.sql | 39 +++ .../schema/revert/payflow-hosted-org-settings.sql | 9 + KCLS/sql/schema/sqitch.plan | 1 + .../schema/verify/payflow-hosted-org-settings.sql | 7 + .../lib/OpenILS/Application/Circ/CircCommon.pm | 2 +- .../perlmods/lib/OpenILS/Application/Circ/Money.pm | 4 + .../src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm | 8 +- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 316 ++++++++++++++++++++- .../lib/OpenILS/WWW/EGCatLoader/PayflowHosted.pm | 220 ++++++++++++++ 18 files changed, 1092 insertions(+), 4 deletions(-) create mode 100644 KCLS/openils/var/templates_kcls/opac/parts/myopac/payment_xacts.tt2 create mode 100644 KCLS/openils/var/templates_kcls/opac/payflow/errors.tt2 create mode 100644 KCLS/openils/var/templates_kcls/opac/payflow/footer.tt2 create mode 100644 KCLS/openils/var/templates_kcls/opac/payflow/form1.tt2 create mode 100644 KCLS/openils/var/templates_kcls/opac/payflow/form2.tt2 create mode 100644 KCLS/openils/var/templates_kcls/opac/payflow/pay_form.tt2 create mode 100644 KCLS/openils/var/templates_kcls/opac/payflow/pay_receipt.tt2 create mode 100644 KCLS/openils/var/templates_kcls/opac/payflow/pay_response.tt2 create mode 100644 KCLS/sql/schema/deploy/payflow-hosted-org-settings.sql create mode 100644 KCLS/sql/schema/revert/payflow-hosted-org-settings.sql create mode 100644 KCLS/sql/schema/verify/payflow-hosted-org-settings.sql create mode 100644 Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/PayflowHosted.pm diff --git a/KCLS/openils/var/templates_kcls/opac/biblio/main_fines.tt2 b/KCLS/openils/var/templates_kcls/opac/biblio/main_fines.tt2 index c273bb0662..3bad65b5ca 100644 --- a/KCLS/openils/var/templates_kcls/opac/biblio/main_fines.tt2 +++ b/KCLS/openils/var/templates_kcls/opac/biblio/main_fines.tt2 @@ -16,7 +16,13 @@ -
+[% + pay_form_url = ctx.opac_root _ '/biblio/main_payment_form'; + IF ctx.using_payflow OR CGI.param('use_payflow'); + pay_form_url = ctx.opac_root _ '/payflow/pay_form'; + END; +%] + [% IF ctx.fines.circulation.size > 0 %]
diff --git a/KCLS/openils/var/templates_kcls/opac/parts/myopac/payment_xacts.tt2 b/KCLS/openils/var/templates_kcls/opac/parts/myopac/payment_xacts.tt2 new file mode 100644 index 0000000000..ae7ee82247 --- /dev/null +++ b/KCLS/openils/var/templates_kcls/opac/parts/myopac/payment_xacts.tt2 @@ -0,0 +1,46 @@ +
+
+

[% l('Selected fines you are paying for:') %]

+ +
+ + + + + + [% + FOR f IN ctx.fines.circulation; + NEXT IF CGI.param('xact').size && + !CGI.param('xact').grep(f.xact.id).size; + attrs = {marc_xml => f.marc_xml}; + IF f.marc_xml; + PROCESS get_marc_attrs args=attrs; + ELSIF f.xact.reservation; + attrs.title = f.xact.reservation.target_resource_type.name; + END %] + + + + + [% + END; + FOR f IN ctx.fines.grocery; + NEXT IF CGI.param('xact_misc').size && + !CGI.param('xact_misc').grep(f.xact.id).size %] + + + + + [% END %] + +
[% l('Name') %][% l('Amount') %]
[% attrs.title | html %][% money(f.xact.balance_owed) %]
[% f.xact.last_billing_type | html %][% money(f.xact.balance_owed) %]
+ +
+ +
+ [% l('Total amount to pay:') %] + [% money(ctx.fines.balance_owed) %] +
+ +
+ diff --git a/KCLS/openils/var/templates_kcls/opac/payflow/errors.tt2 b/KCLS/openils/var/templates_kcls/opac/payflow/errors.tt2 new file mode 100644 index 0000000000..15dc23e848 --- /dev/null +++ b/KCLS/openils/var/templates_kcls/opac/payflow/errors.tt2 @@ -0,0 +1,41 @@ +
+[% + +# Map PayFlow POST response codes to patron messages. +# https://developer.paypal.com/docs/classic/payflow/integration-guide/#result-values-and-respmsg-text + +SWITCH ctx.payflow_hosted_ctx.RESULT; + + CASE '12'; # Declined. + l('Declined. Please verify your card details.'); + + CASE '23'; # Invalid CC number (e..g mis-typed) + l('Declined. Please make sure you entered your credit card number correctly.'); + + CASE '25'; # Transaction type not mapped to this host + l('KCLS does not accept AMEX or Discover Card at this time. Please use your Visa or MasterCard.'); + + CASE '114'; # CVV2 or CID Mismatch + l('Declined. Please make sure you entered the three digit code on the back of your card correctly.'); + + CASE '125'; + handled = 0; + l('Declined. '); + + IF ctx.payflow_hosted_ctx.PROCCVV2 == 'N'; + l('Please make sure you entered the three digit code on the back of your card correctly. '); + handled = 1; + END; + + IF NOT handled + OR ctx.payflow_hosted_ctx.AVSADDR == 'N' + OR ctx.payflow_hosted_ctx.AVSZIP == 'N'; + l('Please make sure your billing information matches what the bank has on file for your credit card.'); + END; + + CASE DEFAULT; + l('An unkown error occurred attempting credit card payment.'); +END; + +%] +
diff --git a/KCLS/openils/var/templates_kcls/opac/payflow/footer.tt2 b/KCLS/openils/var/templates_kcls/opac/payflow/footer.tt2 new file mode 100644 index 0000000000..199765cf1e --- /dev/null +++ b/KCLS/openils/var/templates_kcls/opac/payflow/footer.tt2 @@ -0,0 +1,9 @@ +