I am trying to directly charge the customer using Stripe. I am using this sample code:
var stripeChargeCreateOptions = new StripeChargeCreateOptions();
stripeChargeCreateOptions.Amount = 1000;
stripeChargeCreateOptions.Currency = "usd";
stripeChargeCreateOptions.Description = "Test";
stripeChargeCreateOptions.Source = new StripeSourceOptions()
{
Number = "4242424242424242",
ExpirationYear = "2022",
ExpirationMonth = "10",
AddressCountry = "US", // optional
AddressLine1 = "24 Beef Flank St", // optional
AddressLine2 = "Apt 24", // optional
AddressCity = "Biggie Smalls", // optional
AddressState = "NC", // optional
AddressZip = "27617", // optional
Name = "Joe Meatballs", // optional
Cvc = "1223" // optional
};
stripeChargeCreateOptions.Capture = true;
var stripeChargeService = new StripeChargeService();
StripeCharge stripeCharge = stripeChargeService.Create(stripeChargeCreateOptions);
This seems to work in test mode. Here are my 3 questions:
The amount 1000 here is 10 USD - right?
Will this also work using live keys? I heard Stripe does not allow direct charge and requires us to their Javascript and store token for us to actually charge? How is it working in test mode?
What is the importance of stripeChargeCreateOptions.Capture = true; What would happen if I set it to false?
Yes, that's right. All amounts are in cents/pence.
I don't know enough about Stripe to help you with this one I'm afraid.
This tells Stripe what process to use to carry out the transaction - it's the second half of a charge previously created with the Capture property set to 'false'. So you would later need to call the API with it set to true to actually complete the charge. See the API for more information: https://stripe.com/docs/api?lang=php#capture_charge
Related
I'm using Visual Studio to design a software that uses IBKR API to buy stocks. It's working fine if I'm buying integer stocks but I'm not able to buy fractional stocks.
I have found the function order.CashQty but it's not working.. this is the code that I'm using to buy, and it's working when I'm trying to buy integer stocks. Do you have any suggestion?
public void send_order(string side)
{
IBApi.Contract contract = new IBApi.Contract();
contract.Symbol = Global_variable.stock_sel;
contract.SecType = "STK";
contract.Exchange = cbMarket.Text;
contract.PrimaryExch = "ISLAND";
contract.Currency = "USD";
IBApi.Order order = new IBApi.Order();
order.OrderId = order_id;
order.Action = side;
order.OrderType = cbOrderType.Text;
//order.CashQty = 33.5; <-- maybe is this the way to buy fractionale share?
order.TotalQuantity = 1;
if (cbOrderType.Text == "STP")
{
order.AuxPrice = Convert.ToDouble(numPrice.Value);
}
order.DisplaySize = Convert.ToInt32(tbVisible.Text);
order.OutsideRth = chkOutside.Checked;
ibClient.ClientSocket.placeOrder(order_id, contract, order);
order_id++;
tbValid_Id.Text = Convert.ToString(order_id);
}
Thank you very much!
that code of my program, I hope that will help you:
private void buyStock(string symbol)
{
// Create a new contract to specify the security we are searching for
IBApi.Contract contract = new IBApi.Contract();
// Set the underlying stock symbol from the cbSymbol combobox
contract.Symbol = symbol.ToUpper();
// Set the Security type to STK for a Stock
contract.SecType = "STK";
// Use "SMART" as the general exchange
contract.Exchange = "SMART";
// Set the primary exchange (sometimes called Listing exchange)
// Use either NYSE or ISLAND
contract.PrimaryExch = "ISLAND";
// Set the currency to USD
contract.Currency = "USD";
IBApi.Order order = new IBApi.Order();
// gets the next order id from the text box
order.OrderId = order_id;
// gets the side of the order (BUY, or SELL)
order.Action = "BUY";
// gets order type from combobox market or limit order(MKT, or LMT)
order.OrderType = "MKT";
// number of shares from Quantity
order.TotalQuantity = 400;
// Value from limit price
//order.LmtPrice = Convert.ToDouble(numPrice.Text);
//
//Visible shares to the market
// order.DisplaySize = Convert.ToInt32(tbVisible.Text);
//order.OutsideRth = cbOutsideRTH.Checked;
//order.OutsideRth = chkOutside.Checked;
// Place the order
ibClient.ClientSocket.placeOrder(order_id, contract, order);
// increase the order id value
order_id++;
}
I am trying to add a new defect in QC using OTA API. I am unable to set some mandatory fields while defect creation. Below is my code.I am using .NET framework 4.5 and C# for code development.
There is a problem with Issue Type field, constant used for Issue Type is BG_USER_02
If I set value to this Issue Type constant it shows error as "Required field can not be empty or SPACE filled" even though I already set value for status as bug1.Status = "New"
If I commented Issue Type that is
//Issue Type
//bug1["BG_USER_02"] = "Defect";
It gives error as Required field can not be empty or SPACE filled.;
Also Please tell me constant(eg.BG_USER_02) value used for following mandatory fields that is Issue Type, Product, Application & Module are correct or not If these are not proper constant values please suggest me constant values for these fields.
//Issue Type
bug1["BG_USER_02"] = "Defect";
//Product
bug1["BG_USER_07"] = "Product1";
//Application
bug1["BG_USER_08"] = "Application";
//Module
bug1["BG_USER_04"] = "Accounts";
string qcUrl = "http://localhost:XXXX/qcbin";
string qcDomain = "TestDomain";
string qcProject = "TestProject";
string qcLoginName = "user1";
string qcPassword = "user1";
TDConnection connection = new TDConnection();
connection.InitConnectionEx(qcUrl);
connection.ConnectProjectEx(qcDomain, qcProject, qcLoginName, qcPassword);
BugFactory bugFact = connection.BugFactory;
Bug bug1 = bugFact.AddItem(System.DBNull.Value);
//Summery
bug1.Summary = "This is summary";
//Detected in Cycle
bug1["BG_DETECTED_IN_RCYC"] = #"Release\Program\Test\Value";
// Detected in Release
bug1["BG_DETECTED_IN_REL"] = #"Release\Program\Test\Value";
//Issue Type
bug1["BG_USER_02"] = "Defect";
//Product
bug1["BG_USER_07"] = "Product1";
//Application
bug1["BG_USER_08"] = "Application";
//Module
bug1["BG_USER_04"] = "Accounts";
//Priority
bug1.Priority = "P1 - High";
//Severity
bug1["BG_SEVERITY"] = "SEVERITY1";
//Lines of Business
bug1.Project = "Fire";
//Reproducible
bug1["BG_REPRODUCIBLE"] = "Y";
// Owner Name
bug1.AssignedTo = "XYZ";
//Status
bug1.Status = "New";
//Detected By
bug1.DetectedBy = "user1";
//Detected on Date
bug1["BG_DETECTION_DATE"] = "9/9/2016";
//Detected in Version
bug1["BG_DETECTION_VERSION"] = "8.1.0.11";
//Description
bug1["BG_DESCRIPTION"] = "Description";
bug1.Post();
MessageBox.Show("Post");
connection.DisconnectProject();
connection.Logout();
connection.ReleaseConnection();
Thanks
Amrapali Kamble
I'm having trouble with NHibernate, First let me say I'm not native English talker, OK, let get to point.
As i face this error, i searched over the internet, and saw lot of people talking about it, but most of them had issue with cascade attribute, and totally if i wanna say, non matched my case, or even if it did i couldn't get through.
My Database is so small, but a bit complex.
My model files generated using Entity Developer.
As you can see there is inheritance, one-to-many and many-to-many relation ships,
As I am new to NHibernate, i write a test code, my normal test worked, till i add this many-to-many relation ship.
So i write this code:
//Owner o = new Owner
//{
// //OwnerId = Guid.NewGuid(),
// CellPhone1 = null,
// CellPhone2 = "09132198895",
// Phone = "03114335502",
// Firstname = "Hassan",
// Lastname = "Faghihi",
// OwnerTitle = PersonTitle.Mr
//};
//OwnerFactory ownerFactory = new OwnerFactory();
//ownerFactory.SaveOwner(o);
//SellHouse sh = new SellHouse
//{
// //ItemId = Guid.NewGuid(),
// Owner = o,
// Address = "dsasd",
// BuildYear = 1393,
// City = "Isfahan",
// Code = "A-512",
// Country = "Iran",
// Description = "Nothing",
// Dimensions = "4X5",
// Directions = Directions.North | Directions.South,
// Document = "dasd",
// Exchange = true,
// Facilities = Facilities.Elevator | Facilities.KichenMdfService | Facilities.Parking | Facilities.Warehouse,
// Floor = 4,
// HasYard = false,
// HouseType = HouseType.Apartment,
// IssueDate = DateTime.Now,
// Loan = 3124,
// Meter = 130,
// NumberOfBlocks = 4,
// NumberOfFloors = 0,
// OtherFacilities = "Nothing",
// Rooms = 2,
// ShareOfSixPart = 4.2f,
// State = "Isfahan",
// District = "kaveh",
// ExchangeDescription = "",
// Images = null,
// IsRented = false,
// Maps = null,
// MortgagePayed = 0,
// Price = 2222222,
// RentAmount = 0,
// Substructure = 4,
//};
GalleryFactory galleryFactory = new GalleryFactory();
Gallery g = new Gallery
{
Image = Properties.Resources.jeans_texture03.ToByte()
};
galleryFactory.SaveGallery(g);
SellHouseFactory sellHouseFactory = new SellHouseFactory();
//factory.SaveSellHouse(sh);
HashSet<Gallery> galleries = new HashSet<Gallery>();
galleries.Add(g);
SellHouse sellHouse = sellHouseFactory.GetSellHouses().FirstOrDefault();
if (sellHouse != null)
{
comboBox1.SelectedIndex = (int)sellHouse.Owner.OwnerTitle;
textBox1.Text = sellHouse.Owner.Firstname+sellHouse.Owner.Lastname;
//sellHouse.Images = galleries;
sellHouseFactory.SaveSellHouse(sellHouse);
}
i create an object of Owner, then save it, and pass it to sellHouse, and set Images and Maps (which are my many-to-many relation) to null.
so the sellHouse Created.
then i was wonder how to add image or map to my sellHouse,
So i pass a list containing one gallery element to sellHouse Maps property.
And it generate "Illegal attempt to associate a collection with two open sessions", first i though the reason is because my Gallery didn't saved before i pass it to sell house, so i did as you can see on my code, and did it manually.
But it still keep on generating that error...
I provide required file so, you can set up an example and understand my code better.
I'm very eager to hear your answer,cause my hands are tied do to my little knowledge over Hibernate and NHibernate.
Sources in DropBox:
enter link description here
Probably in all of your factory method you open a new session.
But you have to open just one session in every thread (or transaction).
I'm trying to create the service/product type in the invoice line item. It returns an error saying bad request, is my ItemRef phrased correctly. My service/product is created in qbo already, its called Subscription Fee, it's the 3rd in the dropdown list.
line.AnyIntuitObject = new Intuit.Ipp.Data.SalesItemLineDetail()
{
ItemRef = new Intuit.Ipp.Data.ReferenceType()
{
Value = "3",
type = "Item",
name = "Subscription Fee"
},
ItemElementName = Intuit.Ipp.Data.ItemChoiceType.UnitPrice,
AnyIntuitObject = (decimal)item.Rate, // Line item rate
Qty = (decimal)item.Quantity,
QtySpecified = true,
ServiceDate = DateTime.Now.Date,
ServiceDateSpecified = true,
TaxCodeRef = new Intuit.Ipp.Data.ReferenceType()
{
Value = taxCode0ZR.Id,
type = Enum.GetName(typeof(Intuit.Ipp.Data.objectNameEnumType), Intuit.Ipp.Data.objectNameEnumType.TaxRate),
name = taxCode0ZR.Name
},
};
What am i creating wrongly please help.
You cannot create an Item within an invoice or rather any entity within an entity.
QBO v3 does not supports creating entities on the fly.
You first need to do a create Item.
Get the Id of that Item and refer it in your Invoice.
Also, enable request/response log to get the details of the errors in log files-
https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0150_ipp_.net_devkit_3.0/0002_configuration/override_configuration
My working envirnment is Visual Studio 2008 + C#
I am working on Amazon WebService, I want to fetch the data from Amazon using SOAP but when I am trying to pass IDType = UPC it gives me below error message, so what can I do for this ?
Error:
036725229884 is not a valid value for ItemId. Please change this value and retry your request
MyCode:
ItemLookupRequest request1 = new ItemLookupRequest();
request1.IdType = ItemLookupRequestIdType.UPC;
request1.IdTypeSpecified = true;
request1.ItemId = new string[] { ProductID };
request1.ResponseGroup = new string[] { "Request", "Large", "OfferFull", "BrowseNodes" };
request1.MerchantId = "All";
request1.Condition = Condition.All;
request1.SearchIndex = "Books";
Note:
How can I add multiple SearchIndex like ("Books","Photo","Video")?
I have used following WebService:
http://webservices.amazon.com/AWSECommerceService/2009-11-01/US/AWSECommerceService.wsdl
Also be weary of the difference between UPC and EAN.
UPC = 12 digits,
EAN = 13 digits
If you just punch in a UPC 738678251584 (12 digits) or EAN 3253581057803 (13 digits) to Amazon.com it will show both as being UPC in the description, but using the API you must specify EAN when searching.
We have products with both and you need to specify the search type accordingly or it won't get found.
Edit: OR you can just prepend a 0 to any 12 digit numbers and always search for EAN. This is probably the best solution. By definition "0" + UPC = EAN
This request worked for me (searchType is either UPC or EAN):
ItemLookup itemLookup = new ItemLookup()
{
AssociateTag = "XXXXX-20",
};
itemLookup.AWSAccessKeyId = ACCESS_ID;
ItemLookupRequest itemLookupRequest = new ItemLookupRequest();
itemLookupRequest.IdTypeSpecified = true;
itemLookupRequest.IdType = searchType;
itemLookupRequest.SearchIndex = "All";
itemLookupRequest.ItemId = upcEanList;
itemLookupRequest.ResponseGroup = new[] { "OfferSummary", "ItemAttributes" };
itemLookup.Request = new ItemLookupRequest[] { itemLookupRequest };
I don't think Amazon supports queries across multiple search indices. However, there is a special index named All that you can use with UPC lookups. There are some limitations on the parameters used with this index but since you are specifying All for MerchantId and Condition it may work. If not, you could do the query without those parameters and then issue a new query once you have the ASINs for the UPCs you are interested in.