c# - PayPal PaymentsException: The remote server returned an error: (400) Bad Request -


i'm going sale subscribe service's users , i've trying setup paypal in asp.net webform website c# i'm getting error unknown me. wonder if code i'm wrote ok or not.

code:

var apicontext = configuration.getapicontext(); string payerid = userid.tostring(); if (!string.isnullorempty(payerid)) {     var itemlist = new itemlist()     {         items = new list<item>()          {            new item()            {                 name = "weekly subscribe",                 currency = "usd",                 price = "15",                 quantity = "1",                 sku = "sku"            }         }     };      var payer = new payer() { payment_method = "paypal" };     var baseuri = "http://localhost:1067/pages/general/backfrompaypal.aspx?";     var guid = convert.tostring((new random()).next(100000));     var redirecturl = baseuri + "id=" + item.paidhistoryid;     var redirurls = new redirecturls()     {         cancel_url = redirecturl + "&ispaid=false",         return_url = redirecturl + "&ispaid=true"     };      var details = new details()     {         tax = "0",         shipping = "0",         subtotal = "15"     };       var amount = new amount()     {         currency = "usd",         total = "15.00", // total must equal sum of shipping, tax , subtotal.         details = details     };      var transactionlist = new list<transaction>();     transactionlist.add(new transaction()     {          description = "description",          invoice_number = common.getrandominvoicenumber(),          amount = amount,          item_list = itemlist     });      var payment = new payment()     {         intent = "sale",         payer = payer,         transactions = transactionlist,         redirect_urls = redirurls     };      try     {         var createdpayment = payment.create(apicontext);         var links = createdpayment.links.getenumerator();         while (links.movenext())         {             var link = links.current;             if (link.rel.tolower().trim().equals("approval_url"))             {                         //this.flow.recordredirecturl("redirect paypal approve payment...", link.href);             }         }      session.add(guid, createdpayment.id);      var paymentid = createdpayment.id;     var paymentexecution = new paymentexecution() { payer_id = payerid, transactions = createdpayment.transactions };      var executedpayment = createdpayment.execute(apicontext, paymentexecution);      }     catch (paypalexception ex)     {         if (ex connectionexception)         {              label11.text = ex.message;         }         else         {              label11.text = ex.tostring();         }      } 


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -