Introduction

Postfinance (proper spelling PostFinance) is a subsidiary of the state-owned Swiss Post, which is active in private customer business and business customer business and as such is one of the largest Swiss financial institutions. The main area of activity is national and international payment transactions. In addition, it also offers products and services in the areas of savings, investments, retirement planning and financing. Since the end of June 2013, Postfinance has held a banking license and is under the supervision of the Swiss Financial Market Supervisory Authority (FINMA). In 2015, Postfinance was classified as systemically important domestically by the Swiss National Bank and must comply with special rules on equity and liquidity and submit an emergency plan.

With e-finance, the online banking service from PostFinance, you can easily manage your finances anywhere and at any time via computer or smartphone. You can connect e-finance with selected payment transaction and accounting software and simplify your processes.

POST Request - genericpayment – add_paydata[action] = register_alias

To register a Postfinance alias, there are 3 steps to take:

  1. Initiate Alias Registration
    To start the alias registration you need to send a generic payment request with action “register_alias” to our server api.
  2. Request Alias
    The customer will be redirected to the postfinance alias registration page. After authorization, the customer will be redirected to your shop. When the customer has arrived, you can call the generic payment request with action “get_alias” to receive the registered alias. Save the alias in the customer’s profile, to use it for future authorizations. You will always use the same registered alias for this customer for every future authorization.
  3. Request Payment with Alias
    When the registration is finished, you can send an authorization request to our server api and send the alias in the request. When we receive an alias in the authorization, we will process an alias payment to postfinance. When you don’t send the alias, we will try to process a “normal” authorization to postfinance including a redirect of the customer.
Account Parameters
request
required
Fixed Value: genericpayment
mid
required
your merchant ID, 5-digit numeric
aid
required
your subaccount ID, 5-digit numeric
portalId
required
your Portal ID, 7-digit numeric
key
required
your key value, alpha-numeric
common Parameters
clearingtype
required
Permitted Value sb
onlinebanktransfertype
required
Permitted Value PFF
PFF = Postfinance E-Finance
mode
required
Fixed Value: test/live
amount
required
Fixed Value: 0

As only the configuration is requested, the amount is set to zero

currency
required
Format LIST

Permitted values ISO 4217 (currencies) 3-letter-codes

Samples EUR, USD, GBP

bankcountry
required
Format LIST
Permitted Value CH
country
required
Format LIST
Permitted value CH
successurl
required
Format CHAR(2..255)

Scheme <scheme>://<host>/<path>
       <scheme>://<host>/<path>?<query>
       
scheme-pattern: [a-zA-Z]{1}[a-zA-Z0-9]{1,9}

URL for "payment successful"

errorurl
required
Format CHAR(2..255)

Scheme <scheme>://<host>/<path>
       <scheme>://<host>/<path>?<query>
       
scheme-pattern: [a-zA-Z]{1}[a-zA-Z0-9]{1,9}

URL for "faulty payment"

backurl
required
Format CHAR(2..255)

Scheme <scheme>://<host>/<path>
       <scheme>://<host>/<path>?<query>
       
scheme-pattern: [a-zA-Z]{1}[a-zA-Z0-9]{1,9}

URL for "Back" or "Cancel"

add_paydata Parameters
add_paydata[action]
required
AN..255
Set to "register_alias"
Response Parameters
Permitted Values
REDIRECT
ERROR
Response Parameter (REDIRECT)
 redirecturl
Format CHAR(2..2000)

URL to redirect the customer. The customer needs to authenticate the alias_registration at postfinance. 

 

Redirect URL → zMerchant system has to redirect customer to this URL to complete payment

 workorderid
Format CHAR(1..50)

The ID is unique. The returned workorderid is mandatory for the following requests of PayPal Express Checkout.

 

The workorderid is a technical id returned from the PAYONE platform to identify a workorder. A workorder is a part of a payment process (identified by a txid). The workorderid is used for the genericpayment request.

Response parameters (error)
Format NUMERIC(1..6)

In case of error the PAYONE Platform returns an error code for your internal usage.

Format CHAR(1..1024)

In case of error the PAYONE Platform returns an error message for your internal usage.

Host: api.pay1.de
Content-Type: application/x-www-form-urlencoded
Payload                    
add_paydata[action]=register_alias aid=12345 mid=23456 portalid=12345123 key=abcdefghijklmn123456789 clearingtype=sb currency=CHF country=CH bankcountry=CH mode=test request=genericpayment onlinebanktransfertype=PFF
RESPONSE
status=REDIRECT redirecturl=http://www.aliasregistrationpage.com workorderid=WORKORDERID12345
POST Request - genericpayment – add_paydata[action] = get_alias
Account Parameters
request
required
Fixed Value: genericpayment
mid
required
your merchant ID, 5-digit numeric
aid
required
your subaccount ID, 5-digit numeric
portalId
required
your Portal ID, 7-digit numeric
key
required
your key value, alpha-numeric
common Parameters
workorderid
required
Format CHAR(1..50)

With the first genericpayment the workorderid will be generated from the PAYONE platform and will be sent to you in the response. The ID is unique. The returned workorderid is mandatory for the following requests.

clearingtype
required
Permitted Value sb
onlinebanktransfertype
required
Fixed Value PFF

PFF = Postfinance E-Finance

currency
required
Format LIST
Permitted Value CHF
bankcountry
required
Format LIST
Permitted Value CH
country
required
Format LIST
Permitted value CH
add_paydata Parameters
add_paydata[action]
required
AN..255
Set to "get_alias"
Response Parameters
Permitted Values
OK
ERROR
Response Parameter (OK)
workorderid
Format CHAR(1..50)

The ID is unique. The returned workorderid is mandatory for the following requests of PayPal Express Checkout.

The workorderid is a technical id returned from the PAYONE platform to identify a workorder. A workorder is a part of a payment process (identified by a txid). The workorderid is used for the genericpayment request.

add_paydata[alias]

alias of the buyer

Response parameters (error)
Format NUMERIC(1..6)

In case of error the PAYONE Platform returns an error code for your internal usage.

Format CHAR(1..1024)

In case of error the PAYONE Platform returns an error message for your internal usage.

Host: api.pay1.de
Content-Type: application/x-www-form-urlencoded
Payload
add_paydata[action]=get_alias aid=12345 mid=23456 portalid=12345123 key=abcdefghijklmn123456789 clearingtype=sb bankcountry=CH currency=EUR mode=test request=genericpayment onlinebanktransfertype=PFF workorderid=WORKORDERID12345
RESPONSE
status=OK add_paydata[alias]=yourcustomeralias workorderid=WORKORDERID12345
POST Request Pre- /Authorization
Account Parameters
request
required
Fixed Value: preauthorisation/authorization
mid
required
your merchant ID, 5-digit numeric
aid
required
your subaccount ID, 5-digit numeric
portalId
required
your Portal ID, 7-digit numeric
key
required
your key value, alpha-numeric
common Parameters
clearingtype
required
Fixed Value: sb
onlinebanktransfertype
required
Permitted Value PFF
PFF = Postfinance E-Finance
mode
required
Fixed Value: test/live

can be either test environment (test) or live environment (live)

reference
optional
Format CHAR(2..255)

a unique ID that will be displayed in your shop backend and for the customer

amount
required
Format NUMERIC(1..10)
Permitted values max. +/- 19 999 999 99

Specifies the total gross amount of a payment transaction.

Value is given in smallest currency unit, e.g. Cent of Euro.

The amount must be less than or equal to the amount of the corresponding booking.

currency
required
Format LIST

Permitted values ISO 4217 (currencies) 3-letter-codes

 

Samples EUR, USD, GBP

bankcountry
required
Fixed Value CH
narrative_text
optional
Format CHAR(1..81)

Dynamic text element on account statements
(3 lines with 27 characters each) and credit card statements.

successurl
required
Format CHAR(2..255)

Scheme <scheme>://<host>/<path>
       <scheme>://<host>/<path>?<query>
       
scheme-pattern: [a-zA-Z]{1}[a-zA-Z0-9]{1,9}

URL for "payment successful"

errorurl
required
Format CHAR(2..255)

Scheme <scheme>://<host>/<path>
       <scheme>://<host>/<path>?<query>
       
scheme-pattern: [a-zA-Z]{1}[a-zA-Z0-9]{1,9}

URL for "faulty payment"

backurl
required
Format CHAR(2..255)

Scheme <scheme>://<host>/<path>
       <scheme>://<host>/<path>?<query>
       
scheme-pattern: [a-zA-Z]{1}[a-zA-Z0-9]{1,9}

URL for "Back" or "Cancel"

PERSONAL DATA Parameters
customerid
optional
Format CHAR(1..20)
Permitted Symbols [0-9, a-z, A-Z, .,-,_,/]

Merchant's customer ID, defined by you / merchant to refer to the customer record.

"customerid" can be used to identify a customer record.
If "customerid" is used then stored customer data are loaded automatically.
userid
optional
Format NUMERIC(6..12)

PAYONE User ID, defined by PAYONE

businessrelation
optional
Format LIST
value Comment
b2c

Indicates business to private customer

b2b

indicates business to business customer (company)

currently not available for PDD

Value specifies business relation between merchant and customer

salutation
optional
Format CHAR(1..10)

The customer's salutation

title
optional
Format CHAR(1..20)
Samples

Dr
Prof.
Dr.-Ing.

Title of the customer

firstname
optional
Format CHAR(1..50)

First name of customer; optional if company is used, i.e.: you may use

"company" or "lastname" or "firstname" plus "lastname"

lastname
required
Format CHAR(2..50)

Last name of customer; optional if company is used, i.e.: you may use

"company" or "lastname" or "firstname" plus "lastname"

company
optional
Format CHAR(2..50)

Comany name of customer; optional if company is used, i.e.: you may use

"company" or "lastname" or "firstname" plus "lastname"

street
optional
Format CHAR(1..50)

Street number and name (required: at least one character)

addressaddition
optional
Format CHAR(1..50)

Samples
7th floor
c/o Maier

Specifies an additional address line for the invoice address of the customer.

zip
optional
Format CHAR(2..50)
Permitted Symbols [0-9][A-Z][a-z][_.-/ ]

Postcode

city
optional
Format CHAR(2..50)

City of customer

country
required
Fixed Value DE
email
optional
Format CHAR(5..254)

Mandatory if "add_paydata[shopping_cart_type]=DIGITAL"

Permitted Symbols RFC 5322

Special Remark email validation:

Max. length for email is 254 characters. Validation is set up in the following way:

Username = Max. 63 characters

Domain Name = Max. 63 characters
Domain Suffixes = Max. 4 suffixes with max. 124 characters
Example: username[63]@domain_name[63].suffix[60].suffix[60].suffix[4]

"@" and "." is counted as a character as well; in case of a total of three suffixes, this would allow a total of 254 characters.

email-address of customer

telephonenumber
optional
Format CHAR(1..30)

Phone number of customer

birthday
optional
Format DATE(8), YYYYMMDD

Samples 20190101 /  19991231

Date of birth of customer

language
optional
Format LIST

Permitted values ISO 639-1 (Language)2-letter-codes

Language indicator (ISO 639) to specify the language that should be presented to the customer (e.g. for error messages, frontend display).

If the language is not transferred, the browser language will be used. For a non-supported language English will be used.

vatid
optional
Format CHAR(1..50)

VAT identification number. Used for b2b transactions to indicate VAT number of customer.

gender
optional
Format LIST

Permitted values f/ m/  d

Gender of customer (female / male / diverse* )

* currently not in use

ip
optional
Format CHAR(1..39)

Customer's IP-V4-address (123.123.123.123) or IP-V6-address

Delivery data Parameters
shipping_firstname
required
Format CHAR(1..50)

First name of delivery address

shipping_lastname
required
Format CHAR(1..50)

Surname of delivery address

shipping_company
optional
Format CHAR(2..50)

Company name of delivery address

shipping_street
optional
Format CHAR(2..50)

Street number and name of delivery address

shipping_zip
required
Format CHAR(2..50)

Postcode of delivery address

shipping_addition
optional
Format CHAR(1..50)

Specifies an additional address line for the delivery address of the customer, e.g. "7th floor", "c/o Maier".

shipping_country
optional
Format LIST

Permitted values ISO 3166 2-letter-codes

 

Samples DE/ GB/ US
 

Specifies country of address for the customer.

Some countries require additional information in parameter "state"

shipping_state
required (in CN)
Format LIST

Permitted values ISO 3166-2 States (regions)  2-letter-codes

Samples US Samples CA
AK AB
AL BC
Article Parameters
it[n]
optional
it[n] Comments
goods Goods
shipment Shipping Charges
handling Handling fee
voucher Voucher / discount

required for physical goods in order to ensure PayPal seller protection

id[n]
optional
Format CHAR(1..32)
Array Array elements [n] starting with [1]; serially numbered; max [400]Permitted Symbols [0-9][a-z][A-Z], .,-,_,/

required for physical goods in order to ensure PayPal seller protection

International Article Number (EAN bzw. GTIN)

Product number, SKU, etc. of this item

pr[n]
optional
Format NUMERIC(10) max. 19 999 999 99
Array Array elements [n] starting with [1]; serially numbered; max [400]Permitted

required for physical goods in order to ensure PayPal seller protection

Unit gross price of the item in smallest unit! e.g. cent

no[n]
optional
Format NUMERIC(6)
Array Array elements [n] starting with [1]; serially numbered; max [400]Permitted

required for physical goods in order to ensure PayPal seller protection

Quantity of this item

de[n]
optional
Format CHAR(1..255)
Array Array elements [n] starting with [1]; serially numbered; max [400]Permitted

required for physical goods in order to ensure PayPal seller protection

Description of this item. Will be printed on documents to customer.

va[n]
optional
Format NUMERIC(4)

VAT rate (% or bp)

Array elements [n] starting with [1]; serially numbered; max [400]

Paydata Parameters
add_paydata[alias]
optional
FORMAT: CHAR(255)"

Alias for postfinance alias payment

Response Parameters
Permitted Values
APPROVED
ERROR
Response Parameter (approved)
txid
Format NUMERIC(9..12)

The txid specifies the payment process within the PAYONE platform

Format NUMERIC(6..12)

PAYONE User ID, defined by PAYONE

ReSponse Parameter (Error)
Format NUMERIC(1..6)

In case of error the PAYONE Platform returns an error code for your internal usage.

Format CHAR(1..1024)

In case of error the PAYONE Platform returns an error message for your internal usage.

Host: api.pay1.de
Content-Type: application/x-www-form-urlencoded
Payload
aid=12345 mid=23456 portalid=12345123 key=abcdefghijklmn123456789 clearingtype=sb amount=6413 onlinebanktransfertype=PFF currency=CHF lastname=Master reference=youranyreference mode=test request=authorization country=CH bankcountry=CH add_paydata[alias]=youralias123456
RESPONSE
status=APPROVED txid=12345678 userid=789654
POST Request - Capture
Account Parameters
request
required
Fixed Value: capture
mid
required
your merchant ID, 5-digit numeric
aid
required
your subaccount ID, 5-digit numeric
portalId
required
your Portal ID, 7-digit numeric
key
required
your key value, alpha-numeric
common Parameters
txid
required
Format NUMERIC(9..12)

The txid specifies the payment process within the PAYONE platform

capturemode
required
Format LIST
Value Comment
completed

Set with last capture; i.e.: Delivery completed.
No further capture is allowed.

notcompleted

Set with partial deliveries (last delivery with "completed")
Another capture is expected to complete the transaction.

Specifies whether this capture is the last one or whether there will be another one in future.

sequencenumber
optional
Format NUMERIC(1..3)

Permitted values 0..127

Sequence number for this transaction within the payment process (1..n), e.g. PreAuthorization: 0, 1. Capture: 1, 2. Capture: 2

Required for multi partial capture (starting with the 2nd capture)

amount
required
Format NUMERIC(1..10)

Permitted values max. +/- 19 999 999 99

Specifies the total gross amount of a payment transaction.

Value is given in smallest currency unit, e.g. Cent of Euro; Pence of Pound sterling; Öre of Swedish krona.

The amount must be less than or equal to the amount of the corresponding booking.

currency
required
Fixed Value EUR
narrative_text
optional
Format CHAR(1..81)

Dynamic text element on account statements
(3 lines with 27 characters each) and credit card statements.

Response Parameters
Permitted Values
APPROVED
ERROR
Response Parameter (approved)
Format NUMERIC(9..12)

The txid specifies the payment process within the PAYONE platform

Format LIST
Value Comment

yes

Settlement of outstanding balances has been carried out.

no

Settlement of outstanding balances has not been carried out.

auto

The system decides - depending on type of payment and balance - if a settlement of balances can be carried out or not. (default)

Provides information about whether a settlement of balances has been carried out.

Response parameters (error)
Format NUMERIC(1..6)

In case of error the PAYONE Platform returns an error code for your internal usage.

Format CHAR(1..1024)

In case of error the PAYONE Platform returns an error message for your internal usage.

Host: api.pay1.de
Content-Type: application/x-www-form-urlencoded
Payload
mid=23456 portalid=12345123 key=abcdefghijklmn123456789 mode=test request=capture txid=345678901 amount=300 currency=CHF
RESPONSE
status=APPROVED txid=345678901 settleaccount=no
POST Request - Debit
Account Parameters
request
required
Fixed Value: debit
mid
required
your merchant ID, 5-digit numeric
aid
required
your subaccount ID, 5-digit numeric
portalId
required
your Portal ID, 7-digit numeric
key
required
your key value, alpha-numeric
common Parameters
txid
required
Format NUMERIC(9..12)

The txid specifies the payment process within the PAYONE platform

settleaccount
Format LIST
Value Comment
yes

Settlement of outstanding balances is carried out.

no

Do not carry out settlement of outstanding balances, book request only.

auto

The system decides - depending on type of payment and balance - if a settlement of balances can be carried out or not. (default)

Carry out settlement of outstanding balances. The request is booked and the resulting balance is settled by means of a collection, e.g. a refund.

sequencenumber
optional
Format NUMERIC(1..3)

Permitted values 0..127

Sequence number for this transaction within the payment process (1..n), e.g. PreAuthorization: 0, 1. Capture: 1, 2. Capture: 2

Required for multi partial capture (starting with the 2nd capture)

amount
required
Format NUMERIC(1..10)

Permitted values max. +/- 19 999 999 99

Specifies the total gross amount of a payment transaction.

Value is given in smallest currency unit, e.g. Cent of Euro; Pence of Pound sterling; Öre of Swedish krona.

The amount must be less than or equal to the amount of the corresponding booking.

currency
required
Fixed Value EUR
narrative_text
optional
Format CHAR(1..81)

Dynamic text element on account statements
(3 lines with 27 characters each) and credit card statements.

transaction_param
optional
Format CHAR(1..50)
Permitted Symbols [0-9][A-Z][a-z][.-_/]

Optional parameter for merchant information (per payment request)

Response Parameters
status
Permitted Values
APPROVED
ERROR
Response Parameter (approved)
txid
Format NUMERIC(9..12)

The txid specifies the payment process within the PAYONE platform

Format LIST
Value Comment
yes

Settlement of outstanding balances has been carried out.

no

Settlement of outstanding balances has not been carried out.

auto

The system decides - depending on type of payment and balance - if a settlement of balances can be carried out or not. (default)

Provides information about whether a settlement of balances has been carried out.

Response Parameter (error)
errorcode
Format NUMERIC(1..6)

In case of error the PAYONE Platform returns an error code for your internal usage.

errormessage
Format CHAR(1..1024)

In case of error the PAYONE Platform returns an error message for your internal usage.

customermessage
Format CHAR(1..1024)

The customermessage is returned to your system in order to be displayed to the customer.

(Language selection is based on the end customer's language, parameter "language")

Host: api.pay1.de
Content-Type: application/x-www-form-urlencoded
Payload
mid=23456 portalid=12345123 key=abcdefghijklmn123456789 api_version=3.10 mode=test request=debit txid=345678901 sequencenumber=2 amount=1000 currency=CHF
RESPONSE
status=APPROVED txid=345678901 settleaccount=no

Sequence Diagrams

Sequence Diagram of a Sale including Alias Registration

Special Case: WebView Handling in Android

If you want to show PostFinance as a payment method in your Android app, it's important to make sure to correctly configure the webview client to launch the PostFinance app when redirected to a Postfinance universal link.

Here's a code example shared by Postfinance:

private fun setUpWebViewClient() {
        binding.webView.webViewClient = object : WebViewClient() {
            override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
                Log.d(this@WebViewActivity::class.java.simpleName, "shouldOverrideUrlLoading: $url")
                if(url?.contains("universal.postfinance.ch/") == true) {
                    startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
                    return true
                }
                return false
            }

            override fun onPageFinished(view: WebView?, url: String?) = onLoadingFinished()

            override fun onReceivedError(
                view: WebView?,
                request: WebResourceRequest?,
                error: WebResourceError?
            ) = onLoadingFinished()
        }
    }