/// <summary> /// Enable the order creation on paypal's side and to log in the customer on it's paypal account. /// Get mandatory informations about customer and it's paypal account. /// </summary> /// <param name="orderAmount">amount of the order, let paypal know a one point the amount to pay.</param> /// <param name="token">internal paypal/shop transaction id</param> /// <param name="returnedMsg">Error message send by paypal</param> /// <param name="shippingAddress">Shipping Address: optionnal field, but usefull for the customer.</param> /// <returns></returns> public static bool Instantiation(decimal orderAmount, ref string token, ref string returnedMsg, Addresse shippingAddress = null) { NVPAPICaller test = new NVPAPICaller(); bool ret = false; if (orderAmount > 0) { string amt = orderAmount.ToString(CultureInfo.InvariantCulture).Replace(',', '.'); //Optional Shipping Address entered on the merchant site string shipToName = ""; if (shippingAddress != null) { if (!string.IsNullOrEmpty(shippingAddress.Identity.Societe)) { shipToName = shippingAddress.Identity.Societe + " "; } shipToName += shippingAddress.Identity.Prenom + " " + shippingAddress.Identity.Nom; string shipToStreet = shippingAddress.MainStreet; string shipToStreet2 = shippingAddress.SubStreet; string shipToCity = shippingAddress.City; string shipToState = ""; //parceque france string shipToZip = shippingAddress.PostCode; //postcode et pas zip parceque france string shipToCountryCode = "FR"; //ref: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_country_codes ret = test.MarkExpressCheckout(amt, shipToName, shipToStreet, shipToStreet2, shipToCity, shipToState, shipToZip, shipToCountryCode, ref token, ref returnedMsg); } else { ret = test.MarkExpressCheckout(amt, "", "", "", "", "", "", "", ref token, ref returnedMsg); } return ret;/* if (ret) { // retToken = token; return ret; Session["token"] = token; Response.Redirect(retMsg); } else { return RedirectToAction("Index", "PaypalErrors", new { ErrorCode = returnedMsg }); // Response.Redirect("APIError.aspx?" + retMsg); }*/ } returnedMsg = "Une erreur est survenue lors du calcul de la somme de votre panier. Merci de renouveler l'opération."; return ret; }