11 Dec

Ogone subscriptions implementation .Net – Create Subscription


We’ve shown you how to set up your Ogone account in our first post. In our second post we’ve created a client class which will control all Ogone request.
In our third part about Ogone subscriptions we’re finally going to show you how to create a subscription and send it to Ogone.


Create a subscription

Data you’ll be needing:

  • Your Ogone PSID: [PSID]
  • Name of the API user: [USERID]
  • Your Ogone API user password: [PSWD]
  • Credit card number: [CARDNO]
  • Credit card holder name:[CN]
  • Currency: [CURRENCY]
  • Credit card verification code: [CVC]
  • Expiry date (mmyy): [ED]
  • Buyer Email: [EMAIL]
  • A unique order Id: [ORDERID]
  • A unique subscription order Id: [SUBORDERID]
  • A unique subscription Id: [SUBID]
  • Credit card owner address (street + number): [OWNERADDRESS]
  • Credit card owner country: [OWNERCTY]
  • Credit Card owner city: [OWNERTOWN]
  • Credit Card owner Zip: [OWNERZIP]
  • Subscription amount: [SUBAMOUNT]
  • Subscription start date: [SUBPERIODMOMENT]
  • The subscription interval number: [SUBPERIODNUMBER]
  • The subscription interval (day, week, month): [SUBPERIODUNIT]
  • Subscription end date (optional): [SUBSCRIPTIONENDDATE]
  • Comment for every payment made in that subscription (optional): [SUBCOM]
  • Comment for the subscription itself (optional): [SUBCOMMENT]

You’ll also be needing a URL [URL] to post to:

  • Testing: https://secure.ogone.com/ncol/test/orderdirect_utf8.asp
  • Production: https://secure.ogone.com/ncol/prod/orderdirect_utf8.asp
Now that we have all the data, we can start implementing the code.
/// <summary>
/// Class which handles all the request send to Ogone and sends them via RemotePost.
/// </summary>
public class OgoneRequest
    /// <summary>
    /// Function which will create a subscription to Ogone with no initial payment.
    /// </summary>
    /// <returns>Dictionary with data send back by Ogone.</returns>
    public static Dictionary<string , string> CreateSubscription()
        //Initialize the RemotePost class with the URL
        var post = new RemotePost
            Url = [URL]
        //Before every subscription you have to make an initial transaction.
        //This transaction will verify the credit card data you're passing on to Ogone.
        //If you don't want your user to pay for an initial transaction, you can pass in an amount of 0.
        post.Add("AMOUNT", "0");

        post.Add("CARDNO", [CARDNO]);

        post.Add("CN", [CN]);

        //Example: USD, EUR,...
        post.Add("CURRENCY", [CURRENCY]);

        post.Add("CVC", [CVC]);

        //month + year, example: 112013
        post.Add("ED", [ED]);

        post.Add("EMAIL", [EMAIL]);

        //This operation indicates that you only want to verify the card.
        //If you'd want to do an initial payment enter SAL
        post.Add("OPERATION", "RES");

        post.Add("ORDERID", [ORDERID]);


        post.Add("OWNERCTY", [OWNERCTY]);

        post.Add("OWNERTOWN", [OWNERTOWN]);

        post.Add("OWNERZIP", [OWNERZIP]);

        post.Add("PSPID", [PSID]);

        post.Add("PSWD", [PSWD]);

        post.Add("SUBSCRIPTION_ID", [SUBID]);
        //The price should be multiplied by 100
        //Example: Price $2.23, subscription amount 223
        post.Add("SUB_AMOUNT", [SUBAMOUNT]);

        post.Add("SUB_COM", [SUBCOM]);

        post.Add("SUB_COMMENT", [SUBCOMMENT]);

        post.Add("SUB_ENDDATE", [SUBENDDATE]);

        post.Add("SUB_ORDERID", [SUBORDERID]);





        //This will set the subscription active.
        //"0" will create the subscription, but make in inactive.
        post.Add("SUB_STATUS", "1");

        post.Add("USERID", [USERID]);

                    OgoneClient.GenerateStaticHash(post.Values, true));

        return post.Post();

You can not change the order of the values since the SHA-signature is created in that particular order!


This concludes our third post. Now you should be able to create a subscription, send it to Ogone and handle their response.
Our next Ogone post will be our last. There we’ll talk about updating and deleting a Ogone subscription.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.