1
                    SetExpressCheckoutRequestType request = new SetExpressCheckoutRequestType();
                    SetExpressCheckoutRequestDetailsType ecDetails = new SetExpressCheckoutRequestDetailsType();
                    ecDetails.ReturnURL = MYSCommon.Constant.SecureChannel + "://" + MYSCommon.Constant.Website + "/" + MYSCommon.Constant.RootName + "Security/PayPalRet.aspx";
                    ecDetails.CancelURL = MYSCommon.Constant.SecureChannel + "://" + MYSCommon.Constant.Website + "/" + MYSCommon.Constant.RootName + "Security/PayPalRet.aspx";

                    ecDetails.BuyerEmail = member.email;

                    ecDetails.ReqConfirmShipping = "0";

                    ecDetails.AddressOverride = "0";

                    ecDetails.NoShipping = "1";
                    /*
                    if (solutionType.SelectedIndex != 0)
                    {
                        ecDetails.SolutionType = (SolutionTypeType)
                            Enum.Parse(typeof(SolutionTypeType), solutionType.SelectedValue);
                    }
                    */

                    /* Populate payment requestDetails. 
                     * SetExpressCheckout allows parallel payments of upto 10 payments. 
                     * This samples shows just one payment.
                     */
                    PaymentDetailsType paymentDetails = new PaymentDetailsType();
                    ecDetails.PaymentDetails.Add(paymentDetails);
                    // (Required) Total cost of the transaction to the buyer. If shipping cost and tax charges are known, include them in this value. If not, this value should be the current sub-total of the order. If the transaction includes one or more one-time purchases, this field must be equal to the sum of the purchases. Set this field to 0 if the transaction does not include a one-time purchase such as when you set up a billing agreement for a recurring payment that is not immediately charged. When the field is set to 0, purchase-specific fields are ignored.
                    double orderTotal = 0.0;
                    // Sum of cost of all items in this order. For digital goods, this field is required.
                    double itemTotal = 0.0;
                    CurrencyCodeType currency = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), "AUD");
                    // (Optional) Total shipping costs for this order.
                    // Note:
                    // You must set the currencyID attribute to one of the 3-character currency codes 
                    // for any of the supported PayPal currencies.
                    // Character length and limitations: 
                    // Value is a positive number which cannot exceed $10,000 USD in any currency.
                    // It includes no currency symbol. 
                    // It must have 2 decimal places, the decimal separator must be a period (.), 
                    // and the optional thousands separator must be a comma (,)
                    //paymentDetails.ShippingTotal = new BasicAmountType(currency, shipprice.ToString());
                    //(Optional) Description of items the buyer is purchasing.
                    // Note:
                    // The value you specify is available only if the transaction includes a purchase.
                    // This field is ignored if you set up a billing agreement for a recurring payment 
                    // that is not immediately charged.
                    // Character length and limitations: 127 single-byte alphanumeric characters
                    paymentDetails.OrderDescription = "I-Tech";

                    // How you want to obtain payment. When implementing parallel payments, 
                    // this field is required and must be set to Order.
                    // When implementing digital goods, this field is required and must be set to Sale.
                    // If the transaction does not include a one-time purchase, this field is ignored. 
                    // It is one of the following values:
                    //   Sale – This is a final sale for which you are requesting payment (default).
                    //   Authorization – This payment is a basic authorization subject to settlement with PayPal Authorization and Capture.
                    //   Order – This payment is an order authorization subject to settlement with PayPal Authorization and Capture.
                    paymentDetails.PaymentAction = (PaymentActionCodeType)Enum.Parse(typeof(PaymentActionCodeType), "SALE");

                    // Each payment can include requestDetails about multiple items
                    // This example shows just one payment item
                    PaymentDetailsItemType itemDetails = new PaymentDetailsItemType();
                    itemDetails.Name = "Order from www.i-tech.com.au";
                    itemDetails.Amount = new BasicAmountType(currency, paypalprice.ToString());
                    itemDetails.Quantity = Convert.ToInt32(1);
                    // Indicates whether an item is digital or physical. For digital goods, this field is required and must be set to Digital. It is one of the following values:
                    //   1.Digital
                    //   2.Physical
                    //  This field is available since version 65.1. 
                    itemDetails.ItemCategory = (ItemCategoryType)Enum.Parse(typeof(ItemCategoryType), "PHYSICAL");
                    itemTotal += Convert.ToDouble(itemDetails.Amount.value) * itemDetails.Quantity.Value;
                    //(Optional) Item sales tax.
                    //    Note: You must set the currencyID attribute to one of 
                    //    the 3-character currency codes for any of the supported PayPal currencies.
                    //    Character length and limitations: Value is a positive number which cannot exceed $10,000 USD in any currency.
                    //    It includes no currency symbol. It must have 2 decimal places, the decimal separator must be a period (.), 
                    //    and the optional thousands separator must be a comma (,).
                    /*
                    if (salesTax.Value != string.Empty)
                    {
                        itemDetails.Tax = new BasicAmountType(currency, salesTax.Value);
                        orderTotal += Convert.ToDouble(salesTax.Value);
                    }
                    */
                    //(Optional) Item description.
                    // Character length and limitations: 127 single-byte characters
                    // This field is introduced in version 53.0. 
                    itemDetails.Description = "Transaction ID: " + transactionID;
                    paymentDetails.PaymentDetailsItem.Add(itemDetails);

                    orderTotal += itemTotal;
                    paymentDetails.ItemTotal = new BasicAmountType(currency, itemTotal.ToString());
                    paymentDetails.OrderTotal = new BasicAmountType(currency, orderTotal.ToString());

                    request.SetExpressCheckoutRequestDetails = ecDetails;

                    // Invoke the API
                    SetExpressCheckoutReq wrapper = new SetExpressCheckoutReq();
                    wrapper.SetExpressCheckoutRequest = 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();

                    // Create the PayPalAPIInterfaceServiceService service object to make the API call
                    PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);

                    // # API call 
                    // Invoke the SetExpressCheckout method in service wrapper object  
                    SetExpressCheckoutResponseType setECResponse = service.SetExpressCheckout(wrapper);

                    // Check for API return status
                    //HttpContext CurrContext = HttpContext.Current;
                    //CurrContext.Items.Add("paymentDetails", request.SetExpressCheckoutRequestDetails.PaymentDetails);
                    //setKeyResponseObjects(service, setECResponse);

                    if (setECResponse.Ack.Equals(AckCodeType.FAILURE) || (setECResponse.Errors != null && setECResponse.Errors.Count > 0))
                    {
                        //CurrContext.Items.Add("Response_error", setECResponse.Errors);
                        //CurrContext.Items.Add("Response_redirectURL", null);

                        Response.Redirect("../Error.aspx");
                    }
                    else
                    {
                        //CurrContext.Items.Add("Response_error", null);
                        //keyResponseParameters.Add("EC token", setECResponse.Token);

                        HttpContext.Current.Session["PayPalInvoice"] = invoiceID;
                        string redirecturl = ConfigurationSettings.AppSettings["PAYPAL_REDIRECT_URL"].ToString() + "_express-checkout&token=" + setECResponse.Token;
                        Response.Redirect(redirecturl);
                    }

I'm using C# and ASP.Net to integrate PayPal Express Checkout to our website. When I calling "SetExpressCheckoutResponseType setECResponse = service.SetExpressCheckout(wrapper);" it has no response from server. These code works fine on my desktop. Only no response after I upload it to server. Also using sandbox mode now.

Thanks.

2 Answers 2

0

I'm not a C# developer, but I know when the sort of thing you describe happens with PHP (where it works on server but not on another) it typically means CURL isn't enabled on the server where it doesn't work.

Whatever library/package/extension (or whatever C# might call it) you're using to make the HTTP requests needs to be enabled on the server. That's the first thing I would check. Sounds like maybe it's not.

2
  • Thanks Andrew, I reviewed server logs and found some errors there.
    – nothy
    Apr 28, 2014 at 9:48
  • Even I didn't found what's wrong there, but I found solution which is just simply restart IIS (not website or application pool).
    – nothy
    Apr 28, 2014 at 9:49
0

This may be not a code problem. Errors from IIS logs show that some connection problem. After search error code. Just restart IIS (not website or recycle application pool) will fix the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.