From d33e6522c0d01dcadcc0d73384a193941b16487a Mon Sep 17 00:00:00 2001 From: senator Date: Tue, 1 Jun 2010 20:35:21 +0000 Subject: [PATCH] Move credit card processing ML code into the circ module, removing API method for direct payment processing. (Using open-ils.circ.money.payment with auth can invoke CC processing). git-svn-id: svn://svn.open-ils.org/ILS/trunk@16550 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Circ.pm | 1 + .../OpenILS/Application/{ => Circ}/CreditCard.pm | 54 ++++++++++------------ .../src/perlmods/OpenILS/Application/Circ/Money.pm | 44 +++++++++++++++--- 3 files changed, 63 insertions(+), 36 deletions(-) rename Open-ILS/src/perlmods/OpenILS/Application/{ => Circ}/CreditCard.pm (85%) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm index 16bd62ef13..794dba3542 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm @@ -8,6 +8,7 @@ use OpenILS::Application::Circ::Survey; use OpenILS::Application::Circ::StatCat; use OpenILS::Application::Circ::Holds; use OpenILS::Application::Circ::HoldNotify; +use OpenILS::Application::Circ::CreditCard; use OpenILS::Application::Circ::Money; use OpenILS::Application::Circ::NonCat; use OpenILS::Application::Circ::CopyLocations; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/CreditCard.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm similarity index 85% rename from Open-ILS/src/perlmods/OpenILS/Application/CreditCard.pm rename to Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm index 10d779c2d5..1475fc64c4 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/CreditCard.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm @@ -15,7 +15,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # -------------------------------------------------------------------- -package OpenILS::Application::CreditCard; +package OpenILS::Application::Circ::CreditCard; use base qw/OpenSRF::Application/; use strict; use warnings; @@ -79,36 +79,32 @@ sub get_processor_settings { }; } -__PACKAGE__->register_method( - method => 'process_payment', - api_name => 'open-ils.credit.process', - signature => { - desc => 'Process a payment via a supported processor (AuthorizeNet, Paypal)', - params => [ - { desc => q/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) - cc: credit card number - cvv2: 3 or 4 digits from back of card - amount: transaction value - action: optional (default: Normal Authorization) - first_name: optional (default: patron's first_given_name field) - last_name: optional (default: patron's family_name field) - address: optional (default: patron's street1 field + street2) - city: optional (default: patron's city field) - state: optional (default: patron's state field) - zip: optional (default: patron's zip field) - country: optional (some processor APIs: 2 letter code.) - description: optional - /, type => 'hash' } - ], - return => { desc => 'Hash of status information', type =>'hash' } - } -); +# signature => { +# desc => 'Process a payment via a supported processor (AuthorizeNet, Paypal)', +# params => [ +# { desc => q/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) +# cc: credit card number +# cvv2: 3 or 4 digits from back of card +# amount: transaction value +# action: optional (default: Normal Authorization) +# first_name: optional (default: patron's first_given_name field) +# last_name: optional (default: patron's family_name field) +# address: optional (default: patron's street1 field + street2) +# city: optional (default: patron's city field) +# state: optional (default: patron's state field) +# zip: optional (default: patron's zip field) +# country: optional (some processor APIs: 2 letter code.) +# description: optional +# /, type => 'hash' } +# ], +# return => { desc => 'Hash of status information', type =>'hash' } +# } sub process_payment { - my ($self, $client, $argshash) = @_; # $client is unused in this sub + my ($argshash) = @_; # Confirm some required arguments. return OpenILS::Event->new('BAD_PARAMS') diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm index dbf9cdc699..2dccec39b6 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm @@ -65,7 +65,36 @@ __PACKAGE__->register_method( ], }/, type => 'hash' }, - ] + ], + "return" => { + "desc" => + q{1 on success, event on failure. Event possibilities include: + BAD_PARAMS + (Bad parameters were given to this API method itself. + See note field.) + CREDIT_PROCESSOR_NOT_SPECIFIED + (Evergreen has not been set up to process CC payments) + CREDIT_PROCESSOR_NOT_ALLOWED + (Evergreen has been incorrectly setup for CC payments) + CREDIT_PROCESSOR_NOT_ENABLED + (Evergreen has been set up for CC payments, but an admin + has not explicitly enabled them) + CREDIT_PROCESSOR_BAD_PARAMS + (Evergreen has been incorrectly setup for CC payments; + specifically, the login and/or password for the CC + processor weren't provided) + CREDIT_PROCESSOR_DECLINED_TRANSACTION + (We contacted the CC processor to attempt the charge, but + they declined it. See the statusText field for their + message.) + CREDIT_PROCESSOR_SUCCESS_WO_RECORD + (A payment was processed successfully, but couldn't be + recorded in Evergreen. This is bad bad bad, as it means + somebody made a payment but isn't getting credit for it. + See note field for more info.) +}, + "type" => "number" + } } ); sub make_payments { @@ -201,10 +230,8 @@ sub make_payments { if ($cc_args->{where_process} == 1) { return OpenILS::Event->new('BAD_PARAMS', note => 'Need CC number') if not $cc_args->{number}; - my $response = $apputils->simplereq( - 'open-ils.credit', - 'open-ils.credit.process', - { + my $response = + OpenILS::Application::Circ::CreditCard::process_payment({ "desc" => $cc_args->{note}, "amount" => $total_paid, "patron_id" => $user_id, @@ -221,10 +248,13 @@ sub make_payments { "city" => $cc_args->{billing_city}, "state" => $cc_args->{billing_state}, "zip" => $cc_args->{billing_zip}, - } - ); + }); if (exists $response->{ilsevent}) { + $logger->info( + "event response from process_payment(): " . + $response->{"textcode"} + ); return $response; } if ($response->{statusCode} != 200) { -- 2.11.0