private bool PayWithIyzipay(Order order, CreditCardModel card, String userId, IEnumerable <CartListModel> cart, ref string ErrorMessage, ref string PageContent, ref string ConversationId) { var user = db.Users.Find(userId); var billingCity = db.Cities.Find(order.BillingCityId).Name; var shippingCity = db.Cities.Find(order.ShippingCityId).Name; Options options = new Options(); options.ApiKey = ConfigurationManager.AppSettings["IyziApiKey"].ToString(); options.SecretKey = ConfigurationManager.AppSettings["IyziSecretKey"].ToString(); options.BaseUrl = "https://sandbox-api.iyzipay.com"; CreatePaymentRequest request = new CreatePaymentRequest(); request.Locale = Locale.TR.ToString(); request.ConversationId = order.OrderId.ToString(); request.Price = order.TotalPrice.ToString().Replace(",", "."); request.PaidPrice = order.TotalPrice.ToString().Replace(",", "."); request.Currency = Currency.TRY.ToString(); request.Installment = 1; request.BasketId = order.OrderId.ToString(); request.PaymentChannel = PaymentChannel.WEB.ToString(); request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); request.CallbackUrl = "http://" + Request.Url.Authority + "/Checkout/IyziReturn"; PaymentCard paymentCard = new PaymentCard(); paymentCard.CardHolderName = card.cardHolder; paymentCard.CardNumber = card.cardNumber; paymentCard.ExpireMonth = card.cardExpirationMonth.ToString(); paymentCard.ExpireYear = card.cardExpirationYear.ToString(); paymentCard.Cvc = card.cardCvv.ToString(); paymentCard.RegisterCard = 0; request.PaymentCard = paymentCard; Buyer buyer = new Buyer(); buyer.Id = userId; buyer.Name = order.BillingFirstName; buyer.Surname = order.BillingLastName; buyer.GsmNumber = "+90" + order.BillingTelephone; buyer.Email = order.BillingEmail; buyer.IdentityNumber = "74300864791"; buyer.LastLoginDate = String.Format("{0:yyyy-MM-dd HH:mm:ss}", user.LastLoginTime); //"2015-10-05 12:43:35"; buyer.RegistrationDate = String.Format("{0:yyyy-MM-dd HH:mm:ss}", user.RegistrationDate); //"2013-04-21 15:12:09"; buyer.RegistrationAddress = order.BillingStreet1 + " " + order.BillingStreet2; buyer.Ip = Request.UserHostAddress; buyer.City = billingCity; buyer.Country = "Turkey"; buyer.ZipCode = order.BillingZip; request.Buyer = buyer; Address shippingAddress = new Address(); shippingAddress.ContactName = order.ShippingFirstName + " " + order.ShippingLastName; shippingAddress.City = shippingCity; shippingAddress.Country = "Turkey"; shippingAddress.Description = order.ShippingStreet1 + " " + order.ShippingStreet2; shippingAddress.ZipCode = order.ShippingZip; request.ShippingAddress = shippingAddress; Address billingAddress = new Address(); billingAddress.ContactName = order.BillingFirstName + " " + order.BillingLastName; billingAddress.City = billingCity; billingAddress.Country = "Turkey"; billingAddress.Description = order.BillingStreet1 + " " + order.BillingStreet2; billingAddress.ZipCode = order.BillingZip; request.BillingAddress = billingAddress; List <BasketItem> basketItems = new List <BasketItem>(); foreach (CartListModel item in cart) { BasketItem basketItem = new BasketItem(); basketItem.Id = item.VariantId.ToString(); basketItem.Name = item.VariantName + " " + item.ProductName; basketItem.Category1 = "Giyim"; basketItem.ItemType = BasketItemType.PHYSICAL.ToString(); basketItem.Price = item.TotalPrice.ToString().Replace(",", "."); basketItems.Add(basketItem); } BasketItem shippingItem = new BasketItem(); shippingItem.Id = "K1"; shippingItem.Name = "Kargo"; shippingItem.Category1 = "Kargo"; shippingItem.ItemType = BasketItemType.VIRTUAL.ToString(); shippingItem.Price = order.ShippingCost.ToString().Replace(",", "."); basketItems.Add(shippingItem); request.BasketItems = basketItems; //Payment payment = Payment.Create(request, options); ThreedsInitialize threedsInitialize = ThreedsInitialize.Create(request, options); //PrintResponse<Payment>(payment); bool success = threedsInitialize.Status == "success"; if (!success) { ErrorMessage = threedsInitialize.ErrorMessage; } else { ConversationId = threedsInitialize.ConversationId; PageContent = threedsInitialize.HtmlContent; } return(success); }
private Payment PaymentProcess(OrderModel model) { Options options = new Options(); options.ApiKey = "defaultApiKey"; options.SecretKey = "defaultSecretKey"; options.BaseUrl = "https://sandbox-api.iyzipay.com"; CreatePaymentRequest request = new CreatePaymentRequest(); request.Locale = Locale.TR.ToString(); request.ConversationId = new Random().Next(100000000, 999999999).ToString(); request.Price = model.BasketModel.TotalPrice().ToString(); request.PaidPrice = model.BasketModel.TotalPrice().ToString(); request.Currency = Currency.TRY.ToString(); request.Installment = 1; request.BasketId = model.BasketModel.BasketId.ToString(); request.PaymentChannel = PaymentChannel.WEB.ToString(); request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); PaymentCard paymentCard = new PaymentCard(); paymentCard.CardHolderName = model.CardName; paymentCard.CardNumber = model.CardNumber; paymentCard.ExpireMonth = model.ExpirationMonth; paymentCard.ExpireYear = model.ExpirationYear; paymentCard.Cvc = model.Cvv; paymentCard.RegisterCard = 0; request.PaymentCard = paymentCard; Buyer buyer = new Buyer(); buyer.Id = _userManager.GetUserId(User); buyer.Name = model.FirstName; buyer.Surname = model.LastName; buyer.GsmNumber = model.Phone; buyer.Email = model.Email; buyer.IdentityNumber = "11111111111"; buyer.LastLoginDate = "2015-10-05 12:43:35"; buyer.RegistrationDate = "2013-04-21 15:12:09"; buyer.RegistrationAddress = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"; buyer.Ip = "85.34.78.112"; buyer.City = "Istanbul"; buyer.Country = "Turkey"; buyer.ZipCode = "34732"; request.Buyer = buyer; Address shippingAddress = new Address(); shippingAddress.ContactName = $"{model.FirstName} {model.LastName}"; shippingAddress.City = model.City; shippingAddress.Country = "Turkey"; shippingAddress.Description = model.Address; shippingAddress.ZipCode = "34742"; request.ShippingAddress = shippingAddress; Address billingAddress = new Address(); billingAddress.ContactName = $"{model.FirstName} {model.LastName}"; billingAddress.City = model.City; billingAddress.Country = "Turkey"; billingAddress.Description = model.Address; billingAddress.ZipCode = "34742"; request.BillingAddress = billingAddress; List <Iyzipay.Model.BasketItem> basketItems = new List <Iyzipay.Model.BasketItem>(); Iyzipay.Model.BasketItem basketItem; foreach (var item in model.BasketModel.BasketItems) { basketItem = new Iyzipay.Model.BasketItem() { Id = item.ProductId.ToString(), Name = item.Name, Category1 = "Telefon", ItemType = BasketItemType.PHYSICAL.ToString(), Price = (item.Price * item.Quantity).ToString() }; basketItems.Add(basketItem); } request.BasketItems = basketItems; Payment payment = Payment.Create(request, options); return(payment); }
public static void Run(IReadOnlyDictionary <string, string> configDictionary) { var requestObj = new CreatePaymentRequest(); var v2PaymentsClientReferenceInformationObj = new V2paymentsClientReferenceInformation { Code = "TC1102345" }; requestObj.ClientReferenceInformation = v2PaymentsClientReferenceInformationObj; var deviceInformationObj = new V2paymentsDeviceInformation { HostName = "cybersource.com", IpAddress = "66.185.179.2" }; requestObj.DeviceInformation = deviceInformationObj; var v2PaymentsProcessingInformationObj = new V2paymentsProcessingInformation(); var authorizationOptionsObj = new V2paymentsProcessingInformationAuthorizationOptions { IgnoreAvsResult = true, IgnoreCvResult = false }; v2PaymentsProcessingInformationObj.AuthorizationOptions = authorizationOptionsObj; requestObj.ProcessingInformation = v2PaymentsProcessingInformationObj; var buyerInformationObj = new V2paymentsBuyerInformation(); var list = new List <V2paymentsBuyerInformationPersonalIdentification>(); var personalIdentificationObj = new V2paymentsBuyerInformationPersonalIdentification { Id = "123* 4sÆ" }; list.Add(personalIdentificationObj); buyerInformationObj.PersonalIdentification = list; requestObj.BuyerInformation = buyerInformationObj; var v2PaymentsOrderInformationObj = new V2paymentsOrderInformation(); var v2PaymentsOrderInformationBillToObj = new V2paymentsOrderInformationBillTo { Country = "US", LastName = "Deo", Address2 = "test", Address1 = "201 S. Division St.", PostalCode = "48104-2201", Locality = "Ann Arbor", AdministrativeArea = "MI", FirstName = "John", PhoneNumber = "999999999", District = "MI", BuildingNumber = "123", Company = "Visa", Email = "*****@*****.**" }; v2PaymentsOrderInformationObj.BillTo = v2PaymentsOrderInformationBillToObj; var amountDetailsObj = new V2paymentsOrderInformationAmountDetails { TotalAmount = "2531", Currency = "usd" }; v2PaymentsOrderInformationObj.AmountDetails = amountDetailsObj; requestObj.OrderInformation = v2PaymentsOrderInformationObj; var v2PaymentsPaymentInformationObj = new V2paymentsPaymentInformation(); var v2PaymentsPaymentInformationCardObj = new V2paymentsPaymentInformationCard { ExpirationYear = "2031", Number = "372425119311008", SecurityCode = "1111", ExpirationMonth = "12", Type = "003", SecurityCodeIndicator = "1" }; v2PaymentsPaymentInformationObj.Card = v2PaymentsPaymentInformationCardObj; requestObj.PaymentInformation = v2PaymentsPaymentInformationObj; var merchantConfig = new MerchantConfig(configDictionary) { RequestType = "POST", RequestTarget = "/pts/v2/payments", RequestJsonData = JsonConvert.SerializeObject(requestObj) }; try { var configurationSwagger = new ApiClient().CallAuthenticationHeader(merchantConfig); var apiInstance = new PaymentApi(configurationSwagger); var result = apiInstance.CreatePayment(requestObj); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API: " + e.Message); } }
/// <summary> /// This method is for user story 1 /// </summary> /// <param name="createPaymentRequest"></param> /// <returns></returns> public CreatePaymentResponse CreatePayment(CreatePaymentRequest createPaymentRequest) { return((CreatePaymentResponse) new CreatePaymentBL(PaymentValidatorService).ExecuteAction(createPaymentRequest)); }
/// <summary> /// Process a Payment A payment authorizes the amount for the transaction. There are a number of supported payment feature, such as E-commerce and Card Present - Credit Card/Debit Card, Echeck, e-Wallets, Level II/III Data, etc.. A payment response includes the status of the request. It also includes processor-specific information when the request is successful and errors if unsuccessful. See the [Payments Developer Guides Page](https://developer.cybersource.com/api/developer-guides/dita-payments/GettingStarted.html). Authorization can be requested with Capture, Decision Manager, Payer Authentication(3ds), and Token Creation. Find more on [Authorization with Add-On Features page.] (https://developer.cybersource.com/api/authorization-add-ons.html) Possible [RESPONSE CODES](https://developer.cybersource.com/api/reference/response-codes.html) . Processor specific [Testing Triggers](https://developer.cybersource.com/hello-world/testing-guide.html). /// </summary> /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="createPaymentRequest"></param> /// <returns>Task of ApiResponse (PtsV2PaymentsPost201Response)</returns> public async System.Threading.Tasks.Task <ApiResponse <PtsV2PaymentsPost201Response> > CreatePaymentAsyncWithHttpInfo(CreatePaymentRequest createPaymentRequest) { // verify the required parameter 'createPaymentRequest' is set if (createPaymentRequest == null) { throw new ApiException(400, "Missing required parameter 'createPaymentRequest' when calling PaymentsApi->CreatePayment"); } var localVarPath = $"/pts/v2/payments"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new Dictionary <String, String>(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json;charset=utf-8" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/hal+json;charset=utf-8" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (createPaymentRequest != null && createPaymentRequest.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(createPaymentRequest); // http body (model) parameter } else { localVarPostBody = createPaymentRequest; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("CreatePayment", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <PtsV2PaymentsPost201Response>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (PtsV2PaymentsPost201Response)Configuration.ApiClient.Deserialize(localVarResponse, typeof(PtsV2PaymentsPost201Response)))); // Return statement }
public void Should_Create_Payment_With_Registered_Card() { CreatePaymentRequest request = new CreatePaymentRequest(); request.Locale = Locale.TR.ToString(); request.ConversationId = "123456789"; request.Price = "1"; request.PaidPrice = "1.2"; request.Currency = Currency.TRY.ToString(); request.Installment = 1; request.BasketId = "B67832"; request.PaymentChannel = PaymentChannel.WEB.ToString(); request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); PaymentCard paymentCard = new PaymentCard(); paymentCard.CardUserKey = "card user key"; paymentCard.CardToken = "card token"; request.PaymentCard = paymentCard; Buyer buyer = new Buyer(); buyer.Id = "BY789"; buyer.Name = "John"; buyer.Surname = "Doe"; buyer.GsmNumber = "+905350000000"; buyer.Email = "*****@*****.**"; buyer.IdentityNumber = "74300864791"; buyer.LastLoginDate = "2015-10-05 12:43:35"; buyer.RegistrationDate = "2013-04-21 15:12:09"; buyer.RegistrationAddress = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"; buyer.Ip = "85.34.78.112"; buyer.City = "Istanbul"; buyer.Country = "Turkey"; buyer.ZipCode = "34732"; request.Buyer = buyer; Address shippingAddress = new Address(); shippingAddress.ContactName = "Jane Doe"; shippingAddress.City = "Istanbul"; shippingAddress.Country = "Turkey"; shippingAddress.Description = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"; shippingAddress.ZipCode = "34742"; request.ShippingAddress = shippingAddress; Address billingAddress = new Address(); billingAddress.ContactName = "Jane Doe"; billingAddress.City = "Istanbul"; billingAddress.Country = "Turkey"; billingAddress.Description = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"; billingAddress.ZipCode = "34742"; request.BillingAddress = billingAddress; List <BasketItem> basketItems = new List <BasketItem>(); BasketItem firstBasketItem = new BasketItem(); firstBasketItem.Id = "BI101"; firstBasketItem.Name = "Binocular"; firstBasketItem.Category1 = "Collectibles"; firstBasketItem.Category2 = "Accessories"; firstBasketItem.ItemType = BasketItemType.PHYSICAL.ToString(); firstBasketItem.Price = "0.3"; basketItems.Add(firstBasketItem); BasketItem secondBasketItem = new BasketItem(); secondBasketItem.Id = "BI102"; secondBasketItem.Name = "Game code"; secondBasketItem.Category1 = "Game"; secondBasketItem.Category2 = "Online Game Items"; secondBasketItem.ItemType = BasketItemType.VIRTUAL.ToString(); secondBasketItem.Price = "0.5"; basketItems.Add(secondBasketItem); BasketItem thirdBasketItem = new BasketItem(); thirdBasketItem.Id = "BI103"; thirdBasketItem.Name = "Usb"; thirdBasketItem.Category1 = "Electronics"; thirdBasketItem.Category2 = "Usb / Cable"; thirdBasketItem.ItemType = BasketItemType.PHYSICAL.ToString(); thirdBasketItem.Price = "0.2"; basketItems.Add(thirdBasketItem); request.BasketItems = basketItems; Payment payment = Payment.Create(request, options); PrintResponse <Payment>(payment); Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); Assert.AreEqual(Locale.TR.ToString(), payment.Locale); Assert.AreEqual("123456789", payment.ConversationId); Assert.IsNotNull(payment.SystemTime); Assert.IsNull(payment.ErrorCode); Assert.IsNull(payment.ErrorMessage); Assert.IsNull(payment.ErrorGroup); }
private Payment PaymentProcess(OrderModel model) { Options options = new Options(); options.ApiKey = "sandbox-rQch8hnDtHwbsrS1PeYhcKRLpbNPRFvr"; options.SecretKey = "sandbox-A78oE89WVYT8bfOzCuiiLGDIN3fB4oC2"; options.BaseUrl = "https://sandbox-api.iyzipay.com"; CreatePaymentRequest request = new CreatePaymentRequest(); request.Locale = Locale.TR.ToString(); request.ConversationId = new Random().Next(100000000, 999999999).ToString(); request.Price = model.CartModel.CartTotal().ToString("0.00", System.Globalization.CultureInfo.InvariantCulture); request.PaidPrice = model.CartModel.CartTotal().ToString("0.00", System.Globalization.CultureInfo.InvariantCulture); request.Currency = Currency.TRY.ToString(); request.Installment = 1; request.BasketId = new Random().Next(100000000, 999999999).ToString(); request.PaymentChannel = PaymentChannel.WEB.ToString(); request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); PaymentCard paymentCard = new PaymentCard(); paymentCard.CardHolderName = model.CardName; paymentCard.CardNumber = model.CardNumber; paymentCard.ExpireMonth = model.ExpirationMonth; paymentCard.ExpireYear = model.ExpirationYear; paymentCard.Cvc = model.Cvc; paymentCard.RegisterCard = 0; request.PaymentCard = paymentCard; //---------Card number for try ------------------------// // paymentCard.CardNumber = "5528790000000008"; // paymentCard.ExpireMonth = "12"; // paymentCard.ExpireYear = "2030"; // paymentCard.Cvc = "123"; Buyer buyer = new Buyer(); buyer.Id = new Random().Next(111111111, 999999999).ToString(); buyer.Name = model.FirstName; buyer.Surname = model.LastName; buyer.GsmNumber = "+90" + model.Phone; buyer.Email = model.Email; buyer.IdentityNumber = "Tc Kimlik No İstenmiyor."; buyer.RegistrationAddress = model.Address; buyer.Ip = Request.HttpContext.Connection.RemoteIpAddress.ToString(); buyer.City = model.City; buyer.Country = "Türkiye"; buyer.ZipCode = model.ZipCode; request.Buyer = buyer; Address shippingAddress = new Address(); shippingAddress.ContactName = model.FirstName + " " + model.LastName; shippingAddress.City = model.City; shippingAddress.Country = "Türkiye"; shippingAddress.Description = model.Address; shippingAddress.ZipCode = model.ZipCode; request.ShippingAddress = shippingAddress; Address billingAddress = new Address(); billingAddress.ContactName = model.FirstName + " " + model.LastName; billingAddress.City = model.City; billingAddress.Country = "Türkiye"; billingAddress.Description = model.Address; billingAddress.ZipCode = model.ZipCode; request.BillingAddress = billingAddress; List <BasketItem> basketItems = new List <BasketItem>(); BasketItem basketItem; foreach (var item in model.CartModel.CartItems) { basketItem = new BasketItem(); basketItem.Id = item.CartItemId.ToString(); basketItem.Name = item.Name; var price = item.Price.Value * item.Quantity; if (basketItems.Count == model.CartModel.CartItems.Count) { price = price + model.CartModel.CargoPrice; } basketItem.Price = price.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture); basketItem.ItemType = BasketItemType.PHYSICAL.ToString(); basketItem.Category1 = _productService.GetByIdWithCategories(item.ProductId).ProductCategories.Where(i => i.ProductId == item.ProductId).Select(i => i.Category.Name) .FirstOrDefault().ToString(); basketItems.Add(basketItem); Console.WriteLine(basketItem.Category1); } request.BasketItems = basketItems; return(Payment.Create(request, options)); }
/// <summary> /// Process a Payment A payment authorizes the amount for the transaction. There are a number of supported payment feature, such as E-commerce and Card Present - Credit Card/Debit Card, Echeck, e-Wallets, Level II/III Data, etc.. A payment response includes the status of the request. It also includes processor-specific information when the request is successful and errors if unsuccessful. See the [Payments Developer Guides Page](https://developer.cybersource.com/api/developer-guides/dita-payments/GettingStarted.html). Authorization can be requested with Capture, Decision Manager, Payer Authentication(3ds), and Token Creation. Find more on [Authorization with Add-On Features page.] (https://developer.cybersource.com/api/authorization-add-ons.html) Possible [RESPONSE CODES](https://developer.cybersource.com/api/reference/response-codes.html) . Processor specific [Testing Triggers](https://developer.cybersource.com/hello-world/testing-guide.html). /// </summary> /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="createPaymentRequest"></param> /// <returns>PtsV2PaymentsPost201Response</returns> public PtsV2PaymentsPost201Response CreatePayment(CreatePaymentRequest createPaymentRequest) { ApiResponse <PtsV2PaymentsPost201Response> localVarResponse = CreatePaymentWithHttpInfo(createPaymentRequest); return(localVarResponse.Data); }
public static PtsV2PaymentsPost201Response Run() { string clientReferenceInformationCode = "TC50171_16"; Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( Code: clientReferenceInformationCode ); List <string> processingInformationActionList = new List <string>(); processingInformationActionList.Add("DECISION"); bool processingInformationCapture = false; Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( ActionList: processingInformationActionList, Capture: processingInformationCapture ); string paymentInformationCardNumber = "4111111111111111"; string paymentInformationCardExpirationMonth = "11"; string paymentInformationCardExpirationYear = "2025"; Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( Number: paymentInformationCardNumber, ExpirationMonth: paymentInformationCardExpirationMonth, ExpirationYear: paymentInformationCardExpirationYear ); Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( Card: paymentInformationCard ); string orderInformationAmountDetailsTotalAmount = "10"; string orderInformationAmountDetailsCurrency = "USD"; Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( TotalAmount: orderInformationAmountDetailsTotalAmount, Currency: orderInformationAmountDetailsCurrency ); string orderInformationBillToFirstName = "John"; string orderInformationBillToLastName = "Doe"; string orderInformationBillToAddress1 = "1 Market St"; string orderInformationBillToLocality = "san francisco"; string orderInformationBillToAdministrativeArea = "CA"; string orderInformationBillToPostalCode = "94105"; string orderInformationBillToCountry = "US"; string orderInformationBillToEmail = "*****@*****.**"; string orderInformationBillToPhoneNumber = "4158880000"; Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( FirstName: orderInformationBillToFirstName, LastName: orderInformationBillToLastName, Address1: orderInformationBillToAddress1, Locality: orderInformationBillToLocality, AdministrativeArea: orderInformationBillToAdministrativeArea, PostalCode: orderInformationBillToPostalCode, Country: orderInformationBillToCountry, Email: orderInformationBillToEmail, PhoneNumber: orderInformationBillToPhoneNumber ); Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( AmountDetails: orderInformationAmountDetails, BillTo: orderInformationBillTo ); var requestObj = new CreatePaymentRequest( ClientReferenceInformation: clientReferenceInformation, ProcessingInformation: processingInformation, PaymentInformation: paymentInformation, OrderInformation: orderInformation ); try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new PaymentsApi(clientConfig); PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); Console.WriteLine(result); return(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API : " + e.Message); return(null); } }
static async Task Main(string[] args) { try { string paymentProductId = string.Empty; do { Console.WriteLine("Enter Payment Product Code"); Console.WriteLine("Code | Card Type"); Console.WriteLine("1 | Visa"); Console.WriteLine("2 | Master Card"); paymentProductId = Console.ReadLine(); } while (string.IsNullOrWhiteSpace(paymentProductId) || !new string[] { "1", "2" }.ToList().Contains(paymentProductId)); Card card = new Card(); card.CardNumber = "4567350000427977"; card.Cvv = "123"; card.ExpiryDate = "1220"; ThreeDSecure threeDSecure = new ThreeDSecure(); threeDSecure.SkipAuthentication = false; CardPaymentMethodSpecificInput cardPaymentMethodSpecificInput = new CardPaymentMethodSpecificInput(); cardPaymentMethodSpecificInput.Card = card; cardPaymentMethodSpecificInput.PaymentProductId = paymentProductId == "2" ? 3 : 1; cardPaymentMethodSpecificInput.ThreeDSecure = threeDSecure; AmountOfMoney amountOfMoney = new AmountOfMoney(); amountOfMoney.Amount = 1; amountOfMoney.CurrencyCode = "USD"; Address billingAddress = new Address(); billingAddress.CountryCode = "US"; Customer customer = new Customer(); customer.BillingAddress = billingAddress; customer.MerchantCustomerId = "1378"; Order order = new Order(); order.AmountOfMoney = amountOfMoney; order.Customer = customer; CreatePaymentRequest body = new CreatePaymentRequest(); body.CardPaymentMethodSpecificInput = cardPaymentMethodSpecificInput; body.Order = order; try { using (Client client = GetClient()) { CreatePaymentResponse response = await client.Merchant("1378").Payments().Create(body); Console.WriteLine("Id: " + response.Payment.Id); Console.WriteLine("Status: " + response.Payment.Status); Console.WriteLine("AmountOfMoney: " + response.Payment.PaymentOutput.AmountOfMoney); } } catch (DeclinedPaymentException e) { Console.WriteLine("Error: Payment Declined"); foreach (var error in e.Errors) { Console.WriteLine("Code: " + error.Code); Console.WriteLine("PropertyName: " + error.PropertyName); Console.WriteLine("Message: " + error.Message); } } catch (ApiException e) { Console.WriteLine("Error: Unknown error occured"); foreach (var error in e.Errors) { Console.WriteLine("Code: " + error.Code); Console.WriteLine("PropertyName: " + error.PropertyName); Console.WriteLine("Message: " + error.Message); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }
private Payment PaymentProcess(OrderModel model) { Options options = new Options(); options.ApiKey = "sandbox-h23CxE4zhg3Di0tvOCVon3G3V6qDsmpb"; options.SecretKey = "sandbox-U9atJ76zQyGKBSX7fIN4mVPjBSdOGad6"; options.BaseUrl = "https://sandbox-api.iyzipay.com"; CreatePaymentRequest request = new CreatePaymentRequest(); request.Locale = Locale.TR.ToString(); request.ConversationId = Guid.NewGuid().ToString(); request.Price = model.CartModel.TotalPrice().ToString().Split(",")[0];; request.PaidPrice = model.CartModel.TotalPrice().ToString().Split(",")[0];; request.Currency = Currency.TRY.ToString(); request.Installment = 1; request.BasketId = model.CartModel.CartId.ToString(); request.PaymentChannel = PaymentChannel.WEB.ToString(); request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); PaymentCard paymentCard = new PaymentCard(); paymentCard.CardHolderName = model.CardName; paymentCard.CardNumber = model.CardNumber; paymentCard.ExpireMonth = model.ExpirationMonth; paymentCard.ExpireYear = model.ExpirationYear; paymentCard.Cvc = model.Cvv; paymentCard.RegisterCard = 0; request.PaymentCard = paymentCard; //paymentCard.CardHolderName = "John Doe"; //paymentCard.CardNumber = "5528790000000008"; //paymentCard.ExpireMonth = "12"; //paymentCard.ExpireYear = "2030"; //paymentCard.Cvc = "123"; Buyer buyer = new Buyer(); buyer.Id = "BY789"; buyer.Name = "John"; buyer.Surname = "Doe"; buyer.GsmNumber = "+905350000000"; buyer.Email = "*****@*****.**"; buyer.IdentityNumber = "74300864791"; buyer.LastLoginDate = "2015-10-05 12:43:35"; buyer.RegistrationDate = "2013-04-21 15:12:09"; buyer.RegistrationAddress = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"; buyer.Ip = "85.34.78.112"; buyer.City = "Istanbul"; buyer.Country = "Turkey"; buyer.ZipCode = "34732"; request.Buyer = buyer; Address shippingAddress = new Address(); shippingAddress.ContactName = "Jane Doe"; shippingAddress.City = "Istanbul"; shippingAddress.Country = "Turkey"; shippingAddress.Description = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"; shippingAddress.ZipCode = "34742"; request.ShippingAddress = shippingAddress; Address billingAddress = new Address(); billingAddress.ContactName = "Jane Doe"; billingAddress.City = "Istanbul"; billingAddress.Country = "Turkey"; billingAddress.Description = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"; billingAddress.ZipCode = "34742"; request.BillingAddress = billingAddress; List <BasketItem> basketItems = new List <BasketItem>(); BasketItem basketItem; foreach (var item in model.CartModel.CartItems) { basketItem = new BasketItem(); basketItem.Id = item.ProductId.ToString(); basketItem.Name = item.Name; basketItem.Category1 = "Phone"; basketItem.ItemType = BasketItemType.PHYSICAL.ToString(); basketItem.Price = item.Price.ToString().Split(",")[0]; basketItems.Add(basketItem); } request.BasketItems = basketItems; return(Payment.Create(request, options)); }
public async Task TestLoggingCreatePayment() { // POST with a success (201) response TestLogger logger = new TestLogger(); using (MockServer host = new MockServer(Port, "/v1/1234/payments", (request, response, arg3) => { AssignResponse((HttpStatusCode)201, new Dictionary <string, string>(), response, "http://localhost/v1/1234/payments/000000123410000595980000100001"); return(createPaymentJson); })) using (Client client = CreateClient()) { client.EnableLogging(logger); AmountOfMoney amountOfMoney = new AmountOfMoney(); amountOfMoney.CurrencyCode = "CAD"; amountOfMoney.Amount = 2345L; Address billingAddress = new Address(); billingAddress.CountryCode = "CA"; Customer customer = new Customer(); customer.BillingAddress = billingAddress; Order order = new Order(); order.AmountOfMoney = amountOfMoney; order.Customer = customer; Card card = new Card(); card.Cvv = "123"; card.CardNumber = "1234567890123456"; card.ExpiryDate = "1220"; CardPaymentMethodSpecificInput paymentMethodSpecificInput = new CardPaymentMethodSpecificInput(); paymentMethodSpecificInput.PaymentProductId = 1; paymentMethodSpecificInput.Card = card; CreatePaymentRequest request = new CreatePaymentRequest(); request.Order = order; request.CardPaymentMethodSpecificInput = paymentMethodSpecificInput; CreatePaymentResponse response = await client.Merchant("1234").Payments().Create(request); Assert.NotNull(response); Assert.NotNull(response.Payment); Assert.NotNull(response.Payment.Id); } Assert.That(logger.Entries, Has.Count.EqualTo(2)); TestLoggerEntry requestEntry = logger.Entries.First(); Assert.That(requestEntry.Message, Is.Not.Null); Assert.That(requestEntry.Thrown, Is.Null); TestLoggerEntry responseEntry = logger.Entries.ElementAt(1); Assert.That(responseEntry.Message, Is.Not.Null); Assert.That(responseEntry.Thrown, Is.Null); AssertRequestAndResponse(requestEntry.Message, responseEntry.Message, createPaymentRequest, createPaymentResponse); }
public void Should_Create_Physical_And_Virtual_Listing_Or_Subscription_Payment() { CreatePaymentRequest request = new CreatePaymentRequest(); request.Locale = Locale.TR.GetName(); request.ConversationId = "123456789"; request.Price = "1"; request.PaidPrice = "1.1"; request.Installment = 1; request.BasketId = "B67832"; request.PaymentGroup = PaymentGroup.SUBSCRIPTION.ToString(); request.PaymentChannel = PaymentChannel.WEB.ToString(); PaymentCard paymentCard = new PaymentCard(); paymentCard.CardHolderName = "John Doe"; paymentCard.CardNumber = "5528790000000008"; paymentCard.RegisterCard = 0; paymentCard.ExpireMonth = "11"; paymentCard.ExpireYear = "2017"; paymentCard.Cvc = "123"; request.PaymentCard = paymentCard; Buyer buyer = new Buyer(); buyer.Id = "BY789"; buyer.Name = "Sabri Onur"; buyer.Surname = "Tüzün"; buyer.GsmNumber = "+905350000000"; buyer.Email = "*****@*****.**"; buyer.IdentityNumber = "74300864791"; buyer.LastLoginDate = "2015-10-05 12:43:35"; buyer.RegistrationDate = "2013-04-21 15:12:09"; buyer.RegistrationAddress = "Nidakule Göztepe İş Merkezi Merdivenköy Mah. Bora Sok. No:1 Kat:19 Bağımsız 70/73 Göztepe Kadıköy"; buyer.Ip = "85.34.78.112"; buyer.City = "İstanbul"; buyer.Country = "Türkiye"; buyer.ZipCode = "34732"; request.Buyer = buyer; Address shippingAddress = new Address(); shippingAddress.ContactName = "Hakan Erdoğan"; shippingAddress.City = "İstanbul"; shippingAddress.Country = "Türkiye"; shippingAddress.Description = "19 Mayıs Mah. İnönü Cad. No:45 Kozyatağı"; shippingAddress.ZipCode = "34742"; request.ShippingAddress = shippingAddress; Address billingAddress = new Address(); billingAddress.ContactName = "Hakan Erdoğan"; billingAddress.City = "İstanbul"; billingAddress.Country = "Türkiye"; billingAddress.Description = "19 Mayıs Mah. İnönü Cad. No:45 Kozyatağı"; billingAddress.ZipCode = "34742"; request.BillingAddress = billingAddress; List <BasketItem> basketItems = new List <BasketItem>(); BasketItem basketItem1 = new BasketItem(); basketItem1.Id = "BI101"; basketItem1.Name = "Dükkan aboneliği ve katalog"; basketItem1.Category1 = "Abonelik"; basketItem1.Category2 = "Dükkan"; basketItem1.ItemType = BasketItemType.PHYSICAL.ToString(); basketItem1.Price = "0.3"; basketItems.Add(basketItem1); BasketItem basketItem2 = new BasketItem(); basketItem2.Id = "BI102"; basketItem2.Name = "Listeleme aboneliği"; basketItem2.Category1 = "Abonelik"; basketItem2.Category2 = "Listeleme"; basketItem1.ItemType = BasketItemType.VIRTUAL.ToString(); basketItem1.Price = "0.5"; basketItems.Add(basketItem2); BasketItem basketItem3 = new BasketItem(); basketItem3.Id = "BI103"; basketItem3.Name = "Servis aboneliği"; basketItem3.Category1 = "Abonelik"; basketItem3.Category2 = "Servis"; basketItem1.ItemType = BasketItemType.VIRTUAL.ToString(); basketItem1.Price = "0.2"; basketItems.Add(basketItem3); request.BasketItems = basketItems; PaymentPreAuth paymentPreAuth = PaymentPreAuth.Create(request, options); PrintResponse <PaymentPreAuth>(paymentPreAuth); Assert.IsNotNull(paymentPreAuth.SystemTime); Assert.AreEqual(Status.SUCCESS.ToString(), paymentPreAuth.Status); Assert.AreEqual(Locale.TR.GetName(), paymentPreAuth.Locale); Assert.AreEqual("123456789", paymentPreAuth.ConversationId); }
/// <remarks/> public void CreatePaymentAsync(CreatePaymentRequest CreatePaymentRequest) { this.CreatePaymentAsync(CreatePaymentRequest, null); }
public static PtsV2PaymentsPost201Response Run() { string clientReferenceInformationCode = "54323007"; Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( Code: clientReferenceInformationCode ); string paymentInformationCardNumber = "4444444444444448"; string paymentInformationCardExpirationMonth = "12"; string paymentInformationCardExpirationYear = "2020"; Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( Number: paymentInformationCardNumber, ExpirationMonth: paymentInformationCardExpirationMonth, ExpirationYear: paymentInformationCardExpirationYear ); Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( Card: paymentInformationCard ); string orderInformationAmountDetailsTotalAmount = "144.14"; string orderInformationAmountDetailsCurrency = "USD"; Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( TotalAmount: orderInformationAmountDetailsTotalAmount, Currency: orderInformationAmountDetailsCurrency ); string orderInformationBillToFirstName = "James"; string orderInformationBillToLastName = "Smith"; string orderInformationBillToAddress1 = "96, powers street"; string orderInformationBillToLocality = "Clearwater milford"; string orderInformationBillToAdministrativeArea = "NH"; string orderInformationBillToPostalCode = "03055"; string orderInformationBillToCountry = "US"; string orderInformationBillToEmail = "*****@*****.**"; string orderInformationBillToPhoneNumber = "7606160717"; Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( FirstName: orderInformationBillToFirstName, LastName: orderInformationBillToLastName, Address1: orderInformationBillToAddress1, Locality: orderInformationBillToLocality, AdministrativeArea: orderInformationBillToAdministrativeArea, PostalCode: orderInformationBillToPostalCode, Country: orderInformationBillToCountry, Email: orderInformationBillToEmail, PhoneNumber: orderInformationBillToPhoneNumber ); string orderInformationShipToFirstName = "James"; string orderInformationShipToLastName = "Smith"; string orderInformationShipToAddress1 = "96, powers street"; string orderInformationShipToLocality = "Clearwater milford"; string orderInformationShipToAdministrativeArea = "KA"; string orderInformationShipToPostalCode = "560056"; string orderInformationShipToCountry = "IN"; string orderInformationShipToPhoneNumber = "7606160717"; Ptsv2paymentsOrderInformationShipTo orderInformationShipTo = new Ptsv2paymentsOrderInformationShipTo( FirstName: orderInformationShipToFirstName, LastName: orderInformationShipToLastName, Address1: orderInformationShipToAddress1, Locality: orderInformationShipToLocality, AdministrativeArea: orderInformationShipToAdministrativeArea, PostalCode: orderInformationShipToPostalCode, Country: orderInformationShipToCountry, PhoneNumber: orderInformationShipToPhoneNumber ); Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( AmountDetails: orderInformationAmountDetails, BillTo: orderInformationBillTo, ShipTo: orderInformationShipTo ); var requestObj = new CreatePaymentRequest( ClientReferenceInformation: clientReferenceInformation, PaymentInformation: paymentInformation, OrderInformation: orderInformation ); try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new PaymentsApi(clientConfig); PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); Console.WriteLine(result); return(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API : " + e.Message); return(null); } }
public void Should_Create_Market_Place_Non_Threeds_Physical_And_Virtual_Product_Payment() { CreatePaymentRequest request = new CreatePaymentRequest(); request.Locale = Locale.TR.GetName(); request.ConversationId = "123456789"; request.Price = "1"; request.PaidPrice = "1.1"; request.Installment = 1; request.BasketId = "B67832"; request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); request.PaymentChannel = PaymentChannel.WEB.ToString(); PaymentCard paymentCard = new PaymentCard(); paymentCard.CardHolderName = "John Doe"; paymentCard.CardNumber = "5528790000000008"; paymentCard.RegisterCard = 0; paymentCard.ExpireMonth = "11"; paymentCard.ExpireYear = "2017"; paymentCard.Cvc = "123"; request.PaymentCard = paymentCard; Buyer buyer = new Buyer(); buyer.Id = "BY789"; buyer.Name = "Sabri Onur"; buyer.Surname = "Tüzün"; buyer.GsmNumber = "+905350000000"; buyer.Email = "*****@*****.**"; buyer.IdentityNumber = "74300864791"; buyer.LastLoginDate = "2015-10-05 12:43:35"; buyer.RegistrationDate = "2013-04-21 15:12:09"; buyer.RegistrationAddress = "Nidakule Göztepe İş Merkezi Merdivenköy Mah. Bora Sok. No:1 Kat:19 Bağımsız 70/73 Göztepe Kadıköy"; buyer.Ip = "85.34.78.112"; buyer.City = "İstanbul"; buyer.Country = "Türkiye"; buyer.ZipCode = "34732"; request.Buyer = buyer; Address shippingAddress = new Address(); shippingAddress.ContactName = "Hakan Erdoğan"; shippingAddress.City = "İstanbul"; shippingAddress.Country = "Türkiye"; shippingAddress.Description = "19 Mayıs Mah. İnönü Cad. No:45 Kozyatağı"; shippingAddress.ZipCode = "34742"; request.ShippingAddress = shippingAddress; Address billingAddress = new Address(); billingAddress.ContactName = "Hakan Erdoğan"; billingAddress.City = "İstanbul"; billingAddress.Country = "Türkiye"; billingAddress.Description = "19 Mayıs Mah. İnönü Cad. No:45 Kozyatağı"; billingAddress.ZipCode = "34742"; request.BillingAddress = billingAddress; List <BasketItem> basketItems = new List <BasketItem>(); BasketItem basketItem1 = new BasketItem(); basketItem1.Id = "BI101"; basketItem1.Name = "ABC Marka Kolye"; basketItem1.Category1 = "Giyim"; basketItem1.Category2 = "Aksesuar"; basketItem1.ItemType = BasketItemType.PHYSICAL.ToString(); basketItem1.Price = "0.3"; basketItem1.SubMerchantKey = "subMerchantKey"; basketItem1.SubMerchantPrice = "0.27"; basketItems.Add(basketItem1); BasketItem basketItem2 = new BasketItem(); basketItem2.Id = "BI102"; basketItem2.Name = "XYZ Oyun Kodu"; basketItem2.Category1 = "Oyun"; basketItem2.Category2 = "Online Oyun Kodları"; basketItem2.ItemType = BasketItemType.VIRTUAL.ToString(); basketItem2.Price = "0.5"; basketItem2.SubMerchantKey = "subMerchantKey"; basketItem2.SubMerchantPrice = "0.42"; basketItems.Add(basketItem2); BasketItem basketItem3 = new BasketItem(); basketItem3.Id = "BI103"; basketItem3.Name = "EDC Marka Usb"; basketItem3.Category1 = "Elektronik"; basketItem3.Category2 = "Usb / Cable"; basketItem3.ItemType = BasketItemType.PHYSICAL.ToString(); basketItem3.Price = "0.2"; basketItem3.SubMerchantKey = "subMerchantKey"; basketItem3.SubMerchantPrice = "0.18"; basketItems.Add(basketItem3); request.BasketItems = basketItems; PaymentPreAuth paymentPreAuth = PaymentPreAuth.Create(request, options); PrintResponse <PaymentPreAuth>(paymentPreAuth); Assert.IsNotNull(paymentPreAuth.SystemTime); Assert.AreEqual(Status.SUCCESS.ToString(), paymentPreAuth.Status); Assert.AreEqual(Locale.TR.GetName(), paymentPreAuth.Locale); Assert.AreEqual("123456789", paymentPreAuth.ConversationId); }
public static void Run(IReadOnlyDictionary <string, string> configDictionary) { var requestObj = new CreatePaymentRequest(); var v2PaymentsClientReferenceInformationObj = new V2paymentsClientReferenceInformation { Code = "TC50171_1" }; requestObj.ClientReferenceInformation = v2PaymentsClientReferenceInformationObj; var v2PaymentsPointOfSaleInformationObj = new V2paymentsPointOfSaleInformation { CardPresent = true }; var emvObj = new V2paymentsPointOfSaleInformationEmv { CardSequenceNumber = "123", Tags = "9F2608EF7753429A5D16B19F100706010A03A0000095058000040000" }; v2PaymentsPointOfSaleInformationObj.Emv = emvObj; v2PaymentsPointOfSaleInformationObj.EntryMode = "contact"; v2PaymentsPointOfSaleInformationObj.TerminalCapability = 4; requestObj.PointOfSaleInformation = v2PaymentsPointOfSaleInformationObj; var v2PaymentsAggregatorInformationObj = new V2paymentsAggregatorInformation(); var v2PaymentsAggregatorInformationSubMerchantObj = new V2paymentsAggregatorInformationSubMerchant { CardAcceptorId = "1234567890", Country = "US", PhoneNumber = "650-432-0000", Address1 = "900 Metro Center", PostalCode = "94404-2775", Locality = "Foster City", Name = "Visa Inc", AdministrativeArea = "CA", Region = "PEN", Email = "*****@*****.**" }; v2PaymentsAggregatorInformationObj.SubMerchant = v2PaymentsAggregatorInformationSubMerchantObj; v2PaymentsAggregatorInformationObj.Name = "V-Internatio"; v2PaymentsAggregatorInformationObj.AggregatorId = "123456789"; requestObj.AggregatorInformation = v2PaymentsAggregatorInformationObj; var v2PaymentsOrderInformationObj = new V2paymentsOrderInformation(); var v2PaymentsOrderInformationBillToObj = new V2paymentsOrderInformationBillTo { Country = "US", LastName = "Deo", Address2 = "Address 2", Address1 = "201 S. Division St.", PostalCode = "48104-2201", Locality = "Ann Arbor", AdministrativeArea = "MI", FirstName = "John", PhoneNumber = "999999999", District = "MI", BuildingNumber = "123", Company = "Visa", Email = "*****@*****.**" }; v2PaymentsOrderInformationObj.BillTo = v2PaymentsOrderInformationBillToObj; var amountDetailsObj = new V2paymentsOrderInformationAmountDetails { TotalAmount = "3000.00", Currency = "USD" }; v2PaymentsOrderInformationObj.AmountDetails = amountDetailsObj; requestObj.OrderInformation = v2PaymentsOrderInformationObj; var v2PaymentsPaymentInformationObj = new V2paymentsPaymentInformation(); var v2PaymentsPaymentInformationCardObj = new V2paymentsPaymentInformationCard { ExpirationYear = "2031", Number = "5555555555554444", SecurityCode = "123", ExpirationMonth = "12", Type = "002" }; v2PaymentsPaymentInformationObj.Card = v2PaymentsPaymentInformationCardObj; requestObj.PaymentInformation = v2PaymentsPaymentInformationObj; var merchantConfig = new MerchantConfig(configDictionary) { RequestType = "POST", RequestTarget = "/pts/v2/payments", RequestJsonData = JsonConvert.SerializeObject(requestObj) }; try { var configurationSwagger = new ApiClient().CallAuthenticationHeader(merchantConfig); var apiInstance = new PaymentApi(configurationSwagger); var result = apiInstance.CreatePayment(requestObj); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API: " + e.Message); } }
/// <summary> /// Process a Payment A payment authorizes the amount for the transaction. There are a number of supported payment feature, such as E-commerce and Card Present - Credit Card/Debit Card, Echeck, e-Wallets, Level II/III Data, etc.. A payment response includes the status of the request. It also includes processor-specific information when the request is successful and errors if unsuccessful. See the [Payments Developer Guides Page](https://developer.cybersource.com/api/developer-guides/dita-payments/GettingStarted.html). Authorization can be requested with Capture, Decision Manager, Payer Authentication(3ds), and Token Creation. Find more on [Authorization with Add-On Features page.] (https://developer.cybersource.com/api/authorization-add-ons.html) Possible [RESPONSE CODES](https://developer.cybersource.com/api/reference/response-codes.html) . Processor specific [Testing Triggers](https://developer.cybersource.com/hello-world/testing-guide.html). /// </summary> /// <exception cref="CyberSource.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="createPaymentRequest"></param> /// <returns>Task of PtsV2PaymentsPost201Response</returns> public async System.Threading.Tasks.Task <PtsV2PaymentsPost201Response> CreatePaymentAsync(CreatePaymentRequest createPaymentRequest) { ApiResponse <PtsV2PaymentsPost201Response> localVarResponse = await CreatePaymentAsyncWithHttpInfo(createPaymentRequest); return(localVarResponse.Data); }
public static void Run(IReadOnlyDictionary <string, string> configDictionary) { var requestObj = new CreatePaymentRequest(); var v2PaymentsClientReferenceInformationObj = new V2paymentsClientReferenceInformation { Code = "1234567890" }; requestObj.ClientReferenceInformation = v2PaymentsClientReferenceInformationObj; var v2PaymentsProcessingInformationObj = new V2paymentsProcessingInformation { Capture = true }; var authorizationOptionsObj = new V2paymentsProcessingInformationAuthorizationOptions { AuthType = "verbal", VerbalAuthCode = "potato" }; v2PaymentsProcessingInformationObj.AuthorizationOptions = authorizationOptionsObj; requestObj.ProcessingInformation = v2PaymentsProcessingInformationObj; var v2PaymentsOrderInformationObj = new V2paymentsOrderInformation(); var v2PaymentsOrderInformationBillToObj = new V2paymentsOrderInformationBillTo { Country = "US", FirstName = "John", LastName = "Deo", Address1 = "901 Metro Center Blvd", PostalCode = "94404", Locality = "Foster City", AdministrativeArea = "CA", Email = "*****@*****.**" }; v2PaymentsOrderInformationObj.BillTo = v2PaymentsOrderInformationBillToObj; var v2PaymentsOrderInformationAmountDetailsObj = new V2paymentsOrderInformationAmountDetails { TotalAmount = "100", Currency = "USD" }; v2PaymentsOrderInformationObj.AmountDetails = v2PaymentsOrderInformationAmountDetailsObj; requestObj.OrderInformation = v2PaymentsOrderInformationObj; var v2PaymentsPaymentInformationObj = new V2paymentsPaymentInformation(); var v2PaymentsPaymentInformationCardObj = new V2paymentsPaymentInformationCard { ExpirationYear = "2031", Number = "4111111111111111", ExpirationMonth = "12" }; v2PaymentsPaymentInformationObj.Card = v2PaymentsPaymentInformationCardObj; requestObj.PaymentInformation = v2PaymentsPaymentInformationObj; var merchantConfig = new MerchantConfig(configDictionary) { RequestType = "POST", RequestTarget = "/pts/v2/payments", RequestJsonData = JsonConvert.SerializeObject(requestObj) }; try { var configurationSwagger = new ApiClient().CallAuthenticationHeader(merchantConfig); var apiInstance = new PaymentApi(configurationSwagger); var result = apiInstance.CreatePayment(requestObj); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API: " + e.Message); } }
public static PtsV2PaymentsPost201Response Run() { string clientReferenceInformationCode = "123456"; string clientReferenceInformationPartnerOriginalTransactionId = "510be4aef90711e6acbc7d88388d803d"; Ptsv2paymentsClientReferenceInformationPartner clientReferenceInformationPartner = new Ptsv2paymentsClientReferenceInformationPartner( OriginalTransactionId: clientReferenceInformationPartnerOriginalTransactionId ); Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( Code: clientReferenceInformationCode, Partner: clientReferenceInformationPartner ); bool processingInformationCapture = true; string processingInformationCommerceIndicator = "retail"; Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( Capture: processingInformationCapture, CommerceIndicator: processingInformationCommerceIndicator ); string orderInformationAmountDetailsTotalAmount = "100.00"; string orderInformationAmountDetailsCurrency = "USD"; Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( TotalAmount: orderInformationAmountDetailsTotalAmount, Currency: orderInformationAmountDetailsCurrency ); Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( AmountDetails: orderInformationAmountDetails ); int pointOfSaleInformationCatLevel = 1; string pointOfSaleInformationEntryMode = "contactless"; int pointOfSaleInformationTerminalCapability = 5; string pointOfSaleInformationEmvTags = "9F3303204000950500000000009F3704518823719F100706011103A000009F26081E1756ED0E2134E29F36020015820200009C01009F1A0208409A030006219F02060000000020005F2A0208409F0306000000000000"; int pointOfSaleInformationEmvCardholderVerificationMethodUsed = 2; string pointOfSaleInformationEmvCardSequenceNumber = "1"; bool pointOfSaleInformationEmvFallback = false; Ptsv2paymentsPointOfSaleInformationEmv pointOfSaleInformationEmv = new Ptsv2paymentsPointOfSaleInformationEmv( Tags: pointOfSaleInformationEmvTags, CardholderVerificationMethodUsed: pointOfSaleInformationEmvCardholderVerificationMethodUsed, CardSequenceNumber: pointOfSaleInformationEmvCardSequenceNumber, Fallback: pointOfSaleInformationEmvFallback ); string pointOfSaleInformationTrackData = "%B4111111111111111^TEST/CYBS ^2012121019761100 00868000000?;"; List <string> pointOfSaleInformationCardholderVerificationMethod = new List <string>(); pointOfSaleInformationCardholderVerificationMethod.Add("pin"); pointOfSaleInformationCardholderVerificationMethod.Add("signature"); List <string> pointOfSaleInformationTerminalInputCapability = new List <string>(); pointOfSaleInformationTerminalInputCapability.Add("contact"); pointOfSaleInformationTerminalInputCapability.Add("contactless"); pointOfSaleInformationTerminalInputCapability.Add("keyed"); pointOfSaleInformationTerminalInputCapability.Add("swiped"); string pointOfSaleInformationTerminalCardCaptureCapability = "1"; string pointOfSaleInformationDeviceId = "123lkjdIOBK34981slviLI39bj"; string pointOfSaleInformationEncryptedKeySerialNumber = "01043191"; Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( CatLevel: pointOfSaleInformationCatLevel, EntryMode: pointOfSaleInformationEntryMode, TerminalCapability: pointOfSaleInformationTerminalCapability, Emv: pointOfSaleInformationEmv, TrackData: pointOfSaleInformationTrackData, CardholderVerificationMethod: pointOfSaleInformationCardholderVerificationMethod, TerminalInputCapability: pointOfSaleInformationTerminalInputCapability, TerminalCardCaptureCapability: pointOfSaleInformationTerminalCardCaptureCapability, DeviceId: pointOfSaleInformationDeviceId, EncryptedKeySerialNumber: pointOfSaleInformationEncryptedKeySerialNumber ); var requestObj = new CreatePaymentRequest( ClientReferenceInformation: clientReferenceInformation, ProcessingInformation: processingInformation, OrderInformation: orderInformation, PointOfSaleInformation: pointOfSaleInformation ); try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new PaymentsApi(clientConfig); PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); Console.WriteLine(result); return(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API : " + e.Message); return(null); } }
public static void Run(IReadOnlyDictionary <string, string> configDictionary) { var requestObj = new CreatePaymentRequest(); var v2PaymentsClientReferenceInformationObj = new V2paymentsClientReferenceInformation { Code = "33557799" }; requestObj.ClientReferenceInformation = v2PaymentsClientReferenceInformationObj; var v2PaymentsPointOfSaleInformationObj = new V2paymentsPointOfSaleInformation { TerminalId = "terminal", CardPresent = true }; var emvObj = new V2paymentsPointOfSaleInformationEmv { CardSequenceNumber = "123", Tags = "9C01019A031207109F33036040209F1A0207849F370482766E409F3602001F82025C009F2608EF7753429A5D16B19F100706010A03A00000950580000400009F02060000000700009F6E0482766E409F5B04123456789F2701809F3403AB12349F0902AB129F4104AB1234AB9F0702AB129F0610123456789012345678901234567890AB9F030200005F2A0207849F7C031234569F350123" }; v2PaymentsPointOfSaleInformationObj.Emv = emvObj; v2PaymentsPointOfSaleInformationObj.EntryMode = "QRCode"; v2PaymentsPointOfSaleInformationObj.TerminalCapability = 4; requestObj.PointOfSaleInformation = v2PaymentsPointOfSaleInformationObj; var v2PaymentsProcessingInformationObj = new V2paymentsProcessingInformation { CommerceIndicator = "retail", PaymentSolution = "007" }; requestObj.ProcessingInformation = v2PaymentsProcessingInformationObj; var v2PaymentsOrderInformationObj = new V2paymentsOrderInformation(); var v2PaymentsOrderInformationBillToObj = new V2paymentsOrderInformationBillTo { Country = "US", LastName = "Deo", Address2 = "test", Address1 = "201 S. Division St.", PostalCode = "48104-2201", Locality = "Ann Arbor", AdministrativeArea = "MI", FirstName = "John", PhoneNumber = "999999999", District = "MI", BuildingNumber = "123", Company = "Visa", Email = "*****@*****.**" }; v2PaymentsOrderInformationObj.BillTo = v2PaymentsOrderInformationBillToObj; var amountDetailsObj = new V2paymentsOrderInformationAmountDetails { TotalAmount = "100.00", Currency = "USD" }; v2PaymentsOrderInformationObj.AmountDetails = amountDetailsObj; requestObj.OrderInformation = v2PaymentsOrderInformationObj; var v2PaymentsPaymentInformationObj = new V2paymentsPaymentInformation(); var tokenizedCardObj = new V2paymentsPaymentInformationTokenizedCard { TransactionType = "1", RequestorId = "12345678901" }; v2PaymentsPaymentInformationObj.TokenizedCard = tokenizedCardObj; var v2PaymentsPaymentInformationCardObj = new V2paymentsPaymentInformationCard { Type = "001" }; // v2PaymentsPaymentInformationCardObj.TrackData = ";4111111111111111=21121019761186800000?"; v2PaymentsPaymentInformationObj.Card = v2PaymentsPaymentInformationCardObj; requestObj.PaymentInformation = v2PaymentsPaymentInformationObj; var merchantConfig = new MerchantConfig(configDictionary) { RequestType = "POST", RequestTarget = "/pts/v2/payments", RequestJsonData = JsonConvert.SerializeObject(requestObj) }; try { var configurationSwagger = new ApiClient().CallAuthenticationHeader(merchantConfig); var apiInstance = new PaymentApi(configurationSwagger); var result = apiInstance.CreatePayment(requestObj); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API: " + e.Message); } }
public async Task <bool> Operation(PaymentModel model) { try { var request = new CreatePaymentRequest { Price = model.Price, PaidPrice = model.Price, Currency = Currency.TRY.ToString(), Installment = 1, PaymentCard = new PaymentCard { CardHolderName = model.CardHolderName, CardNumber = model.CardNumber, ExpireMonth = model.ExpireMonth, ExpireYear = model.ExpireYear, Cvc = model.Cvc }, Buyer = new Buyer { Id = "BY789", Name = "Onur", Surname = "Celik", GsmNumber = "+905074406251", Email = "*****@*****.**", IdentityNumber = "74300864791", LastLoginDate = "2015-10-05 12:43:35", RegistrationDate = "2013-04-21 15:12:09", RegistrationAddress = "Kuruçeşme Mahallesi No:196 Buca", Ip = "85.34.78.112", City = "Izmir", Country = "Turkey" }, ShippingAddress = new Address { ContactName = model.CardHolderName, City = "Izmir", Country = "Turkey", Description = model.ProductName + " - Online Alışveriş" }, BillingAddress = new Address { ContactName = model.CardHolderName, City = "Izmir", Country = "Turkey", Description = "Kuruçeşme Mahallesi No:196 Buca", }, BasketItems = new List <BasketItem> { new BasketItem { Id = "BI101", Name = model.ProductName, Category1 = "Collectibles", ItemType = BasketItemType.PHYSICAL.ToString(), Price = model.Price } } }; Payment payment = await Payment.CreateAsync(request, options); if (payment.Status == "success") { return(true); } return(false); } catch (Exception) { return(false); } }
public static Payment Create(CreatePaymentRequest request, Options options) { return(RestHttpClient.Create().Post <Payment>(options.BaseUrl + "/payment/auth", GetHttpHeaders(request, options), request)); }
public static void Run(IReadOnlyDictionary <string, string> configDictionary) { var requestObj = new CreatePaymentRequest(); var v2PaymentsClientReferenceInformationObj = new V2paymentsClientReferenceInformation { Code = "TC50171_16" }; requestObj.ClientReferenceInformation = v2PaymentsClientReferenceInformationObj; var v2PaymentsPointOfSaleInformationObj = new V2paymentsPointOfSaleInformation { CardPresent = true, CatLevel = 1, EntryMode = "contact", TerminalCapability = 1 // v2PaymentsPointOfSaleInformationObj.EndlessAisleTransactionIndicator = "true"; }; requestObj.PointOfSaleInformation = v2PaymentsPointOfSaleInformationObj; var v2PaymentsProcessingInformationObj = new V2paymentsProcessingInformation { CommerceIndicator = "retail", PaymentSolution = "011" }; requestObj.ProcessingInformation = v2PaymentsProcessingInformationObj; var v2PaymentsAggregatorInformationSubMerchantObj = new V2paymentsAggregatorInformationSubMerchant { CardAcceptorId = "1234567890", Country = "US", PhoneNumber = "650-432-0000", Address1 = "900 Metro Center", PostalCode = "94404-2775", Locality = "Foster City", Name = "Visa Inc", AdministrativeArea = "CA", Region = "PEN", Email = "*****@*****.**" }; var v2PaymentsAggregatorInformationObj = new V2paymentsAggregatorInformation { SubMerchant = v2PaymentsAggregatorInformationSubMerchantObj, Name = "V-Internatio", AggregatorId = "123456789" }; requestObj.AggregatorInformation = v2PaymentsAggregatorInformationObj; var v2PaymentsOrderInformationObj = new V2paymentsOrderInformation(); var v2PaymentsOrderInformationBillToObj = new V2paymentsOrderInformationBillTo { Country = "US", LastName = "Deo", Address2 = "Address 2", Address1 = "201 S. Division St.", PostalCode = "48104-2201", Locality = "Ann Arbor", AdministrativeArea = "MI", FirstName = "John", PhoneNumber = "999999999", District = "MI", BuildingNumber = "123", Company = "Visa", Email = "*****@*****.**" }; v2PaymentsOrderInformationObj.BillTo = v2PaymentsOrderInformationBillToObj; var v2PaymentsOrderInformationAmountDetailsObj = new V2paymentsOrderInformationAmountDetails { TotalAmount = "115.0", Currency = "USD" }; v2PaymentsOrderInformationObj.AmountDetails = v2PaymentsOrderInformationAmountDetailsObj; requestObj.OrderInformation = v2PaymentsOrderInformationObj; var v2PaymentsPaymentInformationObj = new V2paymentsPaymentInformation(); var v2PaymentsPaymentInformationFluidDataObj = new V2paymentsPaymentInformationFluidData { Descriptor = "EMV.PAYMENT.AnywhereCommerce.Walker", Value = "ewogICJkYXRhIiA6ICJOZmNwRURiK1dLdzBnQkpsaTRcL1hlWm1ITzdUSng0bnRoMnc2Mk9ITVJQK3hCRlFPdFE0WWpRcnY0RmFkOHh6VExqT2VFQm5iNHFzeGZMYTNyNXcxVEdXblFGQnNzMWtPYnA0XC95alNtVE1JSGVjbGc5OFROaEhNb0VRcjJkRkFqYVpBTFAxSlBsdVhKSVwvbTZKSmVwNGh3VHRWZE16Z2laSUhnaWFCYzNXZVd1ZnYzc1l0cGRaZDZYZENEUFdLeXFkYjBJdUtkdkpBPT0iLAogICJzaWduYXR1cmUiIDogIkFxck1pKzc0cm1GeVBKVE9HN3NuN2p5K1YxTlpBZUNJVE56TW01N1B5cmc9IiwKICAic2lnbmF0dXJlQWxnSW5mbyIgOiAiSE1BQ3dpdGhTSEEyNTYiLAogICJoZWFkZXIiIDogewogICAgInRyYW5zYWN0aW9uSWQiIDogIjE1MTU2MjI2NjIuMTcyMjIwIiwKICAgICJwdWJsaWNLZXlIYXNoIiA6ICJcLzdmdldqRVhMazJPRWpcL3Z5bk1jeEZvMmRWSTlpRXVoT2Nab0tHQnpGTmM9IiwKICAgICJhcHBsaWNhdGlvbkRhdGEiIDogIkN5YmVyU291cmNlLlZNcG9zS2l0IiwKICAgICJlcGhlbWVyYWxQdWJsaWNLZXkiIDogIk1Ga3dFd1lIS29aSXpqMENBUVlJS29aSXpqMERBUWNEUWdBRW1JN0tScnRNN2NNelk5Zmw2UWt2NEQzdE9jU0NYR1hoOFwvK2R4K2s5c1Zrbk05UFQrOXRqMzk2YWF6QjRcL0hYaWlLRW9DXC9jUzdoSzF6UFk3MVwvN0pUUT09IgogIH0sCiAgInZlcnNpb24iIDogIjEuMCIKfQ==" }; v2PaymentsPaymentInformationObj.FluidData = v2PaymentsPaymentInformationFluidDataObj; requestObj.PaymentInformation = v2PaymentsPaymentInformationObj; var merchantConfig = new MerchantConfig(configDictionary) { RequestType = "POST", RequestTarget = "/pts/v2/payments", RequestJsonData = JsonConvert.SerializeObject(requestObj) }; try { var configurationSwagger = new ApiClient().CallAuthenticationHeader(merchantConfig); var apiInstance = new PaymentApi(configurationSwagger); var result = apiInstance.CreatePayment(requestObj); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API: " + e.Message); } }
public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest) { var result = new ProcessPaymentResult(); try { var options = IyzicoHelper.GetIyzicoOptions(_iyzicoPaymentSettings); var paymentCard = new PaymentCard() { CardHolderName = processPaymentRequest.CreditCardName, CardNumber = processPaymentRequest.CreditCardNumber, ExpireMonth = processPaymentRequest.CreditCardExpireMonth.ToString(), ExpireYear = processPaymentRequest.CreditCardExpireYear.ToString(), Cvc = processPaymentRequest.CreditCardCvv2 }; var customer = _customerService.GetCustomerById(processPaymentRequest.CustomerId); var billingAddress = _addressService.GetAddressById(_customerService.GetCustomerById(processPaymentRequest.CustomerId).BillingAddressId ?? 0); if (billingAddress == null) { throw new NopException("Customer billing address not set"); } var shippingAddress = _addressService.GetAddressById(_customerService.GetCustomerById(processPaymentRequest.CustomerId).ShippingAddressId ?? 0); var billingAddressModel = _iyzicoService.PrepareAddress(billingAddress); var shippingAddressModel = shippingAddress != null?_iyzicoService.PrepareAddress(shippingAddress) : billingAddressModel; var installment = GetInstallment(processPaymentRequest, paymentCard, options); var shoppingCart = _shoppingCartService.GetShoppingCart(customer, ShoppingCartType.ShoppingCart); var shoppingCartTotal = _orderTotalCalculationService.GetShoppingCartTotal(shoppingCart, out var orderDiscountAmount, out var orderAppliedDiscounts, out var appliedGiftCards, out var redeemedRewardPoints, out var redeemedRewardPointsAmount, usePaymentMethodAdditionalFee: false); var paymentRequest = new CreatePaymentRequest { Price = _priceCalculationService.RoundPrice(shoppingCartTotal ?? 0).ToString("f8", CultureInfo.InvariantCulture), PaidPrice = installment.TotalPrice, Currency = Currency.TRY.ToString(), Installment = installment.InstallmentNumber, BasketId = processPaymentRequest.OrderGuid.ToString(), PaymentCard = paymentCard, Buyer = _iyzicoService.PrepareBuyer(processPaymentRequest.CustomerId), ShippingAddress = shippingAddressModel, BillingAddress = billingAddressModel, BasketItems = GetItems(customer, processPaymentRequest.StoreId), PaymentGroup = PaymentGroup.PRODUCT.ToString() }; var payment = Payment.Create(paymentRequest, options); if (payment.Status != "success") { string errorMessage = _localizationService.GetResource(String.Format("Plugins.Payments.Iyzico.ErrorMessage.{0}", payment.ErrorCode)) ?? payment.ErrorMessage; result.AddError(errorMessage); return(result); } result.NewPaymentStatus = PaymentStatus.Pending; return(result); } catch (Exception ex) { result.AddError(ex.Message); return(result); } }
public static void Run(IReadOnlyDictionary <string, string> configDictionary) { var requestObj = new CreatePaymentRequest(); var v2PaymentsClientReferenceInformationObj = new V2paymentsClientReferenceInformation { Code = "TC50171_14" }; requestObj.ClientReferenceInformation = v2PaymentsClientReferenceInformationObj; var v2PaymentsProcessingInformationObj = new V2paymentsProcessingInformation { CommerceIndicator = "internet", PurchaseLevel = "3" }; requestObj.ProcessingInformation = v2PaymentsProcessingInformationObj; var v2PaymentsAggregatorInformationObj = new V2paymentsAggregatorInformation(); var v2PaymentsAggregatorInformationSubMerchantObj = new V2paymentsAggregatorInformationSubMerchant { CardAcceptorId = "1234567890", Country = "US", PhoneNumber = "650-432-0000", Address1 = "900 Metro Center", PostalCode = "94404-2775", Locality = "Foster City", Name = "Visa Inc", AdministrativeArea = "CA", Region = "PEN", Email = "*****@*****.**" }; v2PaymentsAggregatorInformationObj.SubMerchant = v2PaymentsAggregatorInformationSubMerchantObj; v2PaymentsAggregatorInformationObj.Name = "V-Internatio"; v2PaymentsAggregatorInformationObj.AggregatorId = "123456789"; requestObj.AggregatorInformation = v2PaymentsAggregatorInformationObj; var v2PaymentsOrderInformationObj = new V2paymentsOrderInformation(); var v2PaymentsOrderInformationBillToObj = new V2paymentsOrderInformationBillTo { Country = "US", LastName = "Deo", Address2 = "Address 2", Address1 = "201 S. Division St.", PostalCode = "48104-2201", Locality = "Ann Arbor", AdministrativeArea = "MI", FirstName = "John", PhoneNumber = "999999999", District = "MI", BuildingNumber = "123", Company = "Visa", Email = "*****@*****.**" }; v2PaymentsOrderInformationObj.BillTo = v2PaymentsOrderInformationBillToObj; var v2PaymentsOrderInformationInvoiceDetailsObj = new V2paymentsOrderInformationInvoiceDetails { PurchaseOrderNumber = "LevelIII Auth Po" }; v2PaymentsOrderInformationObj.InvoiceDetails = v2PaymentsOrderInformationInvoiceDetailsObj; var v2PaymentsOrderInformationAmountDetailsObj = new V2paymentsOrderInformationAmountDetails { TotalAmount = "114.00", Currency = "USD" }; v2PaymentsOrderInformationObj.AmountDetails = v2PaymentsOrderInformationAmountDetailsObj; requestObj.OrderInformation = v2PaymentsOrderInformationObj; var v2PaymentsPaymentInformationObj = new V2paymentsPaymentInformation(); var v2PaymentsPaymentInformationCardObj = new V2paymentsPaymentInformationCard { ExpirationYear = "2031", Number = "4111111111111111", SecurityCode = "123", ExpirationMonth = "12", Type = "001" }; v2PaymentsPaymentInformationObj.Card = v2PaymentsPaymentInformationCardObj; requestObj.PaymentInformation = v2PaymentsPaymentInformationObj; var merchantConfig = new MerchantConfig(configDictionary) { RequestType = "POST", RequestTarget = "/pts/v2/payments", RequestJsonData = JsonConvert.SerializeObject(requestObj) }; try { var configurationSwagger = new ApiClient().CallAuthenticationHeader(merchantConfig); var apiInstance = new PaymentApi(configurationSwagger); var result = apiInstance.CreatePayment(requestObj); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API: " + e.Message); } }
public static PtsV2PaymentsPost201Response Run() { string clientReferenceInformationCode = "demomerchant"; Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( Code: clientReferenceInformationCode ); bool processingInformationCapture = false; string processingInformationCommerceIndicator = "retail"; Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( Capture: processingInformationCapture, CommerceIndicator: processingInformationCommerceIndicator ); string paymentInformationCardExpirationMonth = "12"; string paymentInformationCardExpirationYear = "2050"; Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( ExpirationMonth: paymentInformationCardExpirationMonth, ExpirationYear: paymentInformationCardExpirationYear ); string paymentInformationFluidDataDescriptor = "Ymx1ZWZpbg=="; string paymentInformationFluidDataValue = "02d700801f3c20008383252a363031312a2a2a2a2a2a2a2a303030395e46444d53202020202020202020202020202020202020202020205e323231322a2a2a2a2a2a2a2a3f2a3b363031312a2a2a2a2a2a2a2a303030393d323231322a2a2a2a2a2a2a2a3f2a7a75ad15d25217290c54b3d9d1c3868602136c68d339d52d98423391f3e631511d548fff08b414feac9ff6c6dede8fb09bae870e4e32f6f462d6a75fa0a178c3bd18d0d3ade21bc7a0ea687a2eef64551751e502d97cb98dc53ea55162cdfa395431323439323830303762994901000001a000731a8003"; Ptsv2paymentsPaymentInformationFluidData paymentInformationFluidData = new Ptsv2paymentsPaymentInformationFluidData( Descriptor: paymentInformationFluidDataDescriptor, Value: paymentInformationFluidDataValue ); Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( Card: paymentInformationCard, FluidData: paymentInformationFluidData ); string orderInformationAmountDetailsTotalAmount = "100.00"; string orderInformationAmountDetailsCurrency = "USD"; Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( TotalAmount: orderInformationAmountDetailsTotalAmount, Currency: orderInformationAmountDetailsCurrency ); string orderInformationBillToFirstName = "John"; string orderInformationBillToLastName = "Deo"; string orderInformationBillToAddress1 = "201 S. Division St."; string orderInformationBillToLocality = "Ann Arbor"; string orderInformationBillToAdministrativeArea = "MI"; string orderInformationBillToPostalCode = "48104-2201"; string orderInformationBillToCountry = "US"; string orderInformationBillToDistrict = "MI"; string orderInformationBillToEmail = "*****@*****.**"; string orderInformationBillToPhoneNumber = "999999999"; Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( FirstName: orderInformationBillToFirstName, LastName: orderInformationBillToLastName, Address1: orderInformationBillToAddress1, Locality: orderInformationBillToLocality, AdministrativeArea: orderInformationBillToAdministrativeArea, PostalCode: orderInformationBillToPostalCode, Country: orderInformationBillToCountry, District: orderInformationBillToDistrict, Email: orderInformationBillToEmail, PhoneNumber: orderInformationBillToPhoneNumber ); Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( AmountDetails: orderInformationAmountDetails, BillTo: orderInformationBillTo ); int pointOfSaleInformationCatLevel = 1; string pointOfSaleInformationEntryMode = "keyed"; int pointOfSaleInformationTerminalCapability = 2; Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( CatLevel: pointOfSaleInformationCatLevel, EntryMode: pointOfSaleInformationEntryMode, TerminalCapability: pointOfSaleInformationTerminalCapability ); var requestObj = new CreatePaymentRequest( ClientReferenceInformation: clientReferenceInformation, ProcessingInformation: processingInformation, PaymentInformation: paymentInformation, OrderInformation: orderInformation, PointOfSaleInformation: pointOfSaleInformation ); try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new PaymentsApi(clientConfig); PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); Console.WriteLine(result); return(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API : " + e.Message); return(null); } }
private void IyziTest() { Options options = new Options(); options.ApiKey = "sandbox-sN9tZPaMwFy0uNj2E1AKJOx5tDzUIwwN"; options.SecretKey = "sandbox-ve0yytU2wsTTuW033KEGHHoXH6R1v5Nx"; options.BaseUrl = "https://sandbox-api.iyzipay.com"; CreatePaymentRequest request = new CreatePaymentRequest(); request.Locale = Locale.TR.ToString(); request.ConversationId = "123456789"; request.Price = "1"; request.PaidPrice = "1.2"; request.Currency = Currency.TRY.ToString(); request.Installment = 1; request.BasketId = "B67832"; request.PaymentChannel = PaymentChannel.WEB.ToString(); request.PaymentGroup = PaymentGroup.PRODUCT.ToString(); PaymentCard paymentCard = new PaymentCard(); paymentCard.CardHolderName = "John Doe"; paymentCard.CardNumber = "5528790000000008"; paymentCard.ExpireMonth = "12"; paymentCard.ExpireYear = "2030"; paymentCard.Cvc = "123"; paymentCard.RegisterCard = 0; request.PaymentCard = paymentCard; Buyer buyer = new Buyer(); buyer.Id = "BY789"; buyer.Name = "John"; buyer.Surname = "Doe"; buyer.GsmNumber = "+905350000000"; buyer.Email = "*****@*****.**"; buyer.IdentityNumber = "74300864791"; buyer.LastLoginDate = "2015-10-05 12:43:35"; buyer.RegistrationDate = "2013-04-21 15:12:09"; buyer.RegistrationAddress = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"; buyer.Ip = "85.34.78.112"; buyer.City = "Istanbul"; buyer.Country = "Turkey"; buyer.ZipCode = "34732"; request.Buyer = buyer; Address shippingAddress = new Address(); shippingAddress.ContactName = "Jane Doe"; shippingAddress.City = "Istanbul"; shippingAddress.Country = "Turkey"; shippingAddress.Description = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"; shippingAddress.ZipCode = "34742"; request.ShippingAddress = shippingAddress; Address billingAddress = new Address(); billingAddress.ContactName = "Jane Doe"; billingAddress.City = "Istanbul"; billingAddress.Country = "Turkey"; billingAddress.Description = "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1"; billingAddress.ZipCode = "34742"; request.BillingAddress = billingAddress; List <BasketItem> basketItems = new List <BasketItem>(); BasketItem firstBasketItem = new BasketItem(); firstBasketItem.Id = "BI101"; firstBasketItem.Name = "Binocular"; firstBasketItem.Category1 = "Collectibles"; firstBasketItem.Category2 = "Accessories"; firstBasketItem.ItemType = BasketItemType.PHYSICAL.ToString(); firstBasketItem.Price = "0.3"; basketItems.Add(firstBasketItem); BasketItem secondBasketItem = new BasketItem(); secondBasketItem.Id = "BI102"; secondBasketItem.Name = "Game code"; secondBasketItem.Category1 = "Game"; secondBasketItem.Category2 = "Online Game Items"; secondBasketItem.ItemType = BasketItemType.VIRTUAL.ToString(); secondBasketItem.Price = "0.5"; basketItems.Add(secondBasketItem); BasketItem thirdBasketItem = new BasketItem(); thirdBasketItem.Id = "BI103"; thirdBasketItem.Name = "Usb"; thirdBasketItem.Category1 = "Electronics"; thirdBasketItem.Category2 = "Usb / Cable"; thirdBasketItem.ItemType = BasketItemType.PHYSICAL.ToString(); thirdBasketItem.Price = "0.2"; basketItems.Add(thirdBasketItem); request.BasketItems = basketItems; Payment payment = Payment.Create(request, options); }
public static PtsV2PaymentsPost201Response Run() { string clientReferenceInformationCode = "TC50171_3"; Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( Code: clientReferenceInformationCode ); List <string> processingInformationActionList = new List <string>(); processingInformationActionList.Add("CONSUMER_AUTHENTICATION"); bool processingInformationCapture = false; Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( ActionList: processingInformationActionList, Capture: processingInformationCapture ); string paymentInformationCardNumber = "4000000000001091"; string paymentInformationCardExpirationMonth = "12"; string paymentInformationCardExpirationYear = "2023"; Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( Number: paymentInformationCardNumber, ExpirationMonth: paymentInformationCardExpirationMonth, ExpirationYear: paymentInformationCardExpirationYear ); Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( Card: paymentInformationCard ); string orderInformationAmountDetailsTotalAmount = "100.00"; string orderInformationAmountDetailsCurrency = "usd"; Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( TotalAmount: orderInformationAmountDetailsTotalAmount, Currency: orderInformationAmountDetailsCurrency ); string orderInformationBillToFirstName = "John"; string orderInformationBillToLastName = "Smith"; string orderInformationBillToAddress1 = "201 S. Division St._1"; string orderInformationBillToAddress2 = "Suite 500"; string orderInformationBillToLocality = "Foster City"; string orderInformationBillToAdministrativeArea = "CA"; string orderInformationBillToPostalCode = "94404"; string orderInformationBillToCountry = "US"; string orderInformationBillToEmail = "*****@*****.**"; string orderInformationBillToPhoneNumber = "6504327113"; Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( FirstName: orderInformationBillToFirstName, LastName: orderInformationBillToLastName, Address1: orderInformationBillToAddress1, Address2: orderInformationBillToAddress2, Locality: orderInformationBillToLocality, AdministrativeArea: orderInformationBillToAdministrativeArea, PostalCode: orderInformationBillToPostalCode, Country: orderInformationBillToCountry, Email: orderInformationBillToEmail, PhoneNumber: orderInformationBillToPhoneNumber ); Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( AmountDetails: orderInformationAmountDetails, BillTo: orderInformationBillTo ); string consumerAuthenticationInformationRequestorId = "123123197675"; string consumerAuthenticationInformationReferenceId = "CybsCruiseTester-8ac0b02f"; Ptsv2paymentsConsumerAuthenticationInformation consumerAuthenticationInformation = new Ptsv2paymentsConsumerAuthenticationInformation( RequestorId: consumerAuthenticationInformationRequestorId, ReferenceId: consumerAuthenticationInformationReferenceId ); var requestObj = new CreatePaymentRequest( ClientReferenceInformation: clientReferenceInformation, ProcessingInformation: processingInformation, PaymentInformation: paymentInformation, OrderInformation: orderInformation, ConsumerAuthenticationInformation: consumerAuthenticationInformation ); try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new PaymentsApi(clientConfig); PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); Console.WriteLine(result); return(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API : " + e.Message); return(null); } }
public static void Run(IReadOnlyDictionary <string, string> configDictionary) { var requestObj = new CreatePaymentRequest(); var v2PaymentsClientReferenceInformationObj = new V2paymentsClientReferenceInformation { Code = "TC45561-10" }; requestObj.ClientReferenceInformation = v2PaymentsClientReferenceInformationObj; var consumerAuthenticationInformationObj = new V2paymentsConsumerAuthenticationInformation { Cavv = "EHuWW9PiBkWvqE5juRwDzAUFBAk=", UcafCollectionIndicator = "0", EciRaw = "02", UcafAuthenticationData = "lEmYpm61EduaVZjPG1/HsgkAAQc=" }; requestObj.ConsumerAuthenticationInformation = consumerAuthenticationInformationObj; var v2PaymentsProcessingInformationObj = new V2paymentsProcessingInformation { CommerceIndicator = "spa" }; requestObj.ProcessingInformation = v2PaymentsProcessingInformationObj; var v2PaymentsOrderInformationObj = new V2paymentsOrderInformation(); var v2PaymentsOrderInformationBillToObj = new V2paymentsOrderInformationBillTo { Country = "SG", LastName = "Deo", Address2 = "test", Address1 = "201 S. Division St.", PostalCode = "48104-2201", Locality = "Ann Arbor", AdministrativeArea = "MI", FirstName = "John", PhoneNumber = "999999999", District = "MI", BuildingNumber = "123", Company = "Visa", Email = "*****@*****.**" }; v2PaymentsOrderInformationObj.BillTo = v2PaymentsOrderInformationBillToObj; var amountDetailsObj = new V2paymentsOrderInformationAmountDetails { TotalAmount = "2016.05", Currency = "USD" }; v2PaymentsOrderInformationObj.AmountDetails = amountDetailsObj; requestObj.OrderInformation = v2PaymentsOrderInformationObj; var v2PaymentsPaymentInformationObj = new V2paymentsPaymentInformation(); var v2PaymentsPaymentInformationCardObj = new V2paymentsPaymentInformationCard { ExpirationYear = "2031", Number = "5641821111166669", SecurityCode = "123", ExpirationMonth = "12", Type = "024" }; v2PaymentsPaymentInformationObj.Card = v2PaymentsPaymentInformationCardObj; requestObj.PaymentInformation = v2PaymentsPaymentInformationObj; var merchantConfig = new MerchantConfig(configDictionary) { RequestType = "POST", RequestTarget = "/pts/v2/payments", RequestJsonData = JsonConvert.SerializeObject(requestObj) }; try { var configurationSwagger = new ApiClient().CallAuthenticationHeader(merchantConfig); var apiInstance = new PaymentApi(configurationSwagger); var result = apiInstance.CreatePayment(requestObj); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API: " + e.Message); } }
public static PtsV2PaymentsPost201Response Run() { string clientReferenceInformationCode = "TC50171_3"; Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( Code: clientReferenceInformationCode ); string paymentInformationLegacyTokenId = "7010000000016241111"; Ptsv2paymentsPaymentInformationLegacyToken paymentInformationLegacyToken = new Ptsv2paymentsPaymentInformationLegacyToken( Id: paymentInformationLegacyTokenId ); Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( LegacyToken: paymentInformationLegacyToken ); string orderInformationAmountDetailsTotalAmount = "22"; string orderInformationAmountDetailsCurrency = "USD"; Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( TotalAmount: orderInformationAmountDetailsTotalAmount, Currency: orderInformationAmountDetailsCurrency ); string orderInformationBillToFirstName = "John"; string orderInformationBillToLastName = "Doe"; string orderInformationBillToAddress1 = "1 Market St"; string orderInformationBillToLocality = "san francisco"; string orderInformationBillToAdministrativeArea = "CA"; string orderInformationBillToPostalCode = "94105"; string orderInformationBillToCountry = "US"; string orderInformationBillToEmail = "*****@*****.**"; string orderInformationBillToPhoneNumber = "4158880000"; Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( FirstName: orderInformationBillToFirstName, LastName: orderInformationBillToLastName, Address1: orderInformationBillToAddress1, Locality: orderInformationBillToLocality, AdministrativeArea: orderInformationBillToAdministrativeArea, PostalCode: orderInformationBillToPostalCode, Country: orderInformationBillToCountry, Email: orderInformationBillToEmail, PhoneNumber: orderInformationBillToPhoneNumber ); Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( AmountDetails: orderInformationAmountDetails, BillTo: orderInformationBillTo ); var requestObj = new CreatePaymentRequest( ClientReferenceInformation: clientReferenceInformation, PaymentInformation: paymentInformation, OrderInformation: orderInformation ); try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new PaymentsApi(clientConfig); PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); Console.WriteLine(result); return(result); } catch (Exception e) { Console.WriteLine("Exception on calling the API : " + e.Message); return(null); } }
/// <remarks/> public void CreatePaymentAsync(CreatePaymentRequest CreatePaymentRequest, object userState) { if ((this.CreatePaymentOperationCompleted == null)) { this.CreatePaymentOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreatePaymentOperationCompleted); } this.InvokeAsync("CreatePayment", new object[] { CreatePaymentRequest}, this.CreatePaymentOperationCompleted, userState); }
/// <remarks/> public void CreatePaymentAsync(CreatePaymentRequest ManageOrderGeneralPaymentSettingsRequest) { this.CreatePaymentAsync(ManageOrderGeneralPaymentSettingsRequest, null); }