Field Mappings - PTFS-Europe/koha-plugin-capita-payments GitHub Wiki

TL;DR

On Invoke

  • Koha accountline_id's are sent through to Capita in the sale/items/itemSummary/reference, sale/items/itemSummary/displayableReference and sale/items/lineID fields.
  • Koha transactionGUID is sent through to Capita in the requestID field (and is stored as transaction_guid in the plugins specific DB table)
  • Capita scpSimpleInvokeResponse/scpReference is stored in Koha as transaction_reference in the plugin specific DB table

On Success

  • A koha payment accountline is created for the 'transaction' and the accountline_id is added to the plugin-specific DB table row associated with the original transaction_guid

In detail

For each transaction initiated from Koha we send the following:

{
        credentials => {
            subject => {
                subjectType => 'CapitaPortal',
                identifier  => $Pay360PortalID,       # Plugin Configuration
                systemCode  => 'SCP'
            },
            requestIdentification => {
                uniqueReference => $requestGUID,      # Unique Random ID for just this HTTP request cycle
                timeStamp       => $timeStamp
            },
            signature => {
                algorithm => 'Original',
                hmacKeyID => $Pay360HMACID,           # Plugin Configuration
                digest    => $currentDigest           # Generated via Config + Timestamp + Request Details
            },
        },
        requestType => 'payOnly',
        requestId   => $transactionGUID,              # Unique Random ID for the 'Transaction', generated and stored in Koha
        routing     => {
            returnUrl => $returnURL,                  # Koha base url + Plugin configuration + Digests
            backUrl   => $cancelURL,                  # Koha base url + Plugin configuration + Digests
            siteId    => $Pay360SiteID,               # Plugin Configuration
            scpId     => $Pay360PortalID,             # Plugin Configuration
        },
        panEntryMethod => 'ECOM',
        billing        => {
            cardHolderDetails => {
                cardHolderName => $borrower->firstname . " "
                  . $borrower->surname,
                contact => {
                    email => $borrower->email
                }
            }
        },
        sale => {
            saleSummary => {
                description        => 'Library Payment',
                amountInMinorUnits => $sum_amountInMinorUnits,
            },
            items => {
                item => $items                        # Described in detail below
            }
        }
    }

For each accountline being paid in Koha via Capita Pay360 we send the following:

{
    itemSummary => {
        description => ( $accountline->description )
        ? $accountline->description
        : "Description not available",
        amountInMinorUnits   => $amount,
        reference            => $accountline->accountlines_id,    # Koha's accountline id for the debt being paid
        displayableReference => $accountline->accountlines_id,    # Koha's accountline id for the debt being paid
    },
    quantity => 1,
    lineId   => $accountline->accountlines_id,                    # Koha's accountline id for the debt being paid
    (
        defined($Pay360FundCode)
        ? (
            lgItemDetails => {
                fundCode => $Pay360FundCode                       # Plugin configuration
            }
          )
       : ()
      )
};

For a successfull transaction we store:

my $sth = $dbh->prepare(
            "UPDATE $table SET accountline_id = ? WHERE transaction_guid = ?");   # credit accountline_id against transaction_guid