|
|
|
|
|
This chapter introduces the CyberSource® client for Microsoft® .NET™. The chapter includes these sections:
The purpose of the client is to enable you to access all of the CyberSource Internet Commerce SuiteSM (ICS) services by using your .NET applications. ICS services use a name-value pair API called the Simple Commerce Messaging Protocol (SCMP) API. This guide shows you how to write C# code to use those name-value pairs.
As a user of CyberSource’s ICS services, you can use the Enterprise Business Center, which offers a graphical interface where you can:
• View details about your transactions
• View and download reports (go here for tutorials and documentation about CyberSource reports)
• Process customers’ payments and credits
After you register your merchant ID with CyberSource, you can use the test version of the Enterprise Business Center at https://ebctest.cybersource.com. Once you go live, you can also use the production version at https://ebc.cybersource.com.The username and password that you use to log in to either site is your merchant ID and the password you established when you (or someone at your company) registered the merchant ID with CyberSource.
Once you have logged in to the production or test versions of the Enterprise Business Center, click the Help button on any page for context-sensitive help.
This section lists other documents that you need to integrate with CyberSource.
• Credit Card Services Implementation Guide: Describes the API fields you will be using for the CyberSource ICS Credit Card Services. Make sure when you read this guide that you read the SCMP API chapter and NOT the Simple Order API chapter.
• Reporting Developer’s Guide: Describes how to download the CyberSource reports you will be using to manage your orders.
• Implementation guides for any other ICS services you are planning to use. These are available in the documentation area of the Support Center.
• The CyberSource SDK for .NET online help provides descriptions of the classes and functions of the .NET Client. To view the online help, open Microsoft Visual Studio .NET, open your project, then place your computer’s pointer over the client’s classes and its members in the code. If the code is not visible, right-click on a Web page, then select View Code.
The following example shows how straightforward the basic code is for sending a transaction for tax calculation and processing the reply. This example is in ICSTest.cs file, located in the ICSTest directory. For more information on implementing this test code, see Running ICSTest.
Example Requesting Tax Calculation
|
using System; using System.IO; using CyberSource;
namespace ICSTest { public class ICSTest { public static void Main( string[] args ) { try { // If no argument is specified, use // ICSTest.xml in the working directory. string configFile = (args.Length > 0) ? args[0] : "ICSTest.xml";
// create and populate request ICSRequest request = new ICSRequest(); request["ics_applications"] = "ics_tax"; request["merchant_ref_number"] = "12345"; request["customer_firstname"] = "John"; request["customer_lastname"] = "Doe"; request["customer_phone"] = "6509656000"; request["customer_email"] = "nobody@cybersource.com"; request["customer_cc_number"] = "4111111111111111"; request["customer_cc_expmo"] = "12"; request["customer_cc_expyr"] = "05"; |
|
request["bill_address1"] = "1295 Charleston Road"; request["bill_city"] = "Mountain View"; request["bill_state"] = "CA"; request["bill_zip"] = "94043"; request["bill_country"] = "US"; request["offer0"] = "amount:1.43"; request["currency"] = "USD";
// print out request name-value pairs Console.WriteLine( "REQUEST:" ); foreach( NameValuePair nvp in request) { Console.WriteLine( nvp ); }
// create client and send request ICSClient client = new ICSClient( configFile ); ICSReply reply = client.Send( request );
// print out reply name-value pairs Console.WriteLine( Environment.NewLine + "REPLY:" ); foreach( NameValuePair nvp in reply) { Console.WriteLine( nvp ); } } catch (BugException e) { Console.WriteLine( Environment.NewLine + e ); } catch (ConfigIOException e) { Console.WriteLine( Environment.NewLine + e ); } catch (CriticalTransactionException e) { Console.WriteLine( Environment.NewLine + e ); |
|
} catch (NonCriticalTransactionException e) { Console.WriteLine( Environment.NewLine + e ); } finally { Console.Write( Environment.NewLine + "Press <Enter>..."); Console.Read(); } } } } |
|
|
|
|
|