I am using paypal API for .NET to create payments.
My exact code in Console Application:
// Get a reference to the config
var config = ConfigManager.Instance.GetProperties();
// Use OAuthTokenCredential to request an access token from PayPal
var accessToken = new OAuthTokenCredential(config).GetAccessToken();
var apiContext = new APIContext(accessToken);
var p = new Payment();
p.intent = "sale";
p.payer = new Payer();
p.payer.payment_method = "credit_card"; //paypal or credit_card
var t = new Transaction();
t.amount = new Amount();
t.amount.currency = "GBP";
t.amount.total = "10.00";
t.amount.details = new Details();
t.amount.details.subtotal = "6.00";
t.amount.details.tax = "2.00";
t.amount.details.shipping = "2.00";
t.item_list = new ItemList();
t.item_list.items = new List<Item>();
var i1 = new Item();
i1.quantity = "1";
i1.name = "OBJETO TESTE";
i1.price = "6.00";
i1.currency = "GBP";
i1.sku = "TESTE";
t.item_list.items.Add(i1);
var a = new ShippingAddress();
a.recipient_name = "ADDRESS";
a.line1 = "LINE1";
a.line2 = "LINE2";
a.city = "LONDOM";
a.country_code = "GB";
a.postal_code = "NW19EA";
t.item_list.shipping_address = a;
p.transactions = new List<Transaction>();
p.transactions.Add(t);
p.redirect_urls = new RedirectUrls();
p.redirect_urls.cancel_url = string.Format("{0}{1}", "http://localhost:3161/", "Order/CancelPayment");
p.redirect_urls.return_url = string.Format("{0}{1}", "http://localhost:3161/", "Order/CompletePayment");
var payment = Payment.Create(apiContext, p);
If I change payment method to paypal, its working. if I send credit_card I get error 500.
debug_id: 30e0f1bb08d3f
configuration: live
Merchants from UK cannot make Direct(Credit Card) Payments using REST API.
You will need to upgrade your account to PRO to make use of Direct Card Payments.
Only US merchants can make direct card payments in REST API without a PRO account.
Related
I am trying to create a new project in MS Project Server 2016 using PSI C#. It creates a new project along with the task but when I tried to set the values of some custom fields and try to load/execute the query, it returns "CSOMUnknownUser" error.
Can anyone help me out to sort out this problem. my sample code is here
worker = new Classes.ProjectServerWorker();
worker.projContext = new Microsoft.ProjectServer.Client.ProjectContext(SPContext.Current.Web.Url);
NetworkCredential cred = new NetworkCredential();
cred.Domain = "abc";
cred.UserName = "abc";
cred.Password = "abc";
worker.projContext.Credentials = cred;
ProjectCreationInformation newProj = new ProjectCreationInformation();
//ProjectContext projContext = new ProjectContext(SPContext.Current.Web.Url + "/sites/PWA");
try
{
newProj.Id = Guid.NewGuid();
string strGuidID = newProj.Id.ToString();
newProj.Name = "new project title";
newProj.Description = "new project requirement details";
PublishedProject newPublishedProj = worker.projContext.Projects.Add(newProj);
QueueJob qJob = worker.projContext.Projects.Update();
//jobState = worker.projContext.WaitForQueue(qJob, timeoutSeconds);
IsProjectCreated = true;
worker.projContext.Load(worker.projContext.Projects);
worker.projContext.ExecuteQuery();
var proj = worker.projContext.Projects.First(p => p.Name == newProj.Name);
worker.projContext.ExecuteQuery();
var draftProj = proj.CheckOut();
// Creating Task under project
TaskCreationInformation newtask = new TaskCreationInformation();
newtask.Name = "First Task";
newtask.Start = DateTime.Today;
newtask.Finish = DateTime.Today.AddDays(35);
newtask.Id = Guid.NewGuid();
newtask.IsManual = false;
DraftTask drafttask = draftProj.Tasks.Add(newtask);
draftProj.Update();
draftProj.Publish(true); // Publish and check-in the project
worker.projContext.ExecuteQuery();
// Setting Custom Fields data
var guidID = new Guid(strGuidID);
var projcs = worker.projContext.Projects.GetByGuid(guidID);
var draftProjCS = projcs.CheckOut().IncludeCustomFields;
worker.projContext.Load(draftProjCS);
worker.projContext.ExecuteQuery();
string WorkRequestTitle = "new project";
var field1 = worker.projContext.CustomFields.Where(a => a.InternalName== ProjectFields.WorkRequestTitle).FirstOrDefault();
draftProjCS.SetCustomFieldValue(field1.InternalName, WorkRequestTitle);
I'm trying to use Stripe on my web following this Stripe doc: https://stripe.com/docs/legacy-checkout/webforms but when i debug the code throws a TypeInitializationException on both create(), the customer and charge.
if (Request.Form["stripeToken"] != null)
{
var optionsCustomer = new CustomerCreateOptions
{
Email = Request.Form["stripeEmail"].ToString(),
Source = Request.Form["stripeToken"].ToString(),
};
var serviceCustomer = new CustomerService();
Customer customer = serviceCustomer.Create(optionsCustomer);
var optionsCharge = new ChargeCreateOptions
{
Amount = 1099,
Currency = "eur",
};
var serviceCharge = new ChargeService();
serviceCharge.Create(optionsCharge);
}
i am trying to use google QPX Express API for ASP.NET in order to read flights with cheap price but stuck on the below code.please share me any idea .
// Passengers
PassengerCounts passengers = new PassengerCounts();
passengers.AdultCount = 2;
// Slice
List<SliceInput> slices = new List<SliceInput>();
SliceInput slice = new SliceInput();
slice.Origin = "ADD";
slice.Destination = "NBO";
slice.Date = "2015-10-29";
slices.Add(slice);
// Options request
TripOptionsRequest tripOptions = new TripOptionsRequest();
tripOptions.Passengers = passengers;
tripOptions.Solutions = 10;
tripOptions.Slice = slices;
Regards,
You need to send your request against the authenticated service and call execute.
QPXExpressService service = new QPXExpressService(new BaseClientService.Initializer()
{
ApiKey = "xxxx",
ApplicationName = "Daimto QPX Express Sample",
});
TripsSearchRequest x = new TripsSearchRequest();
x.Request = new TripOptionsRequest();
x.Request.Passengers = new PassengerCounts { AdultCount = 2 };
x.Request.Slice = new List<SliceInput>();
x.Request.Slice.Add(new SliceInput() { Origin = "ADD", Destination = "NBO", Date = "2015-10-29" });
x.Request.Solutions = 10;
var result = service.Trips.Search(x).Execute();
When I'm trying to Request the Competettive Price for a Product i always get a
MarketplaceWebServiceProductsException
The Message is empty, and the TargetSite gives me
T Call[T](MWSClientCsRuntime.IMwsRequestType1[T], MWSClientCsRuntime.IMwsObject)
Here is the Code I'm running
MarketplaceWebServiceProducts.MarketplaceWebServiceProducts service = new MarketplaceWebServiceProductsClient (config.MWS_AccessKeyId, config.MWS_secretKey);
SellerSKUListType list = new SellerSKUListType ();
List<String> SKUList = new List<String> ();
SKUList.Add (SKU);
list.SellerSKU = SKUList;
GetCompetitivePricingForSKURequest request = new GetCompetitivePricingForSKURequest ();
request.MarketplaceId = config.MWS_MarketPlaceId;
request.SellerId = config.MWS_SellerId;
request.SellerSKUList = list;
GetCompetitivePricingForSKUResponse response = service.GetCompetitivePricingForSKU (request);
Have you tried to specify application name and application version?
var config = new MarketplaceWebServiceProductsConfig();
config.ServiceURL = "https://mws.amazonservices.com/Products/2011-10-01";
config.SetUserAgent(ApplicationName, ApplicationVersion);
var service = new MarketplaceWebServiceProductsClient(ApplicationName, ApplicationVersion, MWSaccessKey, MWSsecretKey, config);
I am working on Expedia hotel API.All the function are working except booking.All the other request using GET method for requesting.But in booking we have to use the POST method with different URL.So i changed the URL for request but still getting the error.
My codes are
HotelServicesImplService client = new HotelServicesImplService();
HotelRoomReservationRequest bookreq = new HotelRoomReservationRequest();
HotelRoomReservationResponse bookres = new HotelRoomReservationResponse();
addressInfo bookad = new addressInfo();
reservationInfo bookinfo = new reservationInfo();
client.Url = "https://book.api.ean.com/ean-services/rs/hotel/v3";
//bookreq.minorRevSpecified = true;
//bookreq.minorRev = 25;
bookreq.hotelId = 106347;
bookreq.apiKey = "api";
bookreq.cid = "cid";
bookreq.arrivalDate = "12/11/2013";
bookreq.departureDate = "12/13/2013";
bookreq.supplierType = SupplierType.E;
bookreq.rateKey = "af00b688-acf4-409e-8bdc-fcfc3d1cb80c";
bookreq.roomTypeCode = "198058";
bookreq.rateCode = "484072";
bookreq.RoomGroup = new[] { new Room
{
numberOfAdults=Convert.ToInt32(2),
numberOfChildren=Convert.ToInt32(0),
childAges=new int[] {} ,
firstName="Test Booking",
lastName="Test Booking",
bedTypeId="23",
smokingPreference=SmokingPreference.NS,
}};
float i = float.Parse("231.18");
bookreq.currencyCode = "USD";
bookreq.chargeableRate = i;
bookinfo.email = "ranaabhi007#yahoo.com";
bookinfo.firstName = "TestBooking";
bookinfo.lastName = "TestBooking";
bookinfo.homePhone = "2145370159";
bookinfo.workPhone = "2145370159";
bookinfo.creditCardType = "CA";
bookinfo.creditCardNumber = "5401999999999999";
bookinfo.creditCardIdentifier = "TestBooking";
bookinfo.creditCardExpirationMonth = "12";
bookinfo.creditCardExpirationYear = "2015";
bookad.city = "Seattle";
bookad.stateProvinceCode = "WA";
bookad.countryCode = "US";
bookad.postalCode = "98004";
bookreq.ReservationInfo = bookinfo;
bookad.address1 = "travelnow";
//bookad.city = txtCity.Text;
//bookad.stateProvinceCode = txtState.Text;
//bookad.countryCode = txtCountry.Text;
//bookad.postalCode = txtPostal.Text;
bookreq.AddressInfo = bookad;
bookres = client.getReservation(bookreq);
// HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(client);
Response.Write(bookres.confirmationNumbers);
Response.Write(bookres.departureDate);
Response.Write(bookres.drivingDirections);
Response.Write(bookres.CouponInformationResponse);
but i am still getting the error
The request failed with HTTP status 404: Not Found.
Are you sure your URL is correct? According to the documentation, it should be
https://book.api.ean.com/ean-services/rs/hotel/v3/res