[open-ils-commits] r17657 - in trunk/Open-ILS/src: perlmods/OpenILS/Application/Circ sql/Pg sql/Pg/upgrade (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Sep 14 15:01:33 EDT 2010


Author: senator
Date: 2010-09-14 15:01:28 -0400 (Tue, 14 Sep 2010)
New Revision: 17657

Added:
   trunk/Open-ILS/src/sql/Pg/upgrade/0396.data.org-setting-payflowpro.sql
Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm
   trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
   trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
Log:
Add PayfloPro support to credit card processing

Additionally, add some default view/update permissions to
credit-card-processing-related org settings.

This should bring the list of supported payment card processing APIs to:
AuthorizeNet, PayPal (Website Payments Pro), and PayflowPro


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm	2010-09-14 15:50:44 UTC (rev 17656)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm	2010-09-14 19:01:28 UTC (rev 17657)
@@ -21,6 +21,7 @@
 
 use Business::CreditCard;
 use Business::OnlinePayment;
+use UUID::Tiny qw/:std/;
 use Locale::Country;
 
 use OpenILS::Event;
@@ -68,24 +69,32 @@
     );
 }
 
+# Provide default arguments for calls using the PayflowPro processor
+sub bop_args_PayflowPro {
+    my $argshash = shift;
+    return (
+        "vendor" => $argshash->{vendor},
+        "partner" => $argshash->{partner} || "PayPal" # reasonable default?
+    );
+}
+
 sub get_processor_settings {
     my $org_unit = shift;
     my $processor = lc shift;
 
+    # XXX TODO: make this one single cstore request instead of many
     +{ map { ($_ =>
         $U->ou_ancestor_setting_value(
             $org_unit, CREDIT_NS . ".processor.${processor}.${_}"
-        )) } qw/enabled login password signature server testmode/
+        )) } qw/enabled login password signature server testmode vendor partner/
     };
 }
 
-#    signature => {
-#        desc   => 'Process a payment via a supported processor (AuthorizeNet, Paypal)',
-#        params => [
-#            { desc => q/Hash of arguments with these keys:
+#        argshash (Hash of arguments with these keys):
 #                patron_id: Not a barcode, but a patron's internal ID
 #                       ou: Org unit where transaction happens
-#                processor: Payment processor to use (AuthorizeNet, PayPal, etc)
+#                processor: Payment processor to use
+#                           (AuthorizeNet/PayPal/PayflowPro)
 #                       cc: credit card number
 #                     cvv2: 3 or 4 digits from back of card
 #                   amount: transaction value
@@ -98,10 +107,6 @@
 #                      zip: optional (default: patron's zip field)
 #                  country: optional (some processor APIs: 2 letter code.)
 #              description: optional
-#                /, type => 'hash' }
-#        ],
-#        return => { desc => 'an ilsevent' }
-#    }
 
 sub process_payment {
     my ($argshash) = @_;
@@ -209,6 +214,8 @@
     # PayPal must have 2 letter country field (ISO 3166) that's uppercase.
     if (length($content{country}) > 2 && $argshash->{processor} eq 'PayPal') {
         $content{country} = uc country2code($content{country});
+    } elsif($argshash->{processor} eq "PayflowPro") {
+        ($content{request_id} = create_uuid_as_string(UUID_V4)) =~ s/-//;
     }
 
     %content;
@@ -256,28 +263,26 @@
         $argshash->{processor}, %bop_args
     );
 
-    $transaction->content(prepare_bop_content($argshash, $patron, $cardtype));
+    my %content = prepare_bop_content($argshash, $patron, $cardtype);
+    $transaction->content(%content);
 
-    # XXX submit() does not return a value, although crashing is possible here
+    # submit() does not return a value, although crashing is possible here
     # with some bad input depending on the payment processor.
     $transaction->submit;
 
     my $payload = {
-        "processor" => $argshash->{"processor"},
-        "card_type" => $cardtype,
-        "server_response" => $transaction->server_response
+        "processor" => $argshash->{"processor"}, "card_type" => $cardtype
     };
 
-    foreach (qw/authorization correlationid avs_code cvv2_code error_message/) {
-        # authorization should always be present for successes, and
-        # error_message should always be present for failures. The remaining
-        # field may be important in PayPal transacations? Not sure.
+    # Put the values of any of these fields into the event payload, if present.
+    foreach (qw/authorization correlationid avs_code request_id
+        server_response cvv2_response cvv2_code error_message order_number/) {
         $payload->{$_} = $transaction->$_ if $transaction->can($_);
     }
 
     my $event_name;
 
-    if ($transaction->is_success()) {
+    if ($transaction->is_success) {
         $logger->info($argshash->{processor} . " payment succeeded");
         $event_name = "SUCCESS";
     } else {

Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2010-09-14 15:50:44 UTC (rev 17656)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2010-09-14 19:01:28 UTC (rev 17657)
@@ -68,7 +68,7 @@
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0394'); -- gmc
+INSERT INTO config.upgrade_log (version) VALUES ('0396'); -- senator
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,

Modified: trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql	2010-09-14 15:50:44 UTC (rev 17656)
+++ trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql	2010-09-14 19:01:28 UTC (rev 17657)
@@ -1383,6 +1383,8 @@
     ,(392, 'COPY_NEEDED_FOR_HOLD.override', oils_i18n_gettext( 392, 'Allow a user to force renewal of an item that could fulfill a hold request', 'ppl', 'description' ))
     ,(393, 'MERGE_AUTH_RECORDS', oils_i18n_gettext( 393, 'Allow a user to merge authority records together', 'ppl', 'description' ))
     ,(394, 'ISSUANCE_HOLDS', oils_i18n_gettext( 394, 'Allow a user to place holds on serials issuances', 'ppl', 'description' ))
+    ,(395, 'VIEW_CREDIT_CARD_PROCESSING', oils_i18n_gettext( 395, 'View org unit settings related to credit card processing', 'ppl', 'description' ))
+    ,(396, 'ADMIN_CREDIT_CARD_PROCESSING', oils_i18n_gettext( 396, 'Update org unit settings related to credit card processing', 'ppl', 'description' ))
 ;
 
 
@@ -1972,6 +1974,36 @@
     'Credit card processing: PayPal test mode',
     '',
     'bool' ),
+('credit.processor.payflowpro.enabled',
+    'Credit card processing: Enable PayflowPro payments',
+    'This is NOT the same thing as the settings labeled with just "PayPal."',
+    'bool'
+),
+('credit.processor.payflowpro.login',
+    'Credit card processing: PayflowPro login/merchant ID',
+    'Often the same thing as the PayPal manager login',
+    'string'
+),
+('credit.processor.payflowpro.password',
+    'Credit card processing: PayflowPro password',
+    'PayflowPro password',
+    'string'
+),
+('credit.processor.payflowpro.testmode',
+    'Credit card processing: PayflowPro test mode',
+    'Do not really process transactions, but stay in test mode - uses pilot-payflowpro.paypal.com instead of the usual host',
+    'bool'
+),
+('credit.processor.payflowpro.vendor',
+    'Credit card processing: PayflowPro vendor',
+    'Often the same thing as the login',
+    'string'
+),
+('credit.processor.payflowpro.partner',
+    'Credit card processing: PayflowPro partner',
+    'Often "PayPal" or "VeriSign", sometimes others',
+    'string'
+),
 
 ( 'ui.admin.work_log.max_entries',
     oils_i18n_gettext('ui.admin.work_log.max_entries', 'GUI: Work Log: Maximum Actions Logged', 'coust', 'label'),
@@ -2009,6 +2041,16 @@
     'string')
 ;
 
+UPDATE config.org_unit_setting_type
+    SET view_perm = (SELECT id FROM permission.perm_list
+        WHERE code = 'VIEW_CREDIT_CARD_PROCESSING' LIMIT 1)
+    WHERE name LIKE 'credit.processor%' AND view_perm IS NULL;
+
+UPDATE config.org_unit_setting_type
+    SET update_perm = (SELECT id FROM permission.perm_list
+        WHERE code = 'ADMIN_CREDIT_CARD_PROCESSING' LIMIT 1)
+    WHERE name LIKE 'credit.processor%' AND update_perm IS NULL;
+
 -- 0234.data.org-setting-ui.circ.suppress_checkin_popups.sql
 INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES (
         'ui.circ.suppress_checkin_popups',

Added: trunk/Open-ILS/src/sql/Pg/upgrade/0396.data.org-setting-payflowpro.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0396.data.org-setting-payflowpro.sql	                        (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0396.data.org-setting-payflowpro.sql	2010-09-14 19:01:28 UTC (rev 17657)
@@ -0,0 +1,59 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0396'); -- senator
+
+INSERT INTO permission.perm_list (code, description) VALUES
+    ('VIEW_CREDIT_CARD_PROCESSING',
+        'View org unit settings related to credit card processing'),
+    ('ADMIN_CREDIT_CARD_PROCESSING',
+        'Update org unit settings related to credit card processing');
+
+INSERT INTO config.org_unit_setting_type (
+    name, label, description, datatype
+) VALUES
+    ('credit.processor.payflowpro.enabled',
+        'Credit card processing: Enable PayflowPro payments',
+        'This is NOT the same thing as the settings labeled with just "PayPal."',
+        'bool'
+    ),
+    ('credit.processor.payflowpro.login',
+        'Credit card processing: PayflowPro login/merchant ID',
+        'Often the same thing as the PayPal manager login',
+        'string'
+    ),
+    ('credit.processor.payflowpro.password',
+        'Credit card processing: PayflowPro password',
+        'PayflowPro password',
+        'string'
+    ),
+    ('credit.processor.payflowpro.testmode',
+        'Credit card processing: PayflowPro test mode',
+        'Do not really process transactions, but stay in test mode - uses pilot-payflowpro.paypal.com instead of the usual host',
+        'bool'
+    ),
+    ('credit.processor.payflowpro.vendor',
+        'Credit card processing: PayflowPro vendor',
+        'Often the same thing as the login',
+        'string'
+    ),
+    ('credit.processor.payflowpro.partner',
+        'Credit card processing: PayflowPro partner',
+        'Often "PayPal" or "VeriSign", sometimes others',
+        'string'
+    );
+
+UPDATE config.org_unit_setting_type
+    SET description = 'This can be "AuthorizeNet", "PayPal" (for the Website Payment Pro API), or "PayflowPro".'
+    WHERE name = 'credit.processor.default';
+
+UPDATE config.org_unit_setting_type
+    SET view_perm = (SELECT id FROM permission.perm_list
+        WHERE code = 'VIEW_CREDIT_CARD_PROCESSING' LIMIT 1)
+    WHERE name LIKE 'credit.processor%' AND view_perm IS NULL;
+
+UPDATE config.org_unit_setting_type
+    SET update_perm = (SELECT id FROM permission.perm_list
+        WHERE code = 'ADMIN_CREDIT_CARD_PROCESSING' LIMIT 1)
+    WHERE name LIKE 'credit.processor%' AND update_perm IS NULL;
+
+COMMIT;



More information about the open-ils-commits mailing list