|
Introduction
We all know how horrible the LinkPoint API is. They tell me a new version will be released soon, but who knows how good it will be. The current API is so hard to deal with that it makes you want to hit your head against a rock. There has to be something better than this, right?
Background
I had to dive deep into the bloody entrails of the LinkPoint API to produce a coherent set of classes to accurately represent the chaos. It's order in a sea of turbulent I-don't-really-know-what-XML-is gateway APIs.
Using the code
This is what you're really here for. If I had more time I might be willing to talk more about the code, but here goes:
X509Certificate cert = new X509Certificate2(
@"C:\My Certificate.p12",
"My Certificate Password",
X509KeyStorageFlags.PersistKeySet
);
LinkPointGateway gateway = Factory.CreateNew(SupportedVersion.V3_5);
LinkPointTransactionInformation trans = new LinkPointTransactionInformation(
LinkPointTransactionType.Sale,
LinkPointTransactionOrigin.Internet
);
LinkPointPaymentInformation payment = new LinkPointPaymentInformation(
100.00
);
LinkPointBillingInformation billing = new LinkPointBillingInformation(
"John Doe",
"My Company",
"1234 Sesame St",
"Apt 111",
"Modesto",
USState.California,
"95206",
"(345)123-4567",
"123-456-7890",
"test@mydomain.com"
);
LinkPointShippingInformation shipping = new LinkPointShippingInformation(
LinkPointShippingMethod.TotalPrice,
null,
null,
null,
payment.Total,
0.0,
billing
);
LinkPointCreditCardInformation cc = new LinkPointCreditCardInformation(
billing.Name,
"4012888888881881",
1,
8,
"123"
);
//Here's the real work...
LinkPointResponse resp = gateway.CreditCardSale(
"staging.linkpt.net",
1129,
"MY STORE NUMBER HERE",
cert,
trans,
payment,
cc,
billing,
shipping,
null
);
if (resp.Success && resp.Error == LinkPointError.None) {
Debug.WriteLine("APPROVED!");
} else {
Debug.WriteLine(resp.Error);
Debug.WriteLine(resp.ErrorMessage);
}
That wasn't so bad was it?
History
|
 |
ASP.NET |
 |
|
|
|
| |
|