Cost Recovery System Technology

The Cost Recovery System manages payments for data deposited to Dryad.

Overview
The Cost Recovery System includes:
 * Determination of which payment plan will be applied to a submission.
 * Transaction tracking for journals with subscriptions.
 * Creation and tracking of single-use vouchers.
 * Integration with a payment processor for author-pays submissions.

Supporting Documents

 * [[Media:AdminCostRecoverySystem-2013-07-25.pdf|Administrator Guide to the Cost Recovery System]]
 * [[Media:Payflowgateway guide testing accounts and guidelines.pdf|PayFlow Testing Guide and Error Codes]]
 * KnowledgeCenter Guide to PayPal/PayFlow

Usage
When a submission is initially created, the journal name is used to determine which payment plan will apply to the submission. As the user progresses through the submission process, they may view and modify payment settings.

Configuration
For the system to work, the database must include the tables that support the shopping cart and vouchers: psql -U dryad_app -d dryad_repo < dspace/etc/postgres/database_change_payment_system.sql

All configuration is performed using the file config/modules/payment-system.cfg

Configuration on PayPal
Additional configuration must be performed in the PayPal Manager system before the credit-card entry form will display. See the settings in the existing PayPal account for details.

Settings must be made on all pages of the "Service Settings" area.

Workflow
Note: The steps after Review and Curate have been adjusted slightly from this diagram. See Publication Blackout

[[Media:PaymentProcessingFlowDiagram.pdf|Workflow Diagram]]

PayFlow Payment Gateway
PayFlow is a gateway operated by PayPal, but ties into an external merchant account. It was originally developed by VeriSign. It was previously known as "Website Payments Pro".

Features:
 * Helpdesk: 7:00 AM – 8:00 PM CDT, Monday – Friday.
 * Available currencies: (see the bottom of FAQ page)
 * Virtual Terminal for processing phone, fax, and mail payments.
 * exports data to Excel, QuickBooks or Quicken
 * PayFlow products comparison
 * PayFlow Link is the basic system
 * Requires that we use their hosted pages for all forms. Doesn't allow complete customization of the forms. Their forms include some PayPal branding, which is undesirable.
 * Cannot process sales transactions through the API. This seems to indicate that we cannot process delayed "reference transactions" via PayFlow Link. (But it's not entirely clear.)
 * PayFlow Pro is the full-featured system
 * Developer site
 * Gateway Developer Guide and Reference
 * Transparent Redirect (only in payflow pro) = displaying forms on our site, but having them processed on paypal's site
 * They do not support unicode characters, only ASCII.
 * "secure token" = auth token for our servers to contact paypal servers
 * we will need to perform "zero dollar authorization" (TRXTYPE=A, AMT=0, VERBOSITY=HIGH), then do a "reference transaction"
 * reference tokens are valid for 12 months
 * "Only your account administrator can enable reference transactions"
 * express checkout = very simple system that requires customers to have a paypal account. Allows for authorization/capture, but not a true delayed payment.

Payment status values
Shopping cart statuses:
 * open -- credit card information not received OR some other form of payment is in effect
 * verified -- credit card has been approved
 * completed -- payment has been processed

Voucher statuses:
 * open -- voucher has not been charged (but may be attached to a shopping cart)
 * used -- voucher has been charged

Troubleshooting
Shopping cart fix for people who were charged but should have a subscription: select * from shoppingcart where journal like '%*'; update shoppingcart set total=0, transaction_id=null,securetoken=null,journal_sub=TRUE where cart_id=######; update shoppingcart set journal='Heredity' where cart_id in (select cart_id from shoppingcart where journal like 'Heredity*');

Implementation

 * for card verification, handling is in PaypalReturnStep -- because the results must go to the web UI
 * for the completed sale transaction, handling is in PaypalImpl

Reports needed

 * Submissions by type of payment plan (sorted version of submission by journal?)
 * Submissions for plan vs. no plan (user pays)
 * Submissions pre/post payment system launch on 2013-3-9 total and by journal
 * Submissions by journal for any time period and for subsets of journals (needed for statements and billing as well as metrics)

Quick reports from the database
Archived items that are paid: select * from shoppingcart where item IN (select item_id from item where in_archive=TRUE) and country not like 'pre-DPC%';

In pub blackout that are paid: select * from shoppingcart where item IN (select item_id from workflowitem where workflow_id in (select workflow_item_id from taskowner where owner_id =949)) and country not like 'pre-DPC%';