public void GetShippingDiscountProfiles()
        {
            GetShippingDiscountProfilesCall api = new GetShippingDiscountProfilesCall(this.apiContext);
            CurrencyCodeType currency           = api.GetShippingDiscountProfiles();

            Assert.IsNotNull(currency);
        }
示例#2
0
 /// <summary>
 /// Convert value to PayPal amount type
 /// </summary>
 /// <param name="value"></param>
 /// <param name="currencyId"></param>
 /// <returns>a basic amount type of PayPal, with 2 decimal digits value</returns>
 public static BasicAmountType ToPayPalAmount(this decimal value, CurrencyCodeType currencyId)
 {
     return(new BasicAmountType()
     {
         value = value.ToString("0.00", CultureInfo.InvariantCulture), currencyID = currencyId
     });
 }
示例#3
0
        public InvoiceType HeatherAndIssueData(string invoiceNumber, InvoiceDocumentTypeType invoiceDocumentType, InvoiceClassType invoiceClassType, DateTime issueDate,
                                               CurrencyCodeType invoiceCurrencyCode, LanguageCodeType languageCodeType)
        {
            this.InvoiceHeader = new InvoiceHeaderType()
            {
                InvoiceNumber       = invoiceNumber,
                InvoiceDocumentType = invoiceDocumentType,
                InvoiceClass        = invoiceClassType
            };

            this.InvoiceIssueData = new InvoiceIssueDataType()
            {
                IssueDate           = issueDate,
                TaxCurrencyCode     = invoiceCurrencyCode,
                LanguageName        = languageCodeType,
                InvoiceCurrencyCode = invoiceCurrencyCode
            };

            this.TaxesOutputs  = new TaxOutputType[] { };
            this.InvoiceTotals = new InvoiceTotalsType();

            this.InvoiceTotals.InvoiceTotal                = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalGrossAmount            = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalGeneralDiscounts       = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalGeneralSurcharges      = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalGrossAmountBeforeTaxes = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalTaxOutputs             = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalTaxesWithheld          = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalOutstandingAmount      = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalExecutableAmount       = new DoubleTwoDecimalType();

            //invoice.InvoiceIssueData.InvoicingPeriod = new PeriodDates() { StartDate = invoicingPeriodStartDate, EndDate = invoicingPeriodEndDate };
            return(this);
        }
示例#4
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object
            DoUATPAuthorizationRequestType request = new DoUATPAuthorizationRequestType();

            request.UATPDetails            = new UATPDetailsType();
            request.UATPDetails.UATPNumber = uatpNumber.Value;
            request.UATPDetails.ExpMonth   = Int32.Parse(expMonth.Value);
            request.UATPDetails.ExpYear    = Int32.Parse(expYear.Value);

            request.TransactionEntity = (TransactionEntityType)
                                        Enum.Parse(typeof(TransactionEntityType), transactionEntity.SelectedValue);

            CurrencyCodeType currency = (CurrencyCodeType)
                                        Enum.Parse(typeof(CurrencyCodeType), currencyID.Value);

            request.Amount = new BasicAmountType(currency, amount.Value);


            // Invoke the API
            DoUATPAuthorizationReq wrapper = new DoUATPAuthorizationReq();

            wrapper.DoUATPAuthorizationRequest = request;
            PayPalAPIInterfaceServiceService service  = new PayPalAPIInterfaceServiceService();
            DoUATPAuthorizationResponseType  response = service.DoUATPAuthorization(wrapper);

            // Check for API return status
            setKeyResponseObjects(service, response);
        }
示例#5
0
        public APIWrapper(string apiUserName, string apiPassword, string signature, CurrencyCode defaultCurrencyCode, bool isLive)
        {
            //TODO: CMC - Add Validation Here
            _apiUserName = apiUserName;
            _apiPassword = apiPassword;
            _signature   = signature;
            if (!Enum.IsDefined(typeof(CurrencyCodeType), Enum.GetName(typeof(CurrencyCode), defaultCurrencyCode)))
            {
                throw new ArgumentException(string.Format("Provided currency code is not a valid PayPalSvc.CurrencyCodeType. Currency Code: {0}.", defaultCurrencyCode), "defaultCurrencyCode");
            }
            ppCurrencyType = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), Enum.GetName(typeof(CurrencyCode), defaultCurrencyCode), true);
            _currencyCode  = defaultCurrencyCode;
            _isLive        = isLive;

            service     = new PayPalAPISoapBinding();
            service.Url = PayPalServiceUtility.GetPayPalServiceEndpoint(IsLive, true, true);
            service.RequesterCredentials                       = new CustomSecurityHeaderType();
            service.RequesterCredentials.Credentials           = new UserIdPasswordType();
            service.RequesterCredentials.Credentials.Username  = APIUserName;
            service.RequesterCredentials.Credentials.Password  = APIPassword;
            service.RequesterCredentials.Credentials.Signature = Signature;
            service.RequesterCredentials.Credentials.Subject   = string.Empty;

            service2     = new PayPalAPIAASoapBinding();
            service2.Url = PayPalServiceUtility.GetPayPalServiceEndpoint(IsLive, true, true);
            service2.RequesterCredentials                       = new CustomSecurityHeaderType();
            service2.RequesterCredentials.Credentials           = new UserIdPasswordType();
            service2.RequesterCredentials.Credentials.Username  = APIUserName;
            service2.RequesterCredentials.Credentials.Password  = APIPassword;
            service2.RequesterCredentials.Credentials.Signature = Signature;
            service2.RequesterCredentials.Credentials.Subject   = string.Empty;
        }
示例#6
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object

            DoAuthorizationRequestType request =
                new DoAuthorizationRequestType();

            request.TransactionID = transactionId.Value;
            CurrencyCodeType currency = (CurrencyCodeType)
                                        Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);

            request.Amount = new BasicAmountType(currency, amount.Value);

            // Invoke the API
            DoAuthorizationReq wrapper = new DoAuthorizationReq();

            wrapper.DoAuthorizationRequest = request;
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
            DoAuthorizationResponseType      doAuthorizationResponse =
                service.DoAuthorization(wrapper);


            // Check for API return status
            setKeyResponseObjects(service, doAuthorizationResponse);
        }
示例#7
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object

            BillOutstandingAmountRequestType request =
                new BillOutstandingAmountRequestType();

            BillOutstandingAmountRequestDetailsType details =
                new BillOutstandingAmountRequestDetailsType();

            request.BillOutstandingAmountRequestDetails = details;
            details.ProfileID = profileId.Value;
            if (currencyCode.SelectedIndex != 0 && amount.Value != "")
            {
                CurrencyCodeType currency = (CurrencyCodeType)
                                            Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);
                details.Amount = new BasicAmountType(currency, amount.Value);
            }
            if (note.Value != "")
            {
                details.Note = note.Value;
            }

            // Invoke the API
            BillOutstandingAmountReq wrapper = new BillOutstandingAmountReq();

            wrapper.BillOutstandingAmountRequest = request;
            PayPalAPIInterfaceServiceService  service  = new PayPalAPIInterfaceServiceService();
            BillOutstandingAmountResponseType response =
                service.BillOutstandingAmount(wrapper);


            // Check for API return status
            setKeyResponseObjects(service, response);
        }
示例#8
0
        public InvoiceType HeatherAndIssueData(string invoiceNumber, InvoiceDocumentTypeType invoiceDocumentType, InvoiceClassType invoiceClassType, DateTime issueDate, 
            CurrencyCodeType invoiceCurrencyCode, LanguageCodeType languageCodeType)
        {
            this.InvoiceHeader = new InvoiceHeaderType() 
                { 
                    InvoiceNumber = invoiceNumber, 
                    InvoiceDocumentType = invoiceDocumentType, 
                    InvoiceClass = invoiceClassType 
                };

            this.InvoiceIssueData = new InvoiceIssueDataType() 
                { 
                    IssueDate = issueDate, 
                    TaxCurrencyCode = invoiceCurrencyCode, 
                    LanguageName = languageCodeType, 
                    InvoiceCurrencyCode = invoiceCurrencyCode 
                };

            this.TaxesOutputs = new TaxOutputType[] { };
            this.InvoiceTotals = new InvoiceTotalsType();

            this.InvoiceTotals.InvoiceTotal = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalGrossAmount = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalGeneralDiscounts = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalGeneralSurcharges = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalGrossAmountBeforeTaxes = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalTaxOutputs = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalTaxesWithheld = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalOutstandingAmount = new DoubleTwoDecimalType();
            this.InvoiceTotals.TotalExecutableAmount = new DoubleTwoDecimalType();

            //invoice.InvoiceIssueData.InvoicingPeriod = new PeriodDates() { StartDate = invoicingPeriodStartDate, EndDate = invoicingPeriodEndDate };
            return this;
        }
示例#9
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object
            DoUATPAuthorizationRequestType request = new DoUATPAuthorizationRequestType();

            request.UATPDetails            = new UATPDetailsType();
            request.UATPDetails.UATPNumber = uatpNumber.Value;
            request.UATPDetails.ExpMonth   = Convert.ToInt32(expMonth.Value);
            request.UATPDetails.ExpYear    = Convert.ToInt32(expYear.Value);

            request.TransactionEntity = (TransactionEntityType)
                                        Enum.Parse(typeof(TransactionEntityType), transactionEntity.SelectedValue);

            CurrencyCodeType currency = (CurrencyCodeType)
                                        Enum.Parse(typeof(CurrencyCodeType), currencyID.Value);

            request.Amount = new BasicAmountType(currency, amount.Value);


            // Invoke the API
            DoUATPAuthorizationReq wrapper = new DoUATPAuthorizationReq();

            wrapper.DoUATPAuthorizationRequest = request;

            // Configuration map containing signature credentials and other required configuration.
            // For a full list of configuration parameters refer in wiki page
            // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters]
            Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig();

            PayPalAPIInterfaceServiceService service  = new PayPalAPIInterfaceServiceService(configurationMap);
            DoUATPAuthorizationResponseType  response = service.DoUATPAuthorization(wrapper);

            // Check for API return status
            setKeyResponseObjects(service, response);
        }
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object
            DoUATPExpressCheckoutPaymentRequestType    request        = new DoUATPExpressCheckoutPaymentRequestType();
            DoExpressCheckoutPaymentRequestDetailsType paymentDetails = new DoExpressCheckoutPaymentRequestDetailsType();

            request.DoExpressCheckoutPaymentRequestDetails = paymentDetails;
            paymentDetails.PayerID       = payerID.Value;
            paymentDetails.Token         = token.Value;
            paymentDetails.PaymentAction = (PaymentActionCodeType)
                                           Enum.Parse(typeof(PaymentActionCodeType), paymentAction.SelectedValue);

            // Set payment amount
            CurrencyCodeType currency = (CurrencyCodeType)
                                        Enum.Parse(typeof(CurrencyCodeType), currencyID.Value);

            paymentDetails.PaymentDetails.Add(new PaymentDetailsType());
            paymentDetails.PaymentDetails[0].OrderTotal =
                new BasicAmountType(currency, amount.Value);

            // Invoke the API
            DoUATPExpressCheckoutPaymentReq wrapper = new DoUATPExpressCheckoutPaymentReq();

            wrapper.DoUATPExpressCheckoutPaymentRequest = request;
            PayPalAPIInterfaceServiceService         service  = new PayPalAPIInterfaceServiceService();
            DoUATPExpressCheckoutPaymentResponseType response = service.DoUATPExpressCheckoutPayment(wrapper);

            // Check for API return status
            setKeyResponseObjects(service, response);
        }
示例#11
0
 public static BasicAmountType GetBasicAmountType(this decimal value, CurrencyCodeType currency)
 {
     return(new BasicAmountType
     {
         currencyID = currency,
         Value = Math.Round(value, 2).ToString("N", new CultureInfo("en-us"))
     });
 }
示例#12
0
        public IPaymentResponse DoExpressCheckoutPayment(decimal amount, CurrencyCodeType currencyCodeType, string payPalToken, string payPalPayerId, PaymentAction action)
        {
            if (amount <= 0) throw new ArgumentOutOfRangeException("amount", "Amount must be greater than zero.");
            if (string.IsNullOrWhiteSpace(payPalToken)) throw new ArgumentNullException("payPalToken");
            if (string.IsNullOrWhiteSpace(payPalPayerId)) throw new ArgumentNullException("payPalPayerId");

            var request = _requestBuilder.DoExpressCheckoutPayment(amount,currencyCodeType, payPalToken, payPalPayerId,action);
            return doExpressCheckoutPaymentFor(request);
        }
示例#13
0
        private CurrencyCodeType getCurrencyType(SiteCodeType siteId)
        {
            CurrencyCodeType curr = CurrencyCodeType.USD;

            switch (siteId)
            {
            case SiteCodeType.US:
            case SiteCodeType.eBayMotors:
                curr = CurrencyCodeType.USD;
                break;

            case SiteCodeType.UK:
                curr = CurrencyCodeType.GBP;
                break;

            case SiteCodeType.Canada:
                curr = CurrencyCodeType.CAD;
                break;

            case SiteCodeType.Australia:
                curr = CurrencyCodeType.AUD;
                break;

            case SiteCodeType.Taiwan:
                curr = CurrencyCodeType.TWD;
                break;

            case SiteCodeType.Switzerland:
                curr = CurrencyCodeType.CHF;
                break;

            case SiteCodeType.Poland:
                curr = CurrencyCodeType.PLN;
                break;

            case SiteCodeType.India:
                curr = CurrencyCodeType.INR;
                break;

            case SiteCodeType.France:
            case SiteCodeType.Germany:
            case SiteCodeType.Italy:
            case SiteCodeType.Netherlands:
            case SiteCodeType.Belgium_Dutch:
            case SiteCodeType.Belgium_French:
            case SiteCodeType.Austria:
                curr = CurrencyCodeType.EUR;
                break;

            default:
                curr = CurrencyCodeType.USD;
                break;
            }

            return(curr);
        }
        private PaymentDetailsType GetPaypalPaymentDetail(CurrencyCodeType currency, PaymentActionCodeType paymentAction, PaymentIn payment)
        {
            var paymentDetails = new PaymentDetailsType {
                PaymentAction = paymentAction
            };

            paymentDetails.OrderTotal = new BasicAmountType(currency, FormatMoney(payment.Sum));

            return(paymentDetails);
        }
 /// <summary>
 /// Gets the currency symbol from the CurrencyCodeType
 /// </summary>
 /// <param name="currency">a CurrencyCodeType to get symbol from</param>
 /// <returns>a currency symbol</returns>
 public static string GetCurrencySymbol(CurrencyCodeType currency)
 {
     switch (currency)
     {
         case CurrencyCodeType.USD:
             return "$";
         default:
             return "(" + Enum.GetName(typeof(CurrencyCodeType), currency) + ")";
     }
 }
示例#16
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object
            MassPayRequestType   request          = new MassPayRequestType();
            ReceiverInfoCodeType receiverInfoType = (ReceiverInfoCodeType)
                                                    Enum.Parse(typeof(ReceiverInfoCodeType), receiverType.SelectedValue);

            request.ReceiverType = receiverInfoType;
            if (emailSubject.Value != "")
            {
                request.EmailSubject = emailSubject.Value;
            }


            // Processing a single masspay receiver.
            // You can add upto 250 receivers in one call
            MassPayRequestItemType massPayItem = new MassPayRequestItemType();
            CurrencyCodeType       currency    = (CurrencyCodeType)
                                                 Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);

            massPayItem.Amount = new BasicAmountType(currency, amount.Value);
            if (receiverInfoType.Equals(ReceiverInfoCodeType.EMAILADDRESS) && emailId.Value != "")
            {
                massPayItem.ReceiverEmail = emailId.Value;
            }
            else if (receiverInfoType.Equals(ReceiverInfoCodeType.PHONENUMBER) && phoneNumber.Value != "")
            {
                massPayItem.ReceiverPhone = phoneNumber.Value;
            }
            else if (receiverInfoType.Equals(ReceiverInfoCodeType.USERID) && receiverId.Value != "")
            {
                massPayItem.ReceiverID = receiverId.Value;
            }

            if (note.Value != "")
            {
                massPayItem.Note = note.Value;
            }
            if (uniqueId.Value != "")
            {
                massPayItem.UniqueId = uniqueId.Value;
            }
            request.MassPayItem.Add(massPayItem);


            // Invoke the API
            MassPayReq wrapper = new MassPayReq();

            wrapper.MassPayRequest = request;
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
            MassPayResponseType massPayResponse      = service.MassPay(wrapper);

            // Check for API return status
            processResponse(service, massPayResponse);
        }
示例#17
0
        public PayPalExpressCheckoutToken SetExpressCheckout(decimal amount, CurrencyCodeType currencyCodeType, string cancelUrl, string confirmationUrl)
        {
            if (amount <= 0) throw new ArgumentOutOfRangeException("amount", "Amount must be greater than zero.");
            if (string.IsNullOrWhiteSpace(cancelUrl)) throw new ArgumentNullException("cancelUrl");
            if (string.IsNullOrWhiteSpace(confirmationUrl)) throw new ArgumentNullException("confirmationUrl");

            _logger.Log("SetExpressCheckout.Request", new { Amount = amount, CancelUrl = cancelUrl, ConfirmationUrl = confirmationUrl });

            var request = _requestBuilder.SetExpressCheckout(amount,currencyCodeType, cancelUrl, confirmationUrl);
            return setExpressCheckoutRequestFor(request);
        }
示例#18
0
        public NameValueCollection MassPayment(IEnumerable <PayReceiver> receivers, CurrencyCodeType currencyCodeType, ReceiverType receiverType, string emailSubject)
        {
            var request = getQueryWithCredentials();

            request["METHOD"]       = "MassPay";
            request["CURRENCYCODE"] = currencyCodeType.ToString();
            request["RECEIVERTYPE"] = receiverType.ToString();
            addOptionalValueToRequest("EMAILSUBJECT", emailSubject, request);
            addItems(receiverType, receivers, request);
            return(request);
        }
示例#19
0
 public NameValueCollection DoExpressCheckoutPayment(decimal amount, CurrencyCodeType currencyCodeType, string payPalToken, string payPalPayerId)
 {
     var request = getQueryWithCredentials();
     request["METHOD"] = "DoExpressCheckoutPayment";
     request["TOKEN"] = payPalToken;
     request["PAYERID"] = payPalPayerId;
     request["PAYMENTREQUEST_0_AMT"] = amount.ToString("0.00");
     request["PAYMENTREQUEST_0_CURRENCYCODE"] = currencyCodeType.ToString();
     request["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
     return request;
 }
示例#20
0
 /// <summary>
 /// Gets the numeric currency id of a <see cref="CurrencyCodeType"/>.
 /// </summary>
 /// <param name="CurrencyCodeType">The <see cref="CurrencyCodeType"/>.</param>
 /// <returns>The numeric id associated with the <see cref="CurrencyCodeType"/>.</returns>
 public static int GetCurrencyID(CurrencyCodeType CurrencyCodeType)
 {
     if (!Enum.IsDefined(typeof(CurrencyValueEnum), CurrencyCodeType.ToString()))
     {
         return(-1);
     }
     else
     {
         return((int)Enum.Parse(typeof(CurrencyValueEnum), Enum.GetName(typeof(CurrencyCodeType), CurrencyCodeType)));
     }
 }
示例#21
0
        /// <summary>
        /// Gets the currency symbol from the CurrencyCodeType
        /// </summary>
        /// <param name="currency">a CurrencyCodeType to get symbol from</param>
        /// <returns>a currency symbol</returns>
        public static string GetCurrencySymbol(CurrencyCodeType currency)
        {
            switch (currency)
            {
            case CurrencyCodeType.USD:
                return("$");

            default:
                return("(" + Enum.GetName(typeof(CurrencyCodeType), currency) + ")");
            }
        }
        /// <summary>
        /// Gets the number of decimal places for a particular currency.
        /// </summary>
        /// <param name="currency">
        /// The currency.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        private int GetCurrencyDecimals(CurrencyCodeType currency)
        {
            var currencyDecimals = new CurrencyCodeTypeDecimal
            {
                CurrencyCodeType = currency,
                DecimalPlaces = 2
            };

            FormattingPrice.RaiseEvent(new ObjectEventArgs<CurrencyCodeTypeDecimal>(currencyDecimals), this);

            return currencyDecimals.DecimalPlaces;
        }
示例#23
0
        public static BasicAmountType GetBasicAmountType(this decimal value, CurrencyCodeType currency)
        {
            var currencyService         = EngineContext.Current.Resolve <ICurrencyService>();
            var workContext             = EngineContext.Current.Resolve <IWorkContext>();
            var valueInCustomerCurrency = currencyService.ConvertCurrency(value, workContext.WorkingCurrency.Rate);

            return(new BasicAmountType
            {
                currencyID = currency,
                Value = Math.Round(valueInCustomerCurrency, 2).ToString("N", new CultureInfo("en-us"))
            });
        }
示例#24
0
        /// <summary>
        /// Gets the number of decimal places for a particular currency.
        /// </summary>
        /// <param name="currency">
        /// The currency.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        private int GetCurrencyDecimals(CurrencyCodeType currency)
        {
            var currencyDecimals = new CurrencyCodeTypeDecimal
            {
                CurrencyCodeType = currency,
                DecimalPlaces    = 2
            };

            FormattingPrice.RaiseEvent(new ObjectEventArgs <CurrencyCodeTypeDecimal>(currencyDecimals), this);

            return(currencyDecimals.DecimalPlaces);
        }
示例#25
0
		private static int CurrencyDecimals(CurrencyCodeType currency)
		{
			switch (currency)
			{
				case CurrencyCodeType.HUF:
				case CurrencyCodeType.JPY:
				case CurrencyCodeType.TWD:
					return 0;
				default:
					return 2;
			}
		}
示例#26
0
        public NameValueCollection DoExpressCheckoutPayment(decimal amount, CurrencyCodeType currencyCodeType, string payPalToken, string payPalPayerId)
        {
            var request = getQueryWithCredentials();

            request["METHOD"]  = "DoExpressCheckoutPayment";
            request["TOKEN"]   = payPalToken;
            request["PAYERID"] = payPalPayerId;
            request["PAYMENTREQUEST_0_AMT"]           = amount.AsPayPalFormatString();
            request["PAYMENTREQUEST_0_CURRENCYCODE"]  = currencyCodeType.ToString();
            request["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
            return(request);
        }
示例#27
0
        private static int CurrencyDecimals(CurrencyCodeType currency)
        {
            switch (currency)
            {
            case CurrencyCodeType.HUF:
            case CurrencyCodeType.JPY:
            case CurrencyCodeType.TWD:
                return(0);

            default:
                return(2);
            }
        }
示例#28
0
        /// <summary>
        /// Get Paypal currency code
        /// </summary>
        /// <param name="currency">Currency</param>
        /// <returns>Paypal currency code</returns>
        public static CurrencyCodeType GetPaypalCurrency(Currency currency)
        {
            CurrencyCodeType currencyCodeType = CurrencyCodeType.USD;

            try
            {
                currencyCodeType = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), currency.CurrencyCode, true);
            }
            catch
            {
            }
            return(currencyCodeType);
        }
        private static DoDirectPaymentResponseType MakePayment(PaymentModel paymentModel)
        {
            // Create request object
            var request        = new DoDirectPaymentRequestType();
            var requestDetails = new DoDirectPaymentRequestDetailsType();

            request.DoDirectPaymentRequestDetails = requestDetails;

            var creditCard = new CreditCardDetailsType();

            requestDetails.CreditCard = creditCard;
            var payer = new PayerInfoType();

            // (Optional) First and last name of buyer.
            PersonNameType name = new PersonNameType();

            name.FirstName  = string.Format("{0} {1}", SessionWrapper.LoggedUser.FirstName, SessionWrapper.LoggedUser.LastName);
            name.LastName   = SessionWrapper.LoggedUser.Email; //pass buyer email address.
            payer.PayerName = name;

            creditCard.CardOwner = payer;

            creditCard.CreditCardNumber = paymentModel.CreditCardModel.CardNumber;

            creditCard.CreditCardType = (CreditCardTypeType)
                                        Enum.Parse(typeof(CreditCardTypeType), paymentModel.CreditCardModel.CardType.ToUpper());
            creditCard.CVV2 = paymentModel.CreditCardModel.SecurityCode;

            creditCard.ExpMonth = Convert.ToInt32(paymentModel.CreditCardModel.ExpMonth);
            creditCard.ExpYear  = Convert.ToInt32(paymentModel.CreditCardModel.ExpYear);

            requestDetails.PaymentDetails = new PaymentDetailsType();


            CurrencyCodeType currency = (CurrencyCodeType)
                                        Enum.Parse(typeof(CurrencyCodeType), "USD");
            var paymentAmount = new BasicAmountType(currency, paymentModel.OrderDetailModel.TotalOrder.ToString());

            requestDetails.PaymentDetails.OrderTotal = paymentAmount;

            // Invoke the API
            var wrapper = new DoDirectPaymentReq();

            wrapper.DoDirectPaymentRequest = request;

            var service = new PayPalAPIInterfaceServiceService();

            // API call
            return(service.DoDirectPayment(wrapper));
        }
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object

            BillOutstandingAmountRequestType request =
                new BillOutstandingAmountRequestType();

            BillOutstandingAmountRequestDetailsType details =
                new BillOutstandingAmountRequestDetailsType();

            request.BillOutstandingAmountRequestDetails = details;
            // (Required) Recurring payments profile ID returned in the CreateRecurringPaymentsProfile response.
            // Note:The profile must have a status of either Active or Suspended.
            details.ProfileID = profileId.Value;

            // (Optional) The amount to bill. The amount must be less than or equal to the current outstanding balance of the profile. If no value is specified, PayPal attempts to bill the entire outstanding balance amount.
            if (currencyCode.SelectedIndex != 0 && amount.Value != string.Empty)
            {
                CurrencyCodeType currency = (CurrencyCodeType)
                                            Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);
                details.Amount = new BasicAmountType(currency, amount.Value);
            }
            // (Optional) The reason for the non-scheduled payment. For profiles created using Express Checkout, this message is included in the email notification to the buyer for the non-scheduled payment transaction, and can also be seen by both you and the buyer on the Status History page of the PayPal account.
            if (note.Value != string.Empty)
            {
                details.Note = note.Value;
            }

            // Invoke the API
            BillOutstandingAmountReq wrapper = new BillOutstandingAmountReq();

            wrapper.BillOutstandingAmountRequest = request;
            // Create the PayPalAPIInterfaceServiceService service object to make the API call

            // Configuration map containing signature credentials and other required configuration.
            // For a full list of configuration parameters refer in wiki page
            // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters]
            Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig();

            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);

            // # API call
            // Invoke the BillOutstandingAmount method in service wrapper object
            BillOutstandingAmountResponseType response =
                service.BillOutstandingAmount(wrapper);


            // Check for API return status
            setKeyResponseObjects(service, response);
        }
示例#31
0
        /// <summary>
        /// Try to get the PayPal's currency code from payment's parent BillingCurrency or SiteContext's currencyCode
        /// </summary>
        /// <value>The PayPal currency code.</value>
        public CurrencyCodeType GetCurrencyCode(IPayment payment, Currency orderGroupCurrency)
        {
            CurrencyCodeType currency = CurrencyCodeType.CUSTOMCODE;

            if (string.IsNullOrEmpty(orderGroupCurrency))
            {
                currency = GetCurrencyCode(SiteContext.Current.Currency);
            }
            else
            {
                currency = GetCurrencyCode(orderGroupCurrency);
            }
            return(currency);
        }
示例#32
0
        /// <summary>
        /// Enables a seller to define shipping cost discount profiles for things such as combined
        /// payments for shipping and handling costs.
        /// </summary>
        ///
        /// <param name="CurrencyID">
        /// The three-digit code of the currency to be used for shipping cost discounts and
        /// insurance for combined payment orders. A discount profile can only be associated
        /// with a listing if the <b>CurrencyID</b> value of the profile matches the
        /// <b>Item.Currency</b> value specified in a listing.
        ///
        /// Required if the user creates flat rate shipping discount profiles, a promotional
        /// discount, a packaging/handling cost profile based on a variable
        /// discount rule, or if the user defines shipping insurance range/fee pairs.
        ///
        /// Note: There is a currencyID attribute on many elements of SetShippingDiscountProfiles.
        /// To avoid an error, be sure to use the same <b>CurrencyID</b> value
        /// in each occurrence within the same request.
        /// </param>
        ///
        /// <param name="CombinedDuration">
        /// This field is used to specify the number of days after the sale of an
        /// item in which the buyer or seller can combine multiple and mutual order
        /// line items into one Combined Payment order. In a Combined Payment order,
        /// the buyer makes one payment for all order line items, hence only unpaid
        /// order line items can be combined into a Combined Payment order.
        /// </param>
        ///
        /// <param name="ModifyActionCode">
        /// Indicates what action to take on the specified flat shipping discount,
        /// calculated shipping discount or promotional discount.
        /// If the action is Delete and if a flat rate or calculated shipping discount
        /// profile is specified, the discount profile identified by
        /// DiscountProfile.DiscountProfileID is deleted
        /// (see DiscountProfile.MappedDiscountProfileID for related details).
        /// </param>
        ///
        /// <param name="FlatShippingDiscount">
        /// Details of a shipping cost discount profile for flat rate shipping.
        /// If this is provided, CalculatedShippingDiscount and PromotionalShippingDiscountDetails
        /// should be omitted.
        /// </param>
        ///
        /// <param name="CalculatedShippingDiscount">
        /// Details of a shipping cost discount profile for calculated shipping.
        /// If this is provided, FlatShippingDiscount and PromotionalShippingDiscountDetails
        /// should be omitted.
        /// </param>
        ///
        /// <param name="CalculatedHandlingDiscount">
        /// This container is used by the seller to specify/modify packaging and handling discounts that are applied
        /// for combined payment orders.
        /// </param>
        ///
        /// <param name="PromotionalShippingDiscountDetails">
        /// The data for the promotional shipping discount.
        /// If this is provided, FlatShippingDiscount and CalculatedShippingDiscount
        /// should be omitted.
        /// </param>
        ///
        /// <param name="ShippingInsurance">
        /// Information establishing what fee to apply for domestic shipping insurance
        /// for combined payment depending on which range the order item-total price
        /// falls into.
        /// </param>
        ///
        /// <param name="InternationalShippingInsurance">
        /// Information establishing what fee to apply for international shipping
        /// insurance for combined payment depending on which range the order item-total
        /// price falls into.
        /// </param>
        ///
        public void SetShippingDiscountProfiles(CurrencyCodeType CurrencyID, CombinedPaymentPeriodCodeType CombinedDuration, ModifyActionCodeType ModifyActionCode, FlatShippingDiscountType FlatShippingDiscount, CalculatedShippingDiscountType CalculatedShippingDiscount, CalculatedHandlingDiscountType CalculatedHandlingDiscount, PromotionalShippingDiscountDetailsType PromotionalShippingDiscountDetails, ShippingInsuranceType ShippingInsurance, ShippingInsuranceType InternationalShippingInsurance)
        {
            this.CurrencyID                         = CurrencyID;
            this.CombinedDuration                   = CombinedDuration;
            this.ModifyActionCode                   = ModifyActionCode;
            this.FlatShippingDiscount               = FlatShippingDiscount;
            this.CalculatedShippingDiscount         = CalculatedShippingDiscount;
            this.CalculatedHandlingDiscount         = CalculatedHandlingDiscount;
            this.PromotionalShippingDiscountDetails = PromotionalShippingDiscountDetails;
            this.ShippingInsurance                  = ShippingInsurance;
            this.InternationalShippingInsurance     = InternationalShippingInsurance;

            Execute();
        }
示例#33
0
        public IPaymentResponse DoMassPayment(IEnumerable <PayReceiver> items, CurrencyCodeType currencyCodeType, ReceiverType receiverType = ReceiverType.EmailAddress, string emailSubject = null)
        {
            _logger.Log("PayPalMassPay.DoMassPayment",
                        new
            {
                CurrencyCode = currencyCodeType,
                ReceiverType = receiverType,
                EmailSubject = emailSubject,
                Items        = items.Select(x => new { x.ReceiverId, x.Amount, x.UniqueId, x.Note })
            });

            var request  = _requestBuilder.MassPayment(items, currencyCodeType, receiverType, emailSubject);
            var response = sendToPayPal(request);

            return(_responseParser.MassPayment(response));
        }
示例#34
0
        public NameValueCollection RefundTransaction(string transactionId, RefundType refundType = RefundType.Full, decimal amount = 0, string description = null, CurrencyCodeType currencyCodeType = CurrencyCodeType.USD)
        {
            var request = getQueryWithCredentials();
            request["METHOD"] = "RefundTransaction";
            request["TRANSACTIONID"] = transactionId;
            if (refundType == RefundType.Full)
            {
                return request;
            }

            request["REFUNDTYPE"] = "Partial";
            request["AMT"] = amount.ToString();
            request["CURRENCYCODE"] = currencyCodeType.ToString();
            request["NOTE"] = description;
            return request;
        }
示例#35
0
        NameValueCollection getBaseSetExpressCheckoutRequest(decimal amount, CurrencyCodeType currencyCodeType, string cancelUrl, string confirmationUrl)
        {
            var request = getQueryWithCredentials();
            request["METHOD"] = "SetExpressCheckout";
            request["PAYMENTREQUEST_0_CURRENCYCODE"] = currencyCodeType.ToString();
            request["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
            request["PAYMENTREQUEST_0_AMT"] = amount.AsPayPalFormatString();
            request["cancelUrl"] = cancelUrl;
            request["returnUrl"] = confirmationUrl;

            if (_configuration.UseLocaleFromCurrentCulture)
                request["LOCALECODE"] = Culture.Current.ToPayPalLocaleCode();
            else if (LocaleCodes.LocaleCodeSupported(_configuration.LocaleCode))
                request["LOCALECODE"] = _configuration.LocaleCode;

            return request;
        }
示例#36
0
文件: PaypalAPI.cs 项目: wncoder/core
        public DoCaptureResponseType DoCapture(string authorizationId, string note, string value,
                                               CurrencyCodeType currencyId, string invoiceId)
        {
            var pp_request = new DoCaptureRequestType
            {
                AuthorizationID = authorizationId,
                Note            = note,
                Amount          = new BasicAmountType
                {
                    Value      = value,
                    currencyID = currencyId
                },
                InvoiceID = invoiceId
            };

            return((DoCaptureResponseType)caller.Call("DoCapture", pp_request));
        }
示例#37
0
文件: PaypalAPI.cs 项目: wncoder/core
        public RefundTransactionResponseType RefundTransaction(string trxID, string refundType, string amount,
                                                               CurrencyCodeType storeCurrency)
        {
            // Create the request object
            var concreteRequest = new RefundTransactionRequestType
            {
                TransactionID       = trxID,
                RefundType          = RefundType.Partial,
                RefundTypeSpecified = true,
                Amount = new BasicAmountType
                {
                    currencyID = storeCurrency,
                    Value      = amount
                }
            };

            return((RefundTransactionResponseType)caller.Call("RefundTransaction", concreteRequest));
        }
        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;
        }
示例#39
0
        public string RefundTransaction(string TransactionID, bool DoFullRefund)
        {
            string sReturn = "";

            // Create the Refund Request
            RefundTransactionRequestType refundRequest = new RefundTransactionRequestType();
            BasicAmountType amount = new BasicAmountType();

            CurrencyCodeType currType = (CurrencyCodeType)this._currencyCode;

            amount.currencyID = currType;

            if (DoFullRefund)
            {
                refundRequest.RefundType = RefundType.Full;
            }
            else
            {
                refundRequest.RefundType = RefundType.Partial;
            }
            refundRequest.TransactionID = TransactionID;
            refundRequest.Version       = PayPalServiceUtility.PayPalAPIVersionNumber;

            RefundTransactionReq request = new RefundTransactionReq();

            request.RefundTransactionRequest = refundRequest;

            try {
                RefundTransactionResponseType response = service.RefundTransaction(request);
                string ErrorCheck = CheckErrors(response);
                if (ErrorCheck != "")
                {
                    sReturn = ErrorCheck;
                }
                else
                {
                    sReturn = "Success";
                }
            }
            catch (Exception x) {
                sReturn = "SSL Failure, the transaction did not go through. Error: " + x.Message;
            }
            return(sReturn);
        }
示例#40
0
        public IPaymentResponse DoExpressCheckoutPayment(decimal amount, CurrencyCodeType currencyCodeType, string payPalToken, string payPalPayerId)
        {
            if (amount <= 0)
            {
                throw new ArgumentOutOfRangeException("amount", "Amount must be greater than zero.");
            }
            if (string.IsNullOrWhiteSpace(payPalToken))
            {
                throw new ArgumentNullException("payPalToken");
            }
            if (string.IsNullOrWhiteSpace(payPalPayerId))
            {
                throw new ArgumentNullException("payPalPayerId");
            }

            var request = _requestBuilder.DoExpressCheckoutPayment(amount, currencyCodeType, payPalToken, payPalPayerId);

            return(doExpressCheckoutPaymentFor(request));
        }
示例#41
0
        /// <summary>
        /// Returns a seller's invoice data for their eBay account, including the account's
        /// summary data.
        /// </summary>
        /// 
        /// <param name="AccountHistorySelection">
        /// This field is used by the user to control which account entries are returned. The user has options to retrieve all new account entries (since last invoice), all account entries between two specified dates, or all account entries from a specified invoice. If this field is not include
        /// </param>
        ///
        /// <param name="InvoiceDate">
        /// This field is used to retrieve all account entries from a specific invoice, which is identified through this <b>InvoiceDate</b> field with the timestamp of the account invoice. This field is only applicable if the  <b>AccountHistorySelection</b> value is set to 'SpecifiedInvoice'; otherwise, this field will be ignored.
        /// </param>
        ///
        /// <param name="BeginDate">
        /// This field is used to retrieve all account entries dating back to the timestamp passed into this <b>BeginDate</b> field up until the timestamp passed into the <b>EndDate</b> field. The <b>BeginDate</b> value can not be set back any further than four months into the past. 
        /// <br/><br/>
        /// The allowed date formats are <em>YYYY-MM-DD</em> and <em>YYYY-MM-DD HH:mm:ss</em> The <b>BeginDate</b> value must be less than or equal to the <b>EndDate</b> value. The user might use the same values in both fields if that user wanted to retrieve all account entries from a specific day (if <em>YYYY-MM-DD</em> format used) or wanted to retrieve a specific account entry (if <em>YYYY-MM-DD HH:mm:ss</em> format used).
        /// <br/><br/>
        /// This field is only applicable if the  <b>AccountHistorySelection</b> value is set to 'BetweenSpecifiedDates'; otherwise, this field will be ignored. fiedDates' is used, both the <b>BeginDate</b> and <b>EndDate</b> must be included.
        /// </param>
        ///
        /// <param name="EndDate">
        /// This field is used to retrieve all account entries dating up to the timestamp passed into this <b>EndDate</b> field dating back to the timestamp passed into the <b>BeginDate</b> field. The <b>EndDate</b> value can not be set for a future date. 
        /// <br/><br/>
        /// The allowed date formats are <em>YYYY-MM-DD</em> and <em>YYYY-MM-DD HH:mm:ss</em> The <b>EndDate</b> value must be more than or equal to the <b>BeginDate</b> value. The user might use the same values in both fields if that user wanted to retrieve all account entries from a specific day (if <em>YYYY-MM-DD</em> format used) or wanted to retrieve a specific account entry (if <em>YYYY-MM-DD HH:mm:ss</em> format used).
        /// <br/><br/>
        /// This field is only applicable if the  <b>AccountHistorySelection</b> value is set to 'BetweenSpecifiedDates'; otherwise, this field will be ignored. If 'BetweenSpecifiedDates' is used, both the <b>BeginDate</b> and <b>EndDate</b> must be included.
        /// </param>
        ///
        /// <param name="Pagination">
        /// This container is used to control how many account entries are returned on each page of data in the response. <b>PaginationType</b> is used by numerous Trading API calls, and the default and maximum values for the <b>EntriesPerPage</b> field differs with each call. For the <b>GetAccount</b> call, the default value is 500 (account entries) per page, and maximum allowed value is 2000 (account entries) per page.
        /// </param>
        ///
        /// <param name="ExcludeBalance">
        /// By default, the current balance of the user's account will not be returned in the call response. To retrieve the current balance of their account, the user should include the <b>ExcludeBalance</b> flag in the request and set its value to 'false'. The current balance on the account will be shown in the <b>AccountSummary.CurrentBalance</b> field in the call response.
        /// </param>
        ///
        /// <param name="ExcludeSummary">
        /// Specifies whether to return account summary information in an
        /// AccountSummary node. Default is true, to return AccountSummary.
        /// </param>
        ///
        /// <param name="IncludeConversionRate">
        /// Specifies whether to retrieve the rate used for the currency conversion for usage transactions.
        /// </param>
        ///
        /// <param name="AccountEntrySortType">
        /// Specifies how account entries should be sorted in the response, by an
        /// element and then in ascending or descending order.
        /// </param>
        ///
        /// <param name="Currency">
        /// Specifies the currency used in the account report. Do not specify Currency
        /// in the request unless the following conditions are met. First, the user has
        /// or had multiple accounts under the same UserID. Second, the account
        /// identified in the request uses the currency you specify in the request. An
        /// error is returned if no account is found that uses the currency you specify
        /// in the request.
        /// </param>
        ///
        /// <param name="ItemID">
        /// Specifies the item ID for which to return account entries. If ItemID is
        /// used, all other filters in the request are ignored. If the specified item
        /// does not exist or if the requesting user is not the seller of the item, an
        /// error is returned.
        /// </param>
        ///
        public AccountEntryTypeCollection GetAccount(AccountHistorySelectionCodeType AccountHistorySelection, DateTime InvoiceDate, DateTime BeginDate, DateTime EndDate, PaginationType Pagination, bool ExcludeBalance, bool ExcludeSummary, bool IncludeConversionRate, AccountEntrySortTypeCodeType AccountEntrySortType, CurrencyCodeType Currency, string ItemID)
        {
            this.AccountHistorySelection = AccountHistorySelection;
            this.InvoiceDate = InvoiceDate;
            this.BeginDate = BeginDate;
            this.EndDate = EndDate;
            this.Pagination = Pagination;
            this.ExcludeBalance = ExcludeBalance;
            this.ExcludeSummary = ExcludeSummary;
            this.IncludeConversionRate = IncludeConversionRate;
            this.AccountEntrySortType = AccountEntrySortType;
            this.Currency = Currency;
            this.ItemID = ItemID;

            Execute();
            return ApiResponse.AccountEntries.AccountEntry;
        }
示例#42
0
 /// <summary>
 /// 
 /// </summary>
 public CurrencyDetailsType getCurrencyDetailsByCurrencyCode(CurrencyCodeType currencyCode)
 {
     return (CurrencyDetailsType)_CurrencyDetailsByCurrency[currencyCode];
 }
		private PaymentDetailsType GetPaypalPaymentDetail(CurrencyCodeType currency, PaymentActionCodeType paymentAction, PaymentIn payment)
		{
			var paymentDetails = new PaymentDetailsType { PaymentAction = paymentAction };
			paymentDetails.OrderTotal = new BasicAmountType(currency, FormatMoney(payment.Sum));

			return paymentDetails;
		}
示例#44
0
 public NameValueCollection MassPayment(IEnumerable<PayReceiver> receivers, CurrencyCodeType currencyCodeType, ReceiverType receiverType, string emailSubject)
 {
     var request = getQueryWithCredentials();
     request["METHOD"] = "MassPay";
     request["CURRENCYCODE"] = currencyCodeType.ToString();
     request["RECEIVERTYPE"] = receiverType.ToString();
     addOptionalValueToRequest("EMAILSUBJECT", emailSubject, request);
     addItems(receiverType, receivers, request);
     return request;
 }
示例#45
0
        /// <summary>
        /// For backward compatibility with old wrappers.
        /// </summary>
        public ItemTypeCollection GetCategoryListings(bool MotorsGermanySearchable, string CategoryID, CurrencyCodeType Currency, ItemTypeFilterCodeType ItemTypeFilter, CategoryListingsSearchCodeType SearchType, CategoryListingsOrderCodeType OrderBy, PaginationType Pagination, SearchLocationType SearchLocation, ProximitySearchType ProximitySearch, bool IncludeGetItFastItems, PaymentMethodSearchCodeType PaymentMethod, bool IncludeCondition, bool IncludeFeedback)
        {
            this.MotorsGermanySearchable = MotorsGermanySearchable;
            this.CategoryID = CategoryID;
            this.Currency = Currency;
            this.ItemTypeFilter = ItemTypeFilter;
            this.SearchType = SearchType;
            this.OrderBy = OrderBy;
            this.Pagination = Pagination;
            this.SearchLocation = SearchLocation;
            this.ProximitySearch = ProximitySearch;
            this.IncludeGetItFastItems = IncludeGetItFastItems;
            this.PaymentMethod = PaymentMethod;
            this.IncludeCondition = IncludeCondition;
            this.IncludeFeedback = IncludeFeedback;

            Execute();
            return ApiResponse.ItemArray;
        }
        /// <summary>
        /// Enables a seller to define shipping cost discount profiles for things such as combined
        /// payments for shipping and handling costs.
        /// </summary>
        /// 
        /// <param name="CurrencyID">
        /// The ID of the currency to be used for shipping cost discounts and
        /// insurance for combined payment. A discount profile can only be
        /// associated with a listing if the currency ID of the profile matches the
        /// currency ID of the listing.
        /// 
        /// Required if the user creates flat rate shipping discount profiles, a promotional
        /// discount, a packaging/handling cost profile based on a variable
        /// discount rule, or if the user defines shipping insurance range/fee pairs.
        /// 
        /// Note: There is a currencyID attribute on many elements of SetShippingDiscountProfiles.
        /// To avoid an error, be sure to use the same value of CurrencyCodeType in each
        /// occurrence within the same request.
        /// </param>
        ///
        /// <param name="CombinedDuration">
        /// Only those items purchased within CombinedDuration days of each other can
        /// be combined into an order and benefit from any shipping discounts.
        /// </param>
        ///
        /// <param name="ModifyActionCode">
        /// Indicates what action to take on the specified flat shipping discount,
        /// calculated shipping discount or promotional discount.
        /// If the action is Delete and if a flat rate or calculated shipping discount
        /// profile is specified, the discount profile identified by
        /// DiscountProfile.DiscountProfileID is deleted
        /// (see DiscountProfile.MappedDiscountProfileID for related details).
        /// </param>
        ///
        /// <param name="FlatShippingDiscount">
        /// Details of a shipping cost discount profile for flat rate shipping.
        /// If this is provided, CalculatedShippingDiscount and PromotionalShippingDiscountDetails
        /// should be omitted.
        /// </param>
        ///
        /// <param name="CalculatedShippingDiscount">
        /// Details of a shipping cost discount profile for calculated shipping.
        /// If this is provided, FlatShippingDiscount and PromotionalShippingDiscountDetails
        /// should be omitted.
        /// </param>
        ///
        /// <param name="CalculatedHandlingDiscount">
        /// The data for the specific packaging/handling cost details for combined payment.
        /// </param>
        ///
        /// <param name="PromotionalShippingDiscountDetails">
        /// The data for the promotional shipping discount.
        /// If this is provided, FlatShippingDiscount and CalculatedShippingDiscount
        /// should be omitted.
        /// </param>
        ///
        /// <param name="ShippingInsurance">
        /// Information establishing what fee to apply for domestic shipping insurance
        /// for combined payment depending on which range the order item-total price
        /// falls into.
        /// </param>
        ///
        /// <param name="InternationalShippingInsurance">
        /// Information establishing what fee to apply for international shipping
        /// insurance for combined payment depending on which range the order item-total
        /// price falls into.
        /// </param>
        ///
        public void SetShippingDiscountProfiles(CurrencyCodeType CurrencyID, CombinedPaymentPeriodCodeType CombinedDuration, ModifyActionCodeType ModifyActionCode, FlatShippingDiscountType FlatShippingDiscount, CalculatedShippingDiscountType CalculatedShippingDiscount, CalculatedHandlingDiscountType CalculatedHandlingDiscount, PromotionalShippingDiscountDetailsType PromotionalShippingDiscountDetails, ShippingInsuranceType ShippingInsurance, ShippingInsuranceType InternationalShippingInsurance)
        {
            this.CurrencyID = CurrencyID;
            this.CombinedDuration = CombinedDuration;
            this.ModifyActionCode = ModifyActionCode;
            this.FlatShippingDiscount = FlatShippingDiscount;
            this.CalculatedShippingDiscount = CalculatedShippingDiscount;
            this.CalculatedHandlingDiscount = CalculatedHandlingDiscount;
            this.PromotionalShippingDiscountDetails = PromotionalShippingDiscountDetails;
            this.ShippingInsurance = ShippingInsurance;
            this.InternationalShippingInsurance = InternationalShippingInsurance;

            Execute();
        }
示例#47
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:PayPalService"/> class.
        /// </summary>
        /// <param name="isLive">if set to <c>true</c> [is live].</param>
        /// <param name="apiUserName">Name of the API user.</param>
        /// <param name="apiPassword">The API password.</param>
        /// <param name="signature">The signature.</param>
        /// <param name="businessEmail">The business email.</param>
        /// <param name="defaultCurrencyCode">The default currency code.</param>
        /// <param name="useExpressCheckoutCommit">if set to <c>true</c> [use express checkout commit].</param>
        /// <param name="enforceSellerProtectionPolicy">if set to <c>true</c> [enforce seller protection policy].</param>
        /// <param name="headerImageUrl">The header image URL.</param>
        public PayPalService(bool isLive, string apiUserName, string apiPassword, string signature, string businessEmail,
      string defaultCurrencyCode, bool useExpressCheckoutCommit, bool enforceSellerProtectionPolicy, 
      string headerImageUrl)
        {
            //Validate arguments
              if (string.IsNullOrEmpty(businessEmail)) {
            Validator.ValidateStringArgumentIsNotNullOrEmptyString(apiUserName, API_USERNAME);
            Validator.ValidateStringArgumentIsNotNullOrEmptyString(apiPassword, API_PASSWORD);
            Validator.ValidateStringArgumentIsNotNullOrEmptyString(signature, SIGNATURE);
              }
              Validator.ValidateStringArgumentIsNotNullOrEmptyString(defaultCurrencyCode, DEFAULT_CURRENCY_CODE);
              Validator.ValidateEnumIsDefined(typeof(CurrencyCodeType), defaultCurrencyCode);

              this.isLive = isLive;
              this.apiUserName = apiUserName;
              this.apiPassword = apiPassword;
              this.signature = signature;
              this.businessEmail = businessEmail;
              this.defaultCurrencyCode = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), defaultCurrencyCode);
              this.useExpressCheckoutCommit = useExpressCheckoutCommit;
              this.enforceSellerProtectionPolicy = enforceSellerProtectionPolicy;
              this.headerImageUrl = headerImageUrl;

              payPalAPIAASoapBinding = new PayPalAPIAASoapBinding();
              payPalAPIAASoapBinding.Url = PayPalServiceUtility.GetPayPalServiceEndpoint(true, IsLive, true, true);
              payPalAPIAASoapBinding.RequesterCredentials = new CustomSecurityHeaderType();
              payPalAPIAASoapBinding.RequesterCredentials.Credentials = new UserIdPasswordType();
              payPalAPIAASoapBinding.RequesterCredentials.Credentials.Username = ApiUserName;
              payPalAPIAASoapBinding.RequesterCredentials.Credentials.Password = ApiPassword;
              payPalAPIAASoapBinding.RequesterCredentials.Credentials.Signature = Signature;
              payPalAPIAASoapBinding.RequesterCredentials.Credentials.Subject = this.businessEmail;

              payPalAPISoapBinding = new PayPalAPISoapBinding();
              payPalAPISoapBinding.Url = PayPalServiceUtility.GetPayPalServiceEndpoint(true, IsLive, true, true);
              payPalAPISoapBinding.RequesterCredentials = new CustomSecurityHeaderType();
              payPalAPISoapBinding.RequesterCredentials.Credentials = new UserIdPasswordType();
              payPalAPISoapBinding.RequesterCredentials.Credentials.Username = ApiUserName;
              payPalAPISoapBinding.RequesterCredentials.Credentials.Password = ApiPassword;
              payPalAPISoapBinding.RequesterCredentials.Credentials.Signature = Signature;
              payPalAPISoapBinding.RequesterCredentials.Credentials.Subject = string.Empty;
        }
        /// <summary>
        /// Gets the numeric currency id of a <see cref="CurrencyCodeType"/>.
        /// </summary>
        /// <param name="CurrencyCodeType">The <see cref="CurrencyCodeType"/>.</param>
        /// <returns>The numeric id associated with the <see cref="CurrencyCodeType"/>.</returns>
        public static int GetCurrencyID(CurrencyCodeType CurrencyCodeType)
        {
            if (!Enum.IsDefined(typeof(CurrencyValueEnum), CurrencyCodeType.ToString()))
                return -1;
            else
                return (int)Enum.Parse(typeof(CurrencyValueEnum), Enum.GetName(typeof(CurrencyCodeType), CurrencyCodeType));

        }
示例#49
0
 private PaymentDetailsType GetPaypalPaymentDetail(CurrencyCodeType currency, PaymentActionCodeType paymentAction)
 {
     var paymentDetails = new PaymentDetailsType { PaymentAction = paymentAction };
     var itemTotal = Ch.Cart.Subtotal - Ch.Cart.LineItemDiscountTotal - Ch.Cart.FormDiscountTotal;
     paymentDetails.PaymentDetailsItem.AddRange(GetPaypalPaymentDetailsItemTypes(currency));
     paymentDetails.ItemTotal = new BasicAmountType(currency, FormatMoney(itemTotal));
     paymentDetails.ShippingTotal = new BasicAmountType(currency, FormatMoney(Ch.Cart.ShippingTotal));
     paymentDetails.HandlingTotal = new BasicAmountType(currency, FormatMoney(Ch.Cart.HandlingTotal));
     paymentDetails.TaxTotal = new BasicAmountType(currency, FormatMoney(Ch.Cart.TaxTotal));
     paymentDetails.OrderTotal = new BasicAmountType(currency, FormatMoney(Ch.Cart.Total));
     paymentDetails.ShippingDiscount = new BasicAmountType(currency, FormatMoney(-Ch.Cart.ShipmentDiscountTotal));
     
     return paymentDetails;
 }
        private PaymentDetailsType GetPaypalPaymentDetail(CurrencyCodeType currency, PaymentActionCodeType paymentAction)
        {
            var paymentDetails = new PaymentDetailsType { PaymentAction = paymentAction };
            decimal itemTotal;
            paymentDetails.PaymentDetailsItem.AddRange(GetPaypalPaymentDetailsItemTypes(currency, out itemTotal));
            paymentDetails.ItemTotal = new BasicAmountType(currency, FormatMoney(itemTotal));
            paymentDetails.ShippingTotal = new BasicAmountType(currency, FormatMoney(Ch.Cart.ShippingTotal));
            paymentDetails.HandlingTotal = new BasicAmountType(currency, FormatMoney(Ch.Cart.HandlingTotal));
            paymentDetails.TaxTotal = new BasicAmountType(currency, FormatMoney(Ch.Cart.TaxTotal));
            paymentDetails.OrderTotal = new BasicAmountType(currency, FormatMoney(Ch.Cart.Total));

            var shippingDiscount = Ch.Cart.OrderForms.SelectMany(c => c.Shipments).Sum(c => c.ShippingDiscountAmount);
            if (shippingDiscount > 0)
            {
                paymentDetails.ShippingDiscount = new BasicAmountType(currency, FormatMoney(-shippingDiscount));
            }
            return paymentDetails;
        }
        private IEnumerable<PaymentDetailsItemType> GetPaypalPaymentDetailsItemTypes(CurrencyCodeType currency, out decimal itemTotal)
        {
            itemTotal = 0;

            var detais = Ch.LineItems.Select(li => new PaymentDetailsItemType
            {
                Name = li.DisplayName, 
                Amount = new BasicAmountType(currency, FormatMoney(li.PlacedPrice)), 
                Quantity = (int) li.Quantity, 
                ItemCategory = ItemCategoryType.PHYSICAL,
                Tax = new BasicAmountType(currency, FormatMoney(li.TaxTotal)), 
                Description = li.Description, 
                Number = li.CatalogItemCode, 
                ItemURL = Url.ItemUrl(li.CatalogItemId, li.ParentCatalogItemId)
            }).ToList();

            //Item total is sum of line item extended price
            itemTotal += Ch.LineItems.Sum(li => li.ExtendedPrice);

            //Add order form discounts
            detais.AddRange(Ch.Cart.OrderForms.SelectMany(x => x.Discounts).Select(dicount => new PaymentDetailsItemType
            {
                Name = dicount.DiscountName, 
                Amount = new BasicAmountType(currency, FormatMoney(-dicount.DiscountAmount)), 
                Quantity = 1, 
                ItemCategory = ItemCategoryType.PHYSICAL, 
                Description = dicount.DisplayMessage, 
                PromoCode = dicount.DiscountCode
            }));

            //minus cart subtotal discount sum
            itemTotal -= Ch.Cart.OrderForms.SelectMany(x => x.Discounts).Sum(d => d.DiscountAmount);
  
            //Add line item discounts
            detais.AddRange(Ch.Cart.OrderForms.SelectMany(x => x.LineItems).SelectMany(x=>x.Discounts).Select(dicount => new PaymentDetailsItemType
            {
                Name = dicount.DiscountName,
                Amount = new BasicAmountType(currency, FormatMoney(-dicount.DiscountAmount)),
                Quantity = 1,
                ItemCategory = ItemCategoryType.PHYSICAL,
                Description = dicount.DisplayMessage,
                PromoCode = dicount.DiscountCode
            }));

            return detais;
        }
示例#52
0
        /// <summary>
        /// For backward compatibility with old wrappers.
        /// </summary>
        public ItemTypeCollection GetCategoryListings(bool MotorsGermanySearchable, string CategoryID, bool AdFormat, bool FreeShipping, CurrencyCodeType Currency, ItemTypeFilterCodeType ItemTypeFilter, CategoryListingsSearchCodeType SearchType, CategoryListingsOrderCodeType OrderBy, PaginationType Pagination, SearchLocationType SearchLocation, ProximitySearchType ProximitySearch, bool IncludeGetItFastItems, PaymentMethodSearchCodeType PaymentMethod, bool IncludeCondition, bool IncludeFeedback, string LocalSearchPostalCode, int MaxRelatedSearchKeywords)
        {
            this.MotorsGermanySearchable = MotorsGermanySearchable;
            this.CategoryID = CategoryID;
            this.AdFormat = AdFormat;
            this.FreeShipping = FreeShipping;
            this.Currency = Currency;
            this.ItemTypeFilter = ItemTypeFilter;
            this.SearchType = SearchType;
            this.OrderBy = OrderBy;
            this.Pagination = Pagination;
            this.SearchLocation = SearchLocation;
            this.ProximitySearch = ProximitySearch;
            this.IncludeGetItFastItems = IncludeGetItFastItems;
            this.PaymentMethod = PaymentMethod;
            this.IncludeCondition = IncludeCondition;
            this.IncludeFeedback = IncludeFeedback;
            this.LocalSearchPostalCode = LocalSearchPostalCode;
            this.MaxRelatedSearchKeywords = MaxRelatedSearchKeywords;

            Execute();
            return ApiResponse.ItemArray;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PayPalBasicAmountTypeFactory"/> class.
        /// </summary>
        /// <param name="currencyCodeType">
        /// The currency code type.
        /// </param>
        public PayPalBasicAmountTypeFactory(CurrencyCodeType currencyCodeType)
        {
            _currencyCodeType = currencyCodeType;

            Initialize();
        }
示例#54
0
 public DoCaptureResponseType DoCapture(string authorizationId, string note, string value, CurrencyCodeType currencyId, string invoiceId)
 {
     DoCaptureRequestType pp_request = new DoCaptureRequestType();
     pp_request.AuthorizationID = authorizationId;
     pp_request.Note = note;
     pp_request.Amount = new BasicAmountType();
     pp_request.Amount.Value = value;
     pp_request.Amount.currencyID = currencyId;
     pp_request.InvoiceID = invoiceId;
     return (DoCaptureResponseType)caller.Call("DoCapture", pp_request);
 }
示例#55
0
 public NameValueCollection RefundPartialTransaction(string transactionId, decimal amount, CurrencyCodeType currencyCodeType, string description)
 {
     var request = getQueryWithCredentials();
     request["METHOD"] = "RefundTransaction";
     request["TRANSACTIONID"] = transactionId;
     request["REFUNDTYPE"] = "Partial";
     request["AMT"] = amount.AsPayPalFormatString();
     request["CURRENCYCODE"] = currencyCodeType.ToString();
     request["NOTE"] = description;
     return request;
 }
示例#56
0
        public SetExpressCheckoutResponseType SetExpressCheckout(string paymentAmount, string returnURL, string cancelURL, PaymentActionCodeType paymentAction, CurrencyCodeType currencyCodeType, string invoiceId)
        {
            // Create the request object
            SetExpressCheckoutRequestType pp_request = new SetExpressCheckoutRequestType();

            // Create the request details object
            pp_request.SetExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType();
            pp_request.SetExpressCheckoutRequestDetails.PaymentAction = paymentAction;
            pp_request.SetExpressCheckoutRequestDetails.PaymentActionSpecified = true;
            pp_request.SetExpressCheckoutRequestDetails.InvoiceID = invoiceId;
            pp_request.SetExpressCheckoutRequestDetails.OrderTotal = new BasicAmountType();

            pp_request.SetExpressCheckoutRequestDetails.OrderTotal.currencyID = currencyCodeType;
            pp_request.SetExpressCheckoutRequestDetails.OrderTotal.Value = paymentAmount;            

            pp_request.SetExpressCheckoutRequestDetails.CancelURL = cancelURL;
            pp_request.SetExpressCheckoutRequestDetails.ReturnURL = returnURL;

            return (SetExpressCheckoutResponseType)caller.Call("SetExpressCheckout", pp_request);
        }
示例#57
0
 public NameValueCollection SetExpressCheckout(decimal amount, CurrencyCodeType currencyCodeType, string cancelUrl, string confirmationUrl)
 {
     var request = getBaseSetExpressCheckoutRequest(amount, currencyCodeType, cancelUrl, confirmationUrl);
     return request;
 }
示例#58
0
        public SetExpressCheckoutResponseType SetExpressCheckout(string paymentAmount, string returnURL, string cancelURL, PaymentActionCodeType paymentAction, CurrencyCodeType currencyCodeType, String name, String countryISOCode, String street1, String street2, String city, String region, String postalCode, String phone, string invoiceId)
        {
            // Create the request object
            SetExpressCheckoutRequestType pp_request = new SetExpressCheckoutRequestType();

            // Create the request details object
            pp_request.SetExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType();
            pp_request.SetExpressCheckoutRequestDetails.PaymentAction = paymentAction;
            pp_request.SetExpressCheckoutRequestDetails.PaymentActionSpecified = true;

            pp_request.SetExpressCheckoutRequestDetails.AddressOverride = "1";
            pp_request.SetExpressCheckoutRequestDetails.InvoiceID = invoiceId;

            pp_request.SetExpressCheckoutRequestDetails.OrderTotal = new BasicAmountType();

            pp_request.SetExpressCheckoutRequestDetails.OrderTotal.currencyID = currencyCodeType;
            pp_request.SetExpressCheckoutRequestDetails.OrderTotal.Value = paymentAmount;

            pp_request.SetExpressCheckoutRequestDetails.CancelURL = cancelURL;
            pp_request.SetExpressCheckoutRequestDetails.ReturnURL = returnURL;
            
            pp_request.SetExpressCheckoutRequestDetails.Address = new AddressType();            
            pp_request.SetExpressCheckoutRequestDetails.Address.AddressStatusSpecified = false;
            pp_request.SetExpressCheckoutRequestDetails.Address.AddressOwnerSpecified = false;

            pp_request.SetExpressCheckoutRequestDetails.Address.Street1 = street1;
            pp_request.SetExpressCheckoutRequestDetails.Address.Street2 = street2;
            pp_request.SetExpressCheckoutRequestDetails.Address.CityName = city;
            pp_request.SetExpressCheckoutRequestDetails.Address.StateOrProvince = region;
            pp_request.SetExpressCheckoutRequestDetails.Address.PostalCode = postalCode;
            pp_request.SetExpressCheckoutRequestDetails.Address.CountrySpecified = true;
            pp_request.SetExpressCheckoutRequestDetails.Address.Country = GetCountryCode(countryISOCode);                        
            pp_request.SetExpressCheckoutRequestDetails.Address.Phone = phone;
            pp_request.SetExpressCheckoutRequestDetails.Address.Name = name;                        
            return (SetExpressCheckoutResponseType)caller.Call("SetExpressCheckout", pp_request);
        }
 /// <summary>
 /// Constructor with arguments
 /// </summary>
 public BasicAmountType(CurrencyCodeType? currencyID, string value)
 {
     this.currencyID = currencyID;
     this.value = value;
 }
示例#60
0
        public DoExpressCheckoutPaymentResponseType DoExpressCheckoutPayment(string token, string payerID, string paymentAmount, PaymentActionCodeType paymentAction, CurrencyCodeType currencyCodeType, string invoiceId)
        {
            // Create the request object
            DoExpressCheckoutPaymentRequestType pp_request = new DoExpressCheckoutPaymentRequestType();

            // Create the request details object
            pp_request.DoExpressCheckoutPaymentRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
            pp_request.DoExpressCheckoutPaymentRequestDetails.Token = token;
            pp_request.DoExpressCheckoutPaymentRequestDetails.PayerID = payerID;
            pp_request.DoExpressCheckoutPaymentRequestDetails.PaymentAction = paymentAction;
            

            pp_request.DoExpressCheckoutPaymentRequestDetails.PaymentDetails = new PaymentDetailsType();
            pp_request.DoExpressCheckoutPaymentRequestDetails.PaymentDetails.InvoiceID = invoiceId;
            pp_request.DoExpressCheckoutPaymentRequestDetails.PaymentDetails.OrderTotal = new BasicAmountType();

            pp_request.DoExpressCheckoutPaymentRequestDetails.PaymentDetails.OrderTotal.currencyID = currencyCodeType;
            pp_request.DoExpressCheckoutPaymentRequestDetails.PaymentDetails.OrderTotal.Value = paymentAmount;
            pp_request.DoExpressCheckoutPaymentRequestDetails.PaymentDetails.ButtonSource = "BVCommerce_Cart_EC_US";
            return (DoExpressCheckoutPaymentResponseType)caller.Call("DoExpressCheckoutPayment", pp_request);
        }