Пример #1
0
    public string DoCaptureCode(string authorization_id, string amount)
    {
        CallerServices caller = new CallerServices();

        IAPIProfile profile = ProfileFactory.createSSLAPIProfile();

        profile.APIUsername     = "******";
        profile.APIPassword     = "******";
        profile.CertificateFile = @"~\MyTestCertificate.txt";
        profile.Environment     = "sandbox";
        caller.APIProfile       = profile;

        DoCaptureRequestType pp_request = new DoCaptureRequestType();

        pp_request.Version = "51.0";

        pp_request.AuthorizationID   = authorization_id;
        pp_request.Amount            = new BasicAmountType();
        pp_request.Amount.Value      = amount;
        pp_request.Amount.currencyID = CurrencyCodeType.GBP;
        pp_request.CompleteType      = CompleteCodeType.Complete;

        DoCaptureResponseType pp_response = new DoCaptureResponseType();

        pp_response = (DoCaptureResponseType)caller.Call("DoCapture", pp_request);
        return(pp_response.Ack.ToString());
    }
Пример #2
0
        public PayPalAccountInfo(PayPalSettings settings, IAPIProfile profile, CallerServices caller)
        {
            this.settings = settings;
            this.caller   = caller;

            profile.APIUsername  = settings.Username;
            profile.APIPassword  = settings.Password;
            profile.APISignature = settings.Signature;
            profile.Environment  = settings.Environment;

            caller.APIProfile = profile;
        }
        public PaypalDirectPaymentProcessor(CreditCard creditCard, PayPalSettings settings)
        {
            this.settings = settings;
            this.caller   = caller;

            profile.APIUsername  = settings.Username;
            profile.APIPassword  = settings.Password;
            profile.APISignature = settings.Signature;
            profile.Environment  = settings.Environment;

            caller.APIProfile = profile;
            this.creditCard = creditCard;
        }
Пример #4
0
        public string CreateRecurringPaymentsProfileCode(string token, DateTime date, string amount, int BF, BillingPeriodType BP, CurrencyCodeType currencyCodeType)
        {
            CallerServices caller = new CallerServices();

            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();

            /*
             * WARNING: Do not embed plaintext credentials in your application code.
             * Doing so is insecure and against best practices.
             * Your API credentials must be handled securely. Please consider
             * encrypting them for use in any production environment, and ensure
             * that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, and API version.
            profile.APIUsername  = "******";
            profile.APIPassword  = "******";
            profile.APISignature = "AsaWhdg.F1DEJUmkrAOGADAhmx2zAhz6qMKqOp5lTasZcyA1TAVoQrzO";
            profile.Environment  = "live";

            caller.APIProfile = profile;

            // Create the request object.



            CreateRecurringPaymentsProfileRequestType pp_request = new CreateRecurringPaymentsProfileRequestType();

            pp_request.Version = "51.0";



            // Add request-specific fields to the request.
            pp_request.CreateRecurringPaymentsProfileRequestDetails       = new CreateRecurringPaymentsProfileRequestDetailsType();
            pp_request.CreateRecurringPaymentsProfileRequestDetails.Token = "";
            pp_request.CreateRecurringPaymentsProfileRequestDetails.RecurringPaymentsProfileDetails = new RecurringPaymentsProfileDetailsType();
            pp_request.CreateRecurringPaymentsProfileRequestDetails.RecurringPaymentsProfileDetails.BillingStartDate = date;
            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails = new ScheduleDetailsType();
            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod                   = new BillingPeriodDetailsType();
            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.Amount            = new BasicAmountType();
            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.Amount.Value      = amount;
            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.Amount.currencyID = currencyCodeType; //Enum for currency code is  CurrencyCodeType.USD
            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.BillingFrequency  = BF;
            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.BillingPeriod     = BP;               ////Enum for BillingPeriod is  BillingPeriodType.Day

            // Execute the API operation and obtain the response.
            CreateRecurringPaymentsProfileResponseType pp_response = new CreateRecurringPaymentsProfileResponseType();

            pp_response = (CreateRecurringPaymentsProfileResponseType)caller.Call("CreateRecurringPaymentsProfile", pp_request);
            return(pp_response.Errors[0].LongMessage);
        }
        public string CreateRecurringPaymentsProfileCode(string token, DateTime date, string amount, int BF, BillingPeriodType BP, CurrencyCodeType currencyCodeType)
        {
            CallerServices caller = new CallerServices();

            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
            /*
             WARNING: Do not embed plaintext credentials in your application code.
             Doing so is insecure and against best practices.
             Your API credentials must be handled securely. Please consider
             encrypting them for use in any production environment, and ensure
             that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, and API version.
            profile.APIUsername = "******";
            profile.APIPassword = "******";
            profile.APISignature = "AsaWhdg.F1DEJUmkrAOGADAhmx2zAhz6qMKqOp5lTasZcyA1TAVoQrzO";
            profile.Environment = "live";

            caller.APIProfile = profile;

            // Create the request object.

            CreateRecurringPaymentsProfileRequestType pp_request = new CreateRecurringPaymentsProfileRequestType();
            pp_request.Version = "51.0";

            // Add request-specific fields to the request.
            pp_request.CreateRecurringPaymentsProfileRequestDetails = new CreateRecurringPaymentsProfileRequestDetailsType();
            pp_request.CreateRecurringPaymentsProfileRequestDetails.Token = "";
            pp_request.CreateRecurringPaymentsProfileRequestDetails.RecurringPaymentsProfileDetails = new RecurringPaymentsProfileDetailsType();
            pp_request.CreateRecurringPaymentsProfileRequestDetails.RecurringPaymentsProfileDetails.BillingStartDate = date;
            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails = new ScheduleDetailsType();
            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod = new BillingPeriodDetailsType();
            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.Amount = new BasicAmountType();
            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.Amount.Value = amount;
            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.Amount.currencyID = currencyCodeType;//Enum for currency code is  CurrencyCodeType.USD
            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.BillingFrequency = BF;
            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.BillingPeriod = BP;////Enum for BillingPeriod is  BillingPeriodType.Day

            // Execute the API operation and obtain the response.
            CreateRecurringPaymentsProfileResponseType pp_response = new CreateRecurringPaymentsProfileResponseType();
            pp_response = (CreateRecurringPaymentsProfileResponseType)caller.Call("CreateRecurringPaymentsProfile", pp_request);
            return pp_response.Errors[0].LongMessage;
        }
        ///// <summary>
        ///// Get Paypal country code
        ///// </summary>
        ///// <param name="country">Country</param>
        ///// <returns>Paypal country code</returns>
        //protected CountryCodeType GetPaypalCountryCodeType(Country country)
        //{
        //    CountryCodeType payerCountry = CountryCodeType.IN;
        //    try
        //    {
        //        payerCountry = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), country.TwoLetterIsoCode);
        //    }
        //    catch
        //    {
        //    }
        //    return payerCountry;
        //}
        ///// <summary>
        ///// Get Paypal credit card type
        ///// </summary>
        ///// <param name="CreditCardType">Credit card type</param>
        ///// <returns>Paypal credit card type</returns>
        //protected CreditCardTypeType GetPaypalCreditCardType(string CreditCardType)
        //{
        //    CreditCardTypeType creditCardTypeType = (CreditCardTypeType)Enum.Parse(typeof(CreditCardTypeType), CreditCardType);
        //    return creditCardTypeType;
        //}
        private void InitSettings()
        {
            APIAccountUsername = "******";
            APIAccountPassword = "******";
            APIAccountSignature = "AtP7rLd7TBR7eGbquoauyoA.T0bXAEgVPCgWRJ7.pbYP9lvnEWI2G4k6";
            Environment = "sandbox";

            //if (string.IsNullOrEmpty(APIAccountUsername))
            //    throw new NopException("Paypal Direct API Account Username is empty");

            //if (string.IsNullOrEmpty(APIAccountPassword))
            //    throw new NopException("Paypal Direct API Account Password is empty");

            //if (string.IsNullOrEmpty(APIAccountSignature))
            //    throw new NopException("Paypal Direct API Account Signature is empty");

            caller = new CallerServices();
            profile = ProfileFactory.createSignatureAPIProfile();

            profile.APIUsername = APIAccountUsername;
            profile.APIPassword = APIAccountPassword;
            profile.APISignature = APIAccountSignature;
            profile.Environment = Environment;
            caller.APIProfile = profile;
        }
        ///// <summary>
        ///// Process payment
        ///// </summary>
        ///// <param name="paymentInfo">Payment info required for an order processing</param>
        ///// <param name="customer">Customer</param>
        ///// <param name="orderGuid">Unique order identifier</param>
        ///// <param name="processPaymentResult">Process payment result</param>
        //public void ProcessPayment(PaymentInfo paymentInfo, Customer customer,
        //        Guid orderGuid, ref ProcessPaymentResult processPaymentResult, bool TransactMode)
        //{
        //    if (TransactMode)
        //    {
        //        AuthorizeOrSale(paymentInfo, customer, orderGuid, processPaymentResult, true);
        //        if (!String.IsNullOrEmpty(processPaymentResult.Error))
        //            return;
        //    }
        //    else
        //    {
        //        AuthorizeOrSale(paymentInfo, customer, orderGuid, processPaymentResult, false);
        //        if (!String.IsNullOrEmpty(processPaymentResult.Error))
        //            return;
        //    }
        //}
        /// <summary>
        /// Authorizes the payment
        /// </summary>
        /// <param name="paymentInfo">Payment info required for an order processing</param>
        /// <param name="customer">Customer</param>
        /// <param name="orderGuid">Unique order identifier</param>
        /// <param name="processPaymentResult">Process payment result</param>
        /// <param name="authorizeOnly">A value indicating whether to authorize only; true - authorize; false - sale</param>
        //protected void AuthorizeOrSale(PaymentInfo paymentInfo, Customer customer,
        //    Guid orderGuid, ProcessPaymentResult processPaymentResult, bool authorizeOnly)
        //{
        //    //InitSettings();
        //    DoDirectPaymentRequestType request = new DoDirectPaymentRequestType();
        //    DoDirectPaymentRequestDetailsType details = new DoDirectPaymentRequestDetailsType();
        //    request.Version = this.APIVersion;
        //    request.DoDirectPaymentRequestDetails = details;
        //    details.IPAddress = HttpContext.Current.Request.UserHostAddress;
        //    details.MerchantSessionId = "1X911810264059026";
        //    if (authorizeOnly)
        //        details.PaymentAction = PaymentActionCodeType.Authorization;
        //    else
        //        details.PaymentAction = PaymentActionCodeType.Sale;
        //    details.CreditCard = new CreditCardDetailsType();
        //    details.CreditCard.CreditCardTypeSpecified = true;
        //    details.CreditCard.CreditCardNumber = paymentInfo.CreditCardNumber;
        //    details.CreditCard.CreditCardType = GetPaypalCreditCardType(paymentInfo.CreditCardType);
        //    details.CreditCard.CVV2 = paymentInfo.CreditCardCvv2;
        //    details.CreditCard.ExpMonth = paymentInfo.CreditCardExpireMonth;
        //    details.CreditCard.ExpYear = paymentInfo.CreditCardExpireYear;
        //    details.CreditCard.ExpMonthSpecified = true;
        //    details.CreditCard.ExpYearSpecified = true;
        //    details.CreditCard.CardOwner = new PayerInfoType();
        //    details.CreditCard.CardOwner.Payer = "";
        //    details.CreditCard.CardOwner.PayerID = "";
        //    details.CreditCard.CardOwner.PayerStatus = PayPalUserStatusCodeType.unverified;
        //    details.CreditCard.CardOwner.PayerCountry = "India";
        //    details.CreditCard.CardOwner.Address = new AddressType();
        //    details.CreditCard.CardOwner.Address.CountrySpecified = true;
        //    details.CreditCard.CardOwner.Address.Street1 = paymentInfo.BillingAddress.Address1;
        //    details.CreditCard.CardOwner.Address.Street2 = paymentInfo.BillingAddress.Address2;
        //    details.CreditCard.CardOwner.Address.CityName = paymentInfo.BillingAddress.City;
        //    if (paymentInfo.BillingAddress.StateProvince != null)
        //        details.CreditCard.CardOwner.Address.StateOrProvince = paymentInfo.BillingAddress.StateProvince.Abbreviation;
        //    else
        //        details.CreditCard.CardOwner.Address.StateOrProvince = "CA";
        //    details.CreditCard.CardOwner.Address.PostalCode = paymentInfo.BillingAddress.ZipPostalCode;
        //    details.CreditCard.CardOwner.Address.CountryName = paymentInfo.BillingAddress.Country.Name;
        //    details.CreditCard.CardOwner.Address.Country = GetPaypalCountryCodeType(paymentInfo.BillingAddress.Country);
        //    details.CreditCard.CardOwner.Address.CountrySpecified = true;
        //    details.CreditCard.CardOwner.Payer = paymentInfo.BillingAddress.Email;
        //    details.CreditCard.CardOwner.PayerName = new PersonNameType();
        //    details.CreditCard.CardOwner.PayerName.FirstName = paymentInfo.BillingAddress.FirstName;
        //    details.CreditCard.CardOwner.PayerName.LastName = paymentInfo.BillingAddress.LastName;
        //    details.PaymentDetails = new PaymentDetailsType();
        //    details.PaymentDetails.OrderTotal = new BasicAmountType();
        //    details.PaymentDetails.OrderTotal.Value = paymentInfo.OrderTotal.ToString("N", new CultureInfo("en-us"));
        //    details.PaymentDetails.OrderTotal.currencyID = PayPalHelper.GetPaypalCurrency("INR");
        //    details.PaymentDetails.Custom = orderGuid.ToString();
        //    if (paymentInfo.ShippingAddress != null)
        //    {
        //        if (paymentInfo.ShippingAddress.StateProvince != null && paymentInfo.ShippingAddress.Country != null)
        //        {
        //            AddressType shippingAddress = new AddressType();
        //            shippingAddress.Name = paymentInfo.ShippingAddress.FirstName + " " + paymentInfo.ShippingAddress.LastName;
        //            shippingAddress.Street1 = paymentInfo.ShippingAddress.Address1;
        //            shippingAddress.CityName = paymentInfo.ShippingAddress.City;
        //            shippingAddress.StateOrProvince = paymentInfo.ShippingAddress.StateProvince.Abbreviation;
        //            shippingAddress.PostalCode = paymentInfo.ShippingAddress.ZipPostalCode;
        //            shippingAddress.Country = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), paymentInfo.ShippingAddress.Country.TwoLetterIsoCode, true);
        //            shippingAddress.CountrySpecified = true;
        //            details.PaymentDetails.ShipToAddress = shippingAddress;
        //        }
        //    }
        //    DoDirectPaymentResponseType response = new DoDirectPaymentResponseType();
        //    response = (DoDirectPaymentResponseType)caller.Call("DoDirectPayment", request);
        //    string error = string.Empty;
        //    bool Success = PayPalHelper.CheckSuccess(customer.LanguageId, response, out error);
        //    if (Success)
        //    {
        //        processPaymentResult.AVSResult = response.AVSCode;
        //        processPaymentResult.AuthorizationTransactionCode = response.CVV2Code;
        //        if (authorizeOnly)
        //        {
        //            processPaymentResult.AuthorizationTransactionId = response.TransactionID;
        //            processPaymentResult.AuthorizationTransactionResult = response.Ack.ToString();
        //            processPaymentResult.PaymentStatus = "Authorized";
        //        }
        //        else
        //        {
        //            processPaymentResult.CaptureTransactionId = response.TransactionID;
        //            processPaymentResult.CaptureTransactionResult = response.Ack.ToString();
        //            processPaymentResult.PaymentStatus = "Paid";
        //        }
        //    }
        //    else
        //    {
        //        processPaymentResult.Error = error;
        //        processPaymentResult.FullError = error;
        //    }
        //}
        public string DoDirectPaymentCode(string paymentAmount, string buyerLastName, 
                string buyerFirstName, string buyerAddress1, string buyerAddress2, 
                string buyerCity, string buyerState, string buyerZipCode, 
                string creditCardType, string creditCardNumber, string CVV2, int expMonth, int expYear)
        {
            CallerServices caller = new CallerServices();

            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
            /*
             WARNING: Do not embed plaintext credentials in your application code.
             Doing so is insecure and against best practices.
             Your API credentials must be handled securely. Please consider
             encrypting them for use in any production environment, and ensure
             that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, and API version.
            profile.APIUsername = "******";
            profile.APIPassword = "******";
            profile.APISignature = "AtP7rLd7TBR7eGbquoauyoA.T0bXAEgVPCgWRJ7.pbYP9lvnEWI2G4k6";
            profile.Environment = "sandbox";

            caller.APIProfile = profile;
            // Create the request object.
            DoDirectPaymentRequestType pp_Request = new DoDirectPaymentRequestType();
            //DoDirectPaymentRequestDetailsType details = new DoDirectPaymentRequestDetailsType();
            pp_Request.Version = APIVersion;

            // Add request-specific fields to the request.
            // Create the request details object.
            pp_Request.DoDirectPaymentRequestDetails = new DoDirectPaymentRequestDetailsType();
            //details.IPAddress = HttpContext.Current.Request.UserHostAddress;
            //details.MerchantSessionId = "1X911810264059026";
            pp_Request.DoDirectPaymentRequestDetails.IPAddress = HttpContext.Current.Request.UserHostAddress;
            pp_Request.DoDirectPaymentRequestDetails.MerchantSessionId = "1X911810264059026";
            //details.PaymentAction = PaymentActionCodeType.Sale;
            pp_Request.DoDirectPaymentRequestDetails.PaymentAction = PaymentActionCodeType.Sale;
            pp_Request.DoDirectPaymentRequestDetails.CreditCard = new CreditCardDetailsType();
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardNumber = creditCardNumber;
            switch (creditCardType)
            {
                case "Visa":
                    pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Visa;
                    break;
                case "MasterCard":
                    pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.MasterCard;
                    break;
                case "Discover":
                    pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Discover;
                    break;
                case "Amex":
                    pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Amex;
                    break;
            }
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CVV2 = CVV2;
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpMonth = expMonth;
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpMonthSpecified = true;

            pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpYear = expYear;
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpYearSpecified = true;

            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner = new PayerInfoType();
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Payer = "";
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerID = "";
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerStatus = PayPalUserStatusCodeType.unverified;
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerCountry = CountryCodeType.US;

            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address = new AddressType();
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Street1 = buyerAddress1;
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Street2 = buyerAddress2;
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CityName = buyerCity;
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.StateOrProvince = buyerState;
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.PostalCode = buyerZipCode;
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CountryName = "INR";
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Country = CountryCodeType.IN;
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CountrySpecified = true;

            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName = new PersonNameType();
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName.FirstName = buyerFirstName;
            pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName.LastName = buyerLastName;
            pp_Request.DoDirectPaymentRequestDetails.PaymentDetails = new PaymentDetailsType();
            pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal = new BasicAmountType();

            // NOTE: The only currency supported by the Direct Payment API at this time is US dollars (USD).

            pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal.currencyID = CurrencyCodeType.USD;
            pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal.Value = paymentAmount;

            // Execute the API operation and obtain the response.
            DoDirectPaymentResponseType pp_response = new DoDirectPaymentResponseType();
            pp_response = (DoDirectPaymentResponseType)caller.Call("DoDirectPayment", pp_Request);

            InsPayDetails(pp_response.TransactionID);

            return pp_response.Ack.ToString();

            //InitSettings();

            //DoDirectPaymentRequestType request = new DoDirectPaymentRequestType();
            //DoDirectPaymentRequestDetailsType details = new DoDirectPaymentRequestDetailsType();

            //request.Version = this.APIVersion;
            //request.DoDirectPaymentRequestDetails = details;
            //details.IPAddress = HttpContext.Current.Request.UserHostAddress;
            //details.MerchantSessionId = "1X911810264059026";

            ////if (authorizeOnly)
            //details.PaymentAction = PaymentActionCodeType.Sale;
            ////else
            ////    details.PaymentAction = PaymentActionCodeType.Sale;

            //details.CreditCard = new CreditCardDetailsType();
            //details.CreditCard.CreditCardTypeSpecified = true;
            //details.CreditCard.CreditCardNumber = creditCardNumber;
            //details.CreditCard.CreditCardType = CreditCardTypeType.Visa;
            //details.CreditCard.CVV2 = CVV2;
            //details.CreditCard.ExpMonth = expMonth;
            //details.CreditCard.ExpYear = expYear;
            //details.CreditCard.ExpMonthSpecified = true;
            //details.CreditCard.ExpYearSpecified = true;
            //details.CreditCard.CardOwner = new PayerInfoType();
            //details.CreditCard.CardOwner.Payer = "";
            //details.CreditCard.CardOwner.PayerID = "";
            //details.CreditCard.CardOwner.PayerStatus = PayPalUserStatusCodeType.unverified;
            //details.CreditCard.CardOwner.PayerCountry = CountryCodeType.US;

            //details.CreditCard.CardOwner.Address = new AddressType();
            //details.CreditCard.CardOwner.Address.CountrySpecified = true;
            //details.CreditCard.CardOwner.Address.Street1 = "Test Street1";
            //details.CreditCard.CardOwner.Address.Street2 = "Test Street2";
            //details.CreditCard.CardOwner.Address.CityName = "Test City";
            ////if (paymentInfo.BillingAddress.StateProvince != null)
            ////    details.CreditCard.CardOwner.Address.StateOrProvince = paymentInfo.BillingAddress.StateProvince.Abbreviation;
            ////else
            //    details.CreditCard.CardOwner.Address.StateOrProvince = "CA";
            //    details.CreditCard.CardOwner.Address.PostalCode = "560032";
            //    details.CreditCard.CardOwner.Address.CountryName = "US";
            //    details.CreditCard.CardOwner.Address.Country = CountryCodeType.US;
            //details.CreditCard.CardOwner.Address.CountrySpecified = true;
            //details.CreditCard.CardOwner.Payer = "*****@*****.**";
            //details.CreditCard.CardOwner.PayerName = new PersonNameType();
            //details.CreditCard.CardOwner.PayerName.FirstName = buyerFirstName;
            //details.CreditCard.CardOwner.PayerName.LastName = buyerLastName;
            //details.PaymentDetails = new PaymentDetailsType();
            //details.PaymentDetails.OrderTotal = new BasicAmountType();
            //details.PaymentDetails.OrderTotal.Value = paymentAmount;
            //details.PaymentDetails.OrderTotal.currencyID = PayPalHelper.GetPaypalCurrency("US");
            //details.PaymentDetails.Custom = Guid.NewGuid().ToString();

            ////if (paymentInfo.ShippingAddress != null)
            ////{
            ////    if (paymentInfo.ShippingAddress.StateProvince != null && paymentInfo.ShippingAddress.Country != null)
            ////    {
            //        AddressType shippingAddress = new AddressType();
            //        shippingAddress.Name = "Ramesh rc";
            //        shippingAddress.Street1 = "Test street";
            //        shippingAddress.CityName = "Test City";
            //        shippingAddress.StateOrProvince = "Karnadaka";
            //        shippingAddress.PostalCode = "560032";
            //        shippingAddress.Country = CountryCodeType.US;
            //        shippingAddress.CountrySpecified = true;
            //        details.PaymentDetails.ShipToAddress = shippingAddress;
            ////    }
            ////}

            //DoDirectPaymentResponseType response = new DoDirectPaymentResponseType();
            //response = (DoDirectPaymentResponseType)caller.Call("DoDirectPayment", request);
            //return response.Ack.ToString();
        }
Пример #8
0
 public PayPalAPI(com.paypal.sdk.profiles.IAPIProfile PayPalProfile)
 {
     caller = new CallerServices();
     caller.APIProfile = PayPalProfile;
 }
Пример #9
0
 public PayPalAPI(com.paypal.sdk.profiles.IAPIProfile PayPalProfile)
 {
     caller            = new CallerServices();
     caller.APIProfile = PayPalProfile;
 }
Пример #10
0
 public PayPalAPI(IAPIProfile PayPalProfile)
 {
     caller = new CallerServices {
         APIProfile = PayPalProfile
     };
 }
Пример #11
0
 private static CallerServices CreateCaller()
 {
     CallerServices caller = new CallerServices();
     IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
     profile.APIUsername = Settings.Default.PayPalApiUsername;
     profile.APIPassword = Settings.Default.PayPalApiPassword;
     profile.APISignature = Settings.Default.PayPalApiSignature;
     profile.Environment = Settings.Default.PayPalApiEnvironment;
     caller.APIProfile = profile;
     return caller;
 }
Пример #12
0
    public com.paypal.soap.api.DoDirectPaymentResponseType TakeCardPayment(
        com.paypal.soap.api.CreditCardTypeType cardType,
        string cardNumber,
        int startMonth,
        int startYear,
        int expMonth,
        int expYear,
        int CVV2,
        string firstName,
        string lastName,
        string payerName,
        string street1,
        string street2,
        string city,
        string state,
        string postCode,
        CountryCodeType country,
        decimal amount,
        com.paypal.soap.api.CurrencyCodeType currency,
        string ipAddress,
        com.paypal.soap.api.PaymentActionCodeType paymentType)
    {
        CallerServices caller = new CallerServices();
        IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
        profile.APIUsername = APIUsername;
        profile.APIPassword = APIPassword;
        profile.Environment = StartPage.UseTestEnvironment ? "sandbox" : "live";
        profile.Subject = "";
        profile.APISignature = APISignature;
        caller.APIProfile = profile;
        com.paypal.soap.api.DoDirectPaymentRequestDetailsType directPaymentDetails = new com.paypal.soap.api.DoDirectPaymentRequestDetailsType();

        //Set Credit Card
        com.paypal.soap.api.CreditCardDetailsType cc = new com.paypal.soap.api.CreditCardDetailsType();
        cc.CreditCardType = cardType;
        cc.CreditCardNumber = cardNumber;
        cc.StartMonth = startMonth;
        cc.StartMonthSpecified = true;
        cc.StartYear = startYear;
        cc.StartYearSpecified = true;
        cc.ExpMonth = expMonth;
        cc.ExpMonthSpecified = true;
        cc.ExpYear = expYear;
        cc.ExpYearSpecified = true;
        cc.CVV2 = CVV2.ToString();
        //Set Credit Card.CardOwner
        com.paypal.soap.api.PayerInfoType theCardOwner = new com.paypal.soap.api.PayerInfoType();
        com.paypal.soap.api.PersonNameType thePayerName = new com.paypal.soap.api.PersonNameType();
        thePayerName.FirstName = firstName;
        thePayerName.LastName = lastName;
        theCardOwner.PayerName = thePayerName;
        com.paypal.soap.api.AddressType theAddress = new com.paypal.soap.api.AddressType();
        theAddress.Street1 = street1;
        theAddress.Street2 = street2;
        theAddress.CityName = city;
        theAddress.StateOrProvince = state;
        theAddress.PostalCode = postCode;
        theAddress.Country = country;
        theCardOwner.Address = theAddress;
        cc.CardOwner = theCardOwner;
        directPaymentDetails.CreditCard = cc;
        //Set Order Total
        com.paypal.soap.api.BasicAmountType temp = new com.paypal.soap.api.BasicAmountType();
        com.paypal.soap.api.PaymentDetailsType payDetailType = new com.paypal.soap.api.PaymentDetailsType();
        temp.Value = string.Format("{0:0.00}", amount);
        temp.currencyID = currency;
        payDetailType.OrderTotal = temp;
        directPaymentDetails.PaymentDetails = payDetailType;
        //Set IP
        directPaymentDetails.IPAddress = ipAddress;
        //Set Transaction Type
        directPaymentDetails.PaymentAction = paymentType;

        //Set Request
        com.paypal.soap.api.DoDirectPaymentRequestType request = new com.paypal.soap.api.DoDirectPaymentRequestType();

        //Set Payment Detail
        request.DoDirectPaymentRequestDetails = directPaymentDetails;

        request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CountrySpecified = true;
        return (com.paypal.soap.api.DoDirectPaymentResponseType)caller.Call("DoDirectPayment", request);
    }