public async Task <int> CreateOfferAsync(Merchant merchant, VisaOffer offer) { offer.UpdateDefaultValues(merchant); offer.ValidateOffer(merchant); await OnboardMerchantsAsync(merchant); var request = offer.GetCreateOfferRequest(merchant, VisaConstants.CommunityCodeClLevel); var policy = retryPolicy.Get(); var response = await policy.ExecuteAsync( async() => { var client = VisaRtmClientManager.Instance.GetVisaRtmClient(); //uncomment to capture using Fiddler //uncommnet line in Fiddler -- oSession["https-Client-Certificate"] = "...VisaProd.cer"; /* * var binding = client.Endpoint.Binding as BasicHttpBinding; * binding.UseDefaultWebProxy = false; * binding.ProxyAddress = new Uri("http://127.0.0.1:8888"); * binding.BypassProxyOnLocal = false; */ var response1 = await client.CreateOfferAsync(request); return(response1); } ); if (response.HasError() || response.OfferId == null || response.OfferId < 0) { //if (!response.ContainsError(VisaCallErrorConstants.DuplicateOfferName)) if (!response.ContainsError(VisaCallErrorConstants.OfferAlreadyExisitForGivenMidAndSid)) { var errorInfoDetail = response.GetErrorInfoDetail(); var offerInfo = offer.GetOfferInfo(merchant); var msg = string.Format("OfferId not returned by Visa. VisaErrorInfo:{0} OfferInfo:{1}", errorInfoDetail, offerInfo); throw new Exception(msg); } } var visaOfferId = 0; if (response.OfferId != null) { visaOfferId = response.OfferId.Value; if (merchant.ExtendedAttributes == null) { merchant.ExtendedAttributes = new Dictionary <string, string>(); } merchant.ExtendedAttributes[MerchantConstants.VisaOfferId] = visaOfferId.ToString(); } return(visaOfferId); }