public static PtsV2PaymentsCapturesPost201Response Run()
        {
            ServiceFeesWithCreditCardTransaction.CaptureTrueForProcessPayment = false;
            var id = ServiceFeesWithCreditCardTransaction.Run().Id;

            string clientReferenceInformationCode = "TC50171_3";
            Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation(
                Code: clientReferenceInformationCode
                );

            string orderInformationAmountDetailsTotalAmount      = "2325.00";
            string orderInformationAmountDetailsCurrency         = "USD";
            string orderInformationAmountDetailsServiceFeeAmount = "30.00";
            Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails(
                TotalAmount: orderInformationAmountDetailsTotalAmount,
                Currency: orderInformationAmountDetailsCurrency,
                ServiceFeeAmount: orderInformationAmountDetailsServiceFeeAmount
                );

            Ptsv2paymentsidcapturesOrderInformation orderInformation = new Ptsv2paymentsidcapturesOrderInformation(
                AmountDetails: orderInformationAmountDetails
                );

            string merchantInformationServiceFeeDescriptorName    = "Vacations Service Fee";
            string merchantInformationServiceFeeDescriptorContact = "8009999999";
            string merchantInformationServiceFeeDescriptorState   = "CA";
            Ptsv2paymentsMerchantInformationServiceFeeDescriptor merchantInformationServiceFeeDescriptor = new Ptsv2paymentsMerchantInformationServiceFeeDescriptor(
                Name: merchantInformationServiceFeeDescriptorName,
                Contact: merchantInformationServiceFeeDescriptorContact,
                State: merchantInformationServiceFeeDescriptorState
                );

            Ptsv2paymentsidcapturesMerchantInformation merchantInformation = new Ptsv2paymentsidcapturesMerchantInformation(
                ServiceFeeDescriptor: merchantInformationServiceFeeDescriptor
                );

            var requestObj = new CapturePaymentRequest(
                ClientReferenceInformation: clientReferenceInformation,
                OrderInformation: orderInformation,
                MerchantInformation: merchantInformation
                );

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);

                var apiInstance = new CaptureApi(clientConfig);
                PtsV2PaymentsCapturesPost201Response result = apiInstance.CapturePayment(requestObj, id);
                Console.WriteLine(result);
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API : " + e.Message);
                return(null);
            }
        }
Beispiel #2
0
        public static PtsV2PaymentsPost201Response Run()
        {
            string clientReferenceInformationCode = "TC50171_3";
            Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation(
                Code: clientReferenceInformationCode
                );

            bool processingInformationCapture = false;

            if (CaptureTrueForProcessPayment)
            {
                processingInformationCapture = true;
            }

            Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation(
                Capture: processingInformationCapture
                );

            string paymentInformationCardNumber          = "4111111111111111";
            string paymentInformationCardExpirationMonth = "12";
            string paymentInformationCardExpirationYear  = "2031";
            string paymentInformationCardSecurityCode    = "123";
            Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard(
                Number: paymentInformationCardNumber,
                ExpirationMonth: paymentInformationCardExpirationMonth,
                ExpirationYear: paymentInformationCardExpirationYear,
                SecurityCode: paymentInformationCardSecurityCode
                );

            Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation(
                Card: paymentInformationCard
                );

            string orderInformationAmountDetailsTotalAmount      = "2325.00";
            string orderInformationAmountDetailsCurrency         = "USD";
            string orderInformationAmountDetailsServiceFeeAmount = "30.0";
            Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails(
                TotalAmount: orderInformationAmountDetailsTotalAmount,
                Currency: orderInformationAmountDetailsCurrency,
                ServiceFeeAmount: orderInformationAmountDetailsServiceFeeAmount
                );

            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
                );

            string merchantInformationServiceFeeDescriptorName    = "Vacations Service Fee";
            string merchantInformationServiceFeeDescriptorContact = "8009999999";
            string merchantInformationServiceFeeDescriptorState   = "CA";
            Ptsv2paymentsMerchantInformationServiceFeeDescriptor merchantInformationServiceFeeDescriptor = new Ptsv2paymentsMerchantInformationServiceFeeDescriptor(
                Name: merchantInformationServiceFeeDescriptorName,
                Contact: merchantInformationServiceFeeDescriptorContact,
                State: merchantInformationServiceFeeDescriptorState
                );

            Ptsv2paymentsMerchantInformation merchantInformation = new Ptsv2paymentsMerchantInformation(
                ServiceFeeDescriptor: merchantInformationServiceFeeDescriptor
                );

            var requestObj = new CreatePaymentRequest(
                ClientReferenceInformation: clientReferenceInformation,
                ProcessingInformation: processingInformation,
                PaymentInformation: paymentInformation,
                OrderInformation: orderInformation,
                MerchantInformation: merchantInformation
                );

            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);
            }
        }
Beispiel #3
0
        public static PtsV2PaymentsPost201Response Run()
        {
            var processingInformationObj = new Ptsv2paymentsProcessingInformation()
            {
                CommerceIndicator = "internet"
            };

            var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation {
                Code = "test_payment"
            };

            var billToObj = new Ptsv2paymentsOrderInformationBillTo
            {
                Country            = "US",
                FirstName          = "John",
                LastName           = "Doe",
                Address1           = "1 Market St",
                PostalCode         = "94105",
                Locality           = "San Francisco",
                AdministrativeArea = "CA",
                Email = "*****@*****.**"
            };

            var amountDetailsObj = new Ptsv2paymentsOrderInformationAmountDetails
            {
                TotalAmount      = "2325.00",
                Currency         = "USD",
                ServiceFeeAmount = "30.00"
            };

            var orderInformationObj = new Ptsv2paymentsOrderInformation();

            orderInformationObj.BillTo        = billToObj;
            orderInformationObj.AmountDetails = amountDetailsObj;

            var cardObj = new Ptsv2paymentsPaymentInformationCard
            {
                ExpirationYear  = "2031",
                Number          = "4111111111111111",
                ExpirationMonth = "12"
            };

            var paymentInformationObj = new Ptsv2paymentsPaymentInformation();

            paymentInformationObj.Card = cardObj;

            var serviceFeeDescriptorObj = new Ptsv2paymentsMerchantInformationServiceFeeDescriptor
            {
                Name    = "CyberSource Service Fee",
                Contact = "800-999-9999",
                State   = "CA",
            };

            var merchantInformationObj = new Ptsv2paymentsMerchantInformation();

            merchantInformationObj.ServiceFeeDescriptor = serviceFeeDescriptorObj;

            var requestObj = new CreatePaymentRequest
            {
                ProcessingInformation      = processingInformationObj,
                PaymentInformation         = paymentInformationObj,
                ClientReferenceInformation = clientReferenceInformationObj,
                OrderInformation           = orderInformationObj,
                MerchantInformation        = merchantInformationObj
            };

            if (CaptureTrueForProcessPayment)
            {
                requestObj.ProcessingInformation.Capture = true;
            }

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
                var apiInstance      = new PaymentsApi(clientConfig);

                var result = apiInstance.CreatePayment(requestObj);

                Console.WriteLine(result);

                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
                return(null);
            }
        }