Click here to Skip to main content
15,867,991 members
Articles / Programming Languages / C#

Zeta Copos

Rate me:
Please Sign up or sign in to vote.
4.74/5 (11 votes)
3 Aug 2009CPOL2 min read 22.7K   346   10   8
A small .NET library that encapsulates calls to the payment backend provider "COPOSweb" from Germany's Commerzbank.

Introduction

When you want to sell your product to your customers through an online shop, you somehow have to enable the customers to pay for your products. There are several 3rd party companies (like e.g. Plimus) that provide those services for online shops.

Since we wanted to give the customers a single UI experience and those 3rd party solutions usually do redirects to their own servers, we searched for an alternative solution to use in the online shop for our CMS Zeta Producer.

We found a web service (no real SOAP but similar) offered by Germany's Commerzbank, called "COPOSweb".

Since no .NET interface to the COPOSweb web service existed, we developed our own wrapper/encapsulation library which is presented in this article.

Requirements for Using

In order to successfully use the library and the COPOSweb web service, you must fulfill the following requirements:

  1. Have a .NET application/online shop to actually use the library (obviously)
  2. Be a German resident (unsure; maybe they sell their services worldwide, too)
  3. Sign a contract with Commerzbank to get account data

Using the Code

The usage of the code should be rather straightforward; I have included a unit test in the source download.

To summarize a typical call to the COPOSweb web service through the ZetaCops library would look like:

C#
// Each call needs a unique ID.
var id =
    Math.Abs( Guid.NewGuid().ToString( @"N" ).GetHashCode() ).ToString();

// Create a new client instance, providing your account login data.
var copos =
    new CoposClient(
        @"https://coposweb.companydirect.de/posh/cmd/posh/tpl/txn_result.tpl",
        @"COPOSUSER",
        @"COPOSPASSWORD" );

// Charge the given credit card with the given amount.
copos.DoPaymentCreditCard(
    id,
    @"1234123412341234",
    @"123",
    new DateTime( 2014, 04, 01 ),
    Iso4277CurrencyCodeEnum.EUR,
    1.0m );

In a real-world project, the id would e.g. be your basket's unique ID and the credit card data would come from the online shop's front-end, entered by the customer. Similar, the amount and the currency depend on the product(s) being choosen by the customer to purchase.

Since it is a bad idea to hard-code your COPOSweb user name and password directly into the source code, I developed an extension that can be used inside your .NET application configuration file (usually "web.config") to configure all data through the config file only, without changing your source code.

A typical web.config file would look like:

XML
<configuration>
    <configSections>
        <section 
            name="coposClient" 
            type="ZetaCopos.CoposClientConfigurationSectionHandler, ZetaCopos" />
    </configSections>
  
    ...    
  
    <coposClient
        coposWebServiceUri="..."
        coposUserName="..."
        coposPassword="..."
        timeoutSeconds="..."
        >
        <proxy
            address="..."
            credentialsUserName="..."
            credentialsPassword="..."
            credentialsDomain="..."
            />
    </coposClient>
</configuration>

The <proxy> tag allows you to define proxy settings for calling the COPOSweb web service.

Epilog

In this article, I introduced a library to call a payment processor's backend web service. Probably the solution is rather specific and tied to the COPOSweb web service of Commerzbank. If you want to use different backends, you could at least take the source code described here as a basis for your own extensions.

We are using the library since approximately 3-4 years and have successfully processed several thousands of payments with it. So the code should be very stable and reliable.

As always, I would love to get your feedback, suggestions and enhancements. Feel free to drop me a note below in the discussions section of the article.

History

  • 2009-08-04 - First release

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Zeta Software GmbH
Germany Germany
Uwe does programming since 1989 with experiences in Assembler, C++, MFC and lots of web- and database stuff and now uses ASP.NET and C# extensively, too. He has also teached programming to students at the local university.

➡️ Give me a tip 🙂

In his free time, he does climbing, running and mountain biking. In 2012 he became a father of a cute boy and in 2014 of an awesome girl.

Some cool, free software from us:

Windows 10 Ereignisanzeige  
German Developer Community  
Free Test Management Software - Intuitive, competitive, Test Plans.  
Homepage erstellen - Intuitive, very easy to use.  
Offline-Homepage-Baukasten

Comments and Discussions

 
GeneralAwesome Pin
Marcelo Ricardo de Oliveira4-Aug-09 5:02
mvaMarcelo Ricardo de Oliveira4-Aug-09 5:02 
GeneralRe: Awesome Pin
Uwe Keim4-Aug-09 5:06
sitebuilderUwe Keim4-Aug-09 5:06 
GeneralMy vote of 1 Pin
High20064-Aug-09 1:11
High20064-Aug-09 1:11 
GeneralRe: My vote of 1 Pin
Uwe Keim4-Aug-09 1:15
sitebuilderUwe Keim4-Aug-09 1:15 
GeneralRe: My vote of 1 Pin
High20064-Aug-09 4:08
High20064-Aug-09 4:08 
GeneralRe: My vote of 1 Pin
Uwe Keim4-Aug-09 4:25
sitebuilderUwe Keim4-Aug-09 4:25 
GeneralRe: My vote of 1 Pin
Por La Chucha4-Aug-09 4:48
Por La Chucha4-Aug-09 4:48 
GeneralRe: My vote of 1 Pin
Uwe Keim4-Aug-09 4:53
sitebuilderUwe Keim4-Aug-09 4:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.