/// <remarks/> public void SetExpressCheckoutAsync(SetExpressCheckoutReq SetExpressCheckoutReq) { this.SetExpressCheckoutAsync(SetExpressCheckoutReq, null); }
/// <remarks/> public void SetExpressCheckoutAsync(SetExpressCheckoutReq SetExpressCheckoutReq, object userState) { if ((this.SetExpressCheckoutOperationCompleted == null)) { this.SetExpressCheckoutOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetExpressCheckoutOperationCompleted); } this.InvokeAsync("SetExpressCheckout", new object[] { SetExpressCheckoutReq}, this.SetExpressCheckoutOperationCompleted, userState); }
public string SetExpressCheckout(PayPalInformation payPalInformation, string payPalSubmitUrl, string payPalCancelUrl) { string result = string.Empty; SetExpressCheckoutRequestType SetECReqType = new SetExpressCheckoutRequestType(); SetExpressCheckoutRequestDetailsType SetECReqTypeDetails = new SetExpressCheckoutRequestDetailsType(); SetExpressCheckoutResponseType SetECRes = new SetExpressCheckoutResponseType(); SetExpressCheckoutReq SetECReq = new SetExpressCheckoutReq(); SetECReqType.Version = "53.0"; SetECReqTypeDetails.OrderTotal = new BasicAmountType(); SetECReqTypeDetails.OrderTotal.currencyID = CurrencyCodeType.GBP; SetECReqTypeDetails.OrderTotal.Value = payPalInformation.Order.SubTotal.ToString(); //order.OrderTotal = GetAmountValue(payment.GrossAmount); //order.Tax = GetAmountValue(payment.TaxAmount); SetECReqTypeDetails.ReturnURL = ConfigurationManager.AppSettings["PayPalReturnURL"]; SetECReqTypeDetails.CancelURL = ConfigurationManager.AppSettings["PayPalCancelURL"]; SetECReqType.SetExpressCheckoutRequestDetails = SetECReqTypeDetails; SetECReq.SetExpressCheckoutRequest = SetECReqType; UserIdPasswordType user = new UserIdPasswordType(); user.Username = this.APIUsername; user.Password = this.APIPassword; user.AuthCert = CertPath; PayPalAPIAASoapBinding ppInterface = new PayPalAPIAASoapBinding(); ppInterface.Url = this.APIPath; ppInterface.RequesterCredentials = new CustomSecurityHeaderType(); ppInterface.RequesterCredentials.Credentials = user; //this is .net 2.0 specific portion of the code //that allows us to have the .p12 on the filesystem and //not have to register it with WinHttpCertCfg uses //X509Certificate2 class. FileStream fStream = File.Open(CertPath, FileMode.Open, FileAccess.Read); byte[] buffer = new byte[fStream.Length]; int count = fStream.Read(buffer, 0, buffer.Length); fStream.Close(); //use .net 2.0 X509Certificate2 class to read .p12 from filesystem //where "12345678" is the private key password X509Certificate2 x509 = new X509Certificate2(buffer, CertPassword); ppInterface.ClientCertificates.Add(x509); //service.ClientCertificates.Add(x509); try { SetECRes = ppInterface.SetExpressCheckout(SetECReq); switch (SetECRes.Ack) { case AckCodeType.Success: result = SetECRes.Token; break; default: // show errors if Ack is NOT Success result = "API response: <b>" + SetECRes.Ack.ToString() + "</b><br> Timestamp: <b>" + SetECRes.Timestamp.ToLongTimeString() + "</b><br> Version: <b>" + SetECRes.Version.ToString() + "</b><br> Error code: <b>" + SetECRes.Errors[0].ErrorCode + "</b><br> Short error: <b>" + SetECRes.Errors[0].ShortMessage + "</b><br> Long error: <b>" + SetECRes.Errors[0].LongMessage; break; } } catch (Exception ex) { result = ex.ToString(); } return result; }