Payment

These are methods affecting payment for an order.

AdjustBalance

Since version 2.5

Adjusts the balance on an order, just as if an administrator adjusted the price via the “Adjust Price…” button on the Order Details page.

Method

int AdjustBalance(string orderID,

string isoCurrencyCode,

long amount,

bool taxable,

string reason)

Parameters

orderID — Internal order identifier

isoCurrencyCode — Currency of the balance adjustment. Must match the currency of the order.

amount — Amount to adjust balance by, positive or negative

taxable — Set this to true if the adjustment is taxable

reason — Descriptive comment for the balance adjustment. You must set this to a non empty string.

Returns

Normally, eSuccess. Returns an error if the balance adjustment failed (e.g. if there were no ledger entries for that order yet.)

CollectPayment

Since version 3.0

Attempt to collect payment on this order, just as if an administrator pressed the “Collect Payment” button on the Finance pages. In particular, this will trigger a DelayedCapture2 event.

Method

bool CollectPayment(string orderId)

Parameters

orderID — Internal order identifier

Returns

Returns true if it succeeds.

DelayedAuthorizationComplete (deprecated)

Since version 7.6

Note:    This event is deprecated. Use DelayedAuthorizationComplete2() instead (described below).

An order whose PaymentStatus is “PEND” (Pending) should now have a PaymentStatus of “AUTH” (Authorized) or “DECL” (Declined), as appropriate.

Method

int DelayedAuthorizationComplete(string orderID, PaymentResponse ccs)

Parameters

orderID — Internal order identifier.

ccs — a PaymentResponse object. The TransactionID, CollectionToken, result fields, etc. should be filled in as if this were the return from an AuthorizeTransaction call.

Returns

Returns eInvalidValue if the user does not require approval, or if the order has already been approved or declined.

Remarks

If the ccs.result is “ccPENDING”, this has no effect. If the ccs.result is “ccSUCCESS”, then the PaymentStatus for the order is set to “AUTH”. If the ccs.result is “ccDECLINE”, then PaymentStatus is set to “DECL” and the order is cancelled (all documents are rejected). We do not asynchronously place the items back in the shopping cart; the user must reorder them if they want to try again.

DelayedAuthorizationComplete2

Since version 9.1

Tells Storefront that a payment whose PaymentStatus is “PEND” (Pending) has been resolved to “AUTH” (Authorized) or “DECL” (Declined), as appropriate.

Method

int DelayedAuthorizationComplete2(string orderID,

string paymentId,

PaymentResponse prsp)

Parameters

orderID — Internal order identifier.

paymentId—Internal payment identifier.

prsp — a PaymentResponse object. The TransactionID, CollectionToken, result fields, etc. should be filled in as if this were the return from an AuthorizeTransaction call.

Returns

Returns eSuccess if the old PaymentStatus for the payment was “PEND” (Pending) before the call, and it changes that status to “AUTH” (Authorized) or “DECL” (Declined) according to whether the prsp.result is “ccSUCCESS” or “ccDECLINE”; if the latter, then the order is cancelled (all documents are rejected). Otherwise if the old PaymentStatus for the payment was anything other than “PEND” then the call returns eUnknownError.

Remarks

We do not asynchronously place cancelled items back in the shopping cart; the user must reorder them if they want to try again.

FundsCollected

Since version 2.5

Record (in the ledger, primarily) that a payment has been made external to Storefront, with respect to the given order, just as if an administrator adjusted the balance due via the “Report Offline Activity…” button on the Order Details page.

Method

int FundsCollected(string orderID,

string isoCurrencyCode,

double amount,

string description)

Parameters

orderID — Internal order identifier

isoCurrencyCode — Currency of the balance adjustment. Must match the currency of the order.

amount — Amount to adjust balance by

description — Descriptive comment for the balance adjustment. You must set this to a non empty string.

Returns

Returns eSuccess if it succeeds.

GetCurrencyValue

Since version 7.7

Retrieve a currency value from the Storefront database. This is like GetValue but is defined for properties which return an amount of currency, e.g. DocumentProperty.Price. Instead of returning a string which must be parsed, this method can return the amount as a double.

Method

bool GetCurrencyValue(string fieldType,

                       string fieldName,

                       string objectID,

                       out string CurrencyUnit,

                       out double Amount)

Parameters

fieldType — One of the fieldType constants described in the Shared Classes section.

fieldName — One of the field names described in the Shared Classes section, or a deployer-defined field name.

objectID — Internal ID of the object (e.g. document, user, order) querying information on.

CurrencyUnit — 3-letter ISO-4217 currency code of the currency used. (e.g. EUR for euros and USD for U.S. Dollars)

Amount — the value requested, as a floating-point number.

Returns

On failure, returns false and sets CurrencyUnit to null and Amount to 0.0. On success, returns true.

Remarks

This returns valid values for the following properties:

OrderProperty: RawPrice, DiscountedPrice, DiscountAmount, HandlingCharge, ShippingCharge, Tax

ShipmentProperty: ShippingCharge

AssetProperty: Price

DocumentProperty: DiscountAmount, Price, DiscountedPrice, ProductionPrice, TaxableProductionPrice, NontaxableProductionPrice, DatabasePrice

ImportPriceTable

Since version 9.0.4

Copy a CSV price table into Storefront.

Method

string ImportPriceTable(string tableName, string filename, string priceTableType, bool overwriteIfExisting)

Parameters

tablename—Name of the price table.

filename — Full file path to the CSV file of values to upload. This file should be in the same format that is used for uploading a price table in the UI.

priceTableType — Either “D” for a document price table or “P” for a per-page (leaf) price table.

overwriteIfExisting—If false, this fails if the "tableName" is already a price table in the deployment. If true, it overwrites the values of that price table with the values from the CSV in this situation

Returns

This method returns the internal ID of the price table.

SetCurrencyValue

Since version 7.7

Set a currency value in the Storefront database. This is like SetValue but is defined for properties which return an amount of currency, e.g. DocumentProperty.Price, and allows the extension to specify the price as a floating-point number.

Method

bool SetCurrencyValue(string fieldType,

             string fieldName,

             string objectID,

             string CurrencyUnit,

             double Amount)

Parameters

fieldType — One of the fieldType constants described in the Shared Classes section.

fieldName — One of the field names described in the Shared Classes section, or a deployer-defined field name.

objectID — Internal ID of the object (e.g. document, user, order) querying information on.

CurrencyUnit — Three-letter ISO-4217 currency code of the currency used. (e.g. EUR for euros and USD for U.S. Dollars)

Amount — The value to be set, as a floating-point number.

Returns

On failure, returns false. On success, returns true.

Remarks

This returns valid values for the following properties:

OrderProperty: DiscountAmount, HandlingCharge, ShippingCharge

AssetProperty: Price

DocumentProperty: DiscountAmount, Price, TaxableProductionPrice, NontaxableProductionPrice

VoidCollectionToken

Since version 3.0

Void the authorization for this payment, just as if an administrator clicked the “Void Authorization” button on the Finance pages.

Method

bool VoidCollectionToken(string orderId)

Parameters

orderID — Internal order identifier

Returns

Returns true if it succeeds.