Sitemagic Payment Standard

The Sitemagic Payment Standard is an extension for Sitemagic CMS, defining the functionality of Payment Extensions. It provides the developer with a common interface for using these Payment Extensions to carry though payments.

The Sitemagic Payment Standard extension consist of the following parts.

  • Payment Extension Manager (provides easy access to installed Payment Extensions)
  • Payment interface (defines the functionality for Payment Extensions)
  • Various helper classes used to carry information such as call back information, payment status messages etc.
The Sitemagic Payment Standard extension ships with two Payment Extensions for international PayPal and Danish Ewire.


Payment Extension Manager

The Payment Extension Manager provides access to installed Payment Extensions. It allows for a list of installed Payment Extensions to be fetched, and instances of each Payment Extension to be created.


SMPaymentExtensionManager class

Function Return type Description
::GetInstance() SMPaymentExtensionManager Get extension manager instance on which the following functions may be called.
GetExtensions() String[] Get string array containing the names of installed Payment Extensions.
CreatePaymentInstance($extension:string, $context:SMContext) SMPaymentInterface Create instance of a named Payment Extension (get names of Payment Extensions using GetExtensions()). Provide the SMContext object from the extension in which the Payment Extension is created (read more in the documentation for the content page extension).
AddExtension($extension:string, $file:string, $class:string)   Add a new Payment Extension to the Extension Manager, allowing it to be used by ie a webshop. Payment Extensions must extend the SMpaymentInterface class - read more about this further down the page.


Payment interface

The payment interface is a class from which all Payment Extensions must inherit. The class defines all available operations for most Payment Extensions. In short, the interface covers the following functionality.

  • Authorize, capture, cancel and refund payments
  • Manage subscriptions
  • Use checkout method (also known as a payment window for easier payment handling)
Notice that a Payment Extension can choose to implement only a subset of the functionality defined in the interface. Use the GetSupportedFunctions function to get a list of functionality available.


SMPaymentInterface class

Function Return type Description
__construct($context:SMContext)   Create instance of Payment Extension. $context is the SMContext object available from all extensions. Usually an instance of a Payment Extension is created using the Payment Extension Manager.
GetName() String Returns display name for the Payment Extension (ie PayPal)
GetPaymentMethods() SMPaymentMethod[] Get information about supported payment methods (usually credit cards). See SMPaymentMethod class for more information.
GetCurrencies() String[] Get list of supported currencies.
GetSupportedFunctions() SMPaymentFunction[] Actually a string array containing values identical to the values of the SMPaymentFunction enum (ie SMPaymentFunction::$Checkout, SMPaymentFunction::$Status etc). Since the extension may only provide a subset of the functionality supported by the Sitemagic Payment Standard, this function may be used to detect what functionality any given Payment Extension implements. See SMPaymentFunction for more information.
RegisterExternalCheckout($orderId:string, $currency:string, $amount:integer)

Register code neccessary in order to load/display payment window available through payment provider. This is usually the easiest way to implement support for payments through a payment provider. The $orderId variable should hold a unique ID identifying an order. $currency should contain the currency code (ie USD, DKK etc), and $amount should contain the amount to pay in the smallest unit available (usually 1/100 - for USD $1 would be 100).
RegisterExternalCheckout($orderId:string, $currency:string, $amount:integer, $autoCapture:bool)   See description for RegisterExternalCheckout( $orderId:string, $currency:string, $amount:integer). The $autoCapture variable determines whether to capture the amount immediately (auto), or later (manually) using the Capture function. Set True to capture automatically, False to authorize payment and capture it later. Auto capture must default to False if both Manual and Auto capture is supported.
RegisterExternalCheckout($orderId:string, $currency:string, $amount:integer, $autoCapture:bool, $callBackInfo:SMPaymentCallBackInfo)   See description for RegisterExternalCheckout($orderId:string, $currency:string, $amount:integer, $autoCapture:bool). The $callBackInfo variable holds a reference to a SMPaymentCallBackInfo object containing information about what URL to return to if a payment is either completed or canceled.
GetCheckoutCaptureSupport() SMPaymentCheckoutCapture[] Function returns an array containing supported capture methods in RegisterExternalCheckout. See SMPaymentCheckoutCapture enum for more information.
GetCheckoutCallBackSupport() SMPaymentCheckoutCallBackSupport[] Function returns an array containing supported call back functionality. See SMPaymentCheckoutCallBackSupport enum for more information.
Authorize($orderId:string, $currency:string, $amount:integer)
Boolean
Authorize a payment (reserve money on credit card, to allow it to be drawn later, when shipping the order). The $orderId variable should hold a unique ID identifying an order. $currency should contain the currency code (ie USD, DKK etc), and $amount should contain the amount to pay in the smallest unit available (usually 1/100 - for USD $1 would be 100).
RenewAuthorization($orderId:string) Bool Renew an existing authorization, which has only been reserved for a given period of time (specified in settings).
Capture($orderId:string)
Bool Capture a payment (draw the money reserved). Specify the order ID used to reserve the money (see Authorize function).
Subscribe($orderId:string, $currency:string, $amount:integer)
Bool
Create a subscription which can be captured regulary. The $orderId variable should hold a unique ID identifying an order. $currency should contain the currency code (ie USD, DKK etc), and $amount should contain the amount to pay in the smallest unit available (usually 1/100 - for USD $1 would be 100).
Recurring($orderId:string) Bool
Capture a subscription (draw the money reserved for a subscription). Specify the order ID used to reserve the money (see Subscribe function).
Cancel($orderId:string) Bool
Cancel a payment authorized or subscribed. Specify the order ID used to reserve the money (see Authorize or Subscribe function).
Refund($orderId:string, $amount:integer)
Bool
Refund part or the whole of a payment, which has been captured (drawn). Specify the order ID used to reserve the money (see Authorize or Subscribe function), and specify the amount to refund, in the smallest unit available (usually 1/100 - for USD $1 would be 100). Money is returned in the currency in which it was paid.
GetStatus($orderId:string)
SMPaymentStatus
Get payment status. Specify the order ID used to reserve the money (see Authorize or Subscribe function). See SMPaymentStatus class for more information.
Notice how no information about the payment account, to which money is transfered, is specified in any of the functions. Each function is responsible for loading account information from a set of stored values (settings).


Information objects

The following classes are used to carry information.


SMPaymentMethod class (holds information about payment method supported by the Payment Extension)

Function Return type Description
__construct($name:string)

Create named payment method (ie Visa)
__construct($name:string, $icon:string)
See description for __construct($name:string). Create named payment method with a reference to an image, usually of the credit card used (recommended height: 20px).
GetName()
String
Get name of payment method
GetIcon()
String
Get reference to icon, which is usually a credit card


SMPaymentStatus class (holds information about the current status (and history) of a payment)

Function Return type Description
__construct($orderId:string, $currency:string, $amount:integer, $status:SMPaymentStatusType, $timestamp:integer)
Create payment status object for an order. The status belongs to the order specified using $orderId. Specify the currency used in $currency, the amount in the smallest unit available in $amount (usually 1/100 - for USD $1 would be 100), and the payment status using any of the values from the SMPaymentStatusType enum. The $timestamp variable contains the creation date and time (Unix time stamp) of the status.
GetOrderId() String
Get order ID.
GetCurrency()
String
Get currency used for the payment.
GetAmount()
Integer
Get payment amount in smallest unit available (usually 1/100 - for USD $1 would be 100).
GetStatus()
SMPaymentStatusType
Get payment status identical to a value from the SMPaymentStatusType enum (ie SMPaymentStatusType::$Captured).
GetTimeStamp()
Integer
Get Unix Time Stamp representing creation date and time
GetAssociated()
SMPaymentStatus[]
Get all associated payment status objects (if a refund has been issued or similar).
SetAssociated($arr:SMPaymentStatus[])   Set associated payment status objects.


SMPaymentCallBackInfo class (used by RegisterExternalCheckout function to carry URLs)

Function Return type Description
__construct()

Create instance of class.
SetReturnUrl($value:string)

Set URL to return to when payment has been carried through.
GetReturnUrl()
String
Get URL to return to when payment has been carried through. NULL is returned if URL has not been specified.
SetCancelUrl($value:string)

Set URL to return to if payment process is canceled.
GetCancelUrl() String
Get URL to return to if payment process is canceled. NULL is returned if URL has not been specified.


Enums

SMPaymentCheckoutCapture enum

Enum value
Description
Manual
Checkout function allows for a payment to be authorized, so that a manual capture may be performed later.
Auto
Checkout function allows for a payment to be automatically captured (amount is immediately drawn)


SMPaymentCheckoutCallBackSupport enum

Enum value
Description
ReturnOnSuccess
Checkout function is capable of returning the user to the Sitemagic installation when a payment has been successfully carried through.
ReturnOnFailure
Checkout function is capable of returning the user in case of a failure occuring during the payment process.


SMPaymentFunction enum

Enum value
Description
Checkout
Payment Extension supports payment window (RegisterExternalCheckout function)
Authorize
Payment Extension allows for money to be reserve using an API (Authorize function)
RenewAuthorization Payment Extension allows for an existing reservation to be renewed using an API (RenewAuthorization function)
Capture
Payment Extension allows for a reserved amount of money to be charged using an API (Capture function)
Subscribe
Payment Extension allows for a subscription to be set up using an API (Subscribe function)
Recurring
Payment Extension allows for money to be charged from a subscription using an API (Recurring function)
Cancel
Payment Extension allows for a transaction to be canceled (when Authorized or Subscribed) using an API (Cancel function)
Refund
Payment Extension allows for a refund (of the whole or part of a reserved amount of money) to be issued using an API (Refund function)
Status
Payment Extension allows for a payment status to be queried using an API (GetStatus function)


SMPaymentStatusType enum

Enum value
Description
Authorized
Status of a payment when money has been successfully reserved
Captured
Status of a payment when money has been successfully captured (drawn)
Subscribed
Status of a payment when money has been successfully reserved for recurring captures
Recurred
Status of a payment when money has been successfully captured (drawn) from a subscription
Canceled Status of a payment when money transfer has been successfully canceled
Refunded
Status of a payment when money (part of, or the whole amount) has been successfully returned
Pending Status of a payment when money transfer is pending (ie in case it is being reviewed for potential fraud)
Expired
Status of a payment when money reservation has expired, and can no longer be captured
Denied Status of a payment when money could not be either reserved or captured. This is usually caused by lack of funds.
Unknown
Status for a payment that has no status.
Error An error occured while processing the requested operation (ie a system failure within the payment provide service)