mastercard mdes customer service net45 tutorial
1.0.0
Mas
이 자습서는 OpenAPI 생성기가있는 API 클라이언트 라이브러리를 생성하고 OAUTH1 서명자 LIB의 .NET 4.5 버전을 사용하여 HTTP 요청에 서명하여 .NET 4.5 앱에서 MasterCard MDES 고객 서비스를 소비하는 방법을 설명합니다.
.NET 4.5 MDES를위한 클라이언트 라이브러리 고객 서비스는 다음 명령을 사용하여 생성 할 수 있습니다.
java -jar openapi-generator-cli.jar generate -i mdes-customer-service-2.0.4.yaml -g csharp -c config.json -o mdes-customer-service-net45-tutorialconfig.json :
{
"targetFramework" : " v4.5 " ,
"packageName" : " YourApp.MdesCustomerClient "
}참조 : OpenApi Generator (실행 파일)
HintPath 요소에서 Condition="Exists('....packages')" < Reference Include = " RestSharp " >
< HintPath >....packagesRestSharp.105.1.0libnet45RestSharp.dll</ HintPath >
</ Reference >YourApp.Console 프로젝트에 다음 종속성을 추가하십시오.YourApp.MdesCustomerClientMastercard.Developer.OAuth1Signer.Core.dllMastercard.Developer.OAuth1Signer.RestSharp.dllRestSharp.dllApiClient 연장하여 JSON을 사용하십시오기본적으로 MDES 고객 서비스는 생성 된 코드가 JSON을 사용할 것으로 예상 할 때 XML 페이로드를 수락하고 반환합니다.
우리가 JSON InterceptRequest 말하는 서비스를 나타내려면, YourApp.MdesCustomerClient 프로젝트에서 새로운 클래스를 만듭니다.
using RestSharp ;
namespace YourApp . MdesCustomerClient . Client
{
/// <summary>
/// Extends the generated ApiClient class.
/// </summary>
public partial class ApiClient
{
/// <summary>
/// Adds "Format=JSON" to the RestSharp request so that the service accepts and returns JSON instead of XML.
/// </summary>
partial void InterceptRequest ( IRestRequest request ) => request . AddQueryParameter ( "Format" , "JSON" ) ;
}
} class Program
{
static void Main ( string [ ] args )
{
// The request was aborted: Could not create SSL/TLS secure channel
ServicePointManager . Expect100Continue = true ;
ServicePointManager . SecurityProtocol = SecurityProtocolType . Tls12 ;
var consumerKey = "<insert consumer key>" ;
var signingKey = SecurityUtils . LoadPrivateKey ( "<insert PKCS#12 key file path>" , "<insert key alias>" , "<insert key password>" ) ; // Pass X509KeyStoragFlags here
var config = Configuration . Default ;
config . BasePath = "https://sandbox.api.mastercard.com/mdes/csapi/v2" ;
config . ApiClient . RestClient . Authenticator = new RestSharpOAuth1Authenticator ( consumerKey , signingKey , new Uri ( config . BasePath ) ) ;
var searchApi = new SearchApi ( config ) ;
var auditInfo = new AuditInfo ( "A1435477" , "John Smith" , "Any Bank" , "5555551234" ) ;
var tokenUniqueReference = "DWSPMC00000000010906a349d9ca4eb1a4d53e3c90a11d9c" ;
var searchRequest = new SearchRequest ( null , tokenUniqueReference , null , null , null , null , null , null , auditInfo ) ;
var response = searchApi . SearchPost ( new SearchRequestSchema ( searchRequest ) ) ;
System . Console . WriteLine ( response . SearchResponse . Accounts . Account [ 0 ] . Tokens . Token [ 0 ] ) ;
System . Console . ReadLine ( ) ;
}
}consumerKey , pkcs12KeyFilePath , signingKeyAlias , signingKeyAlias 및 keyStorageFlags 사용하십시오.