我已使用NuGet包(IppDotNetSdkForQuickBooksApiV3)为我的项目添加了用于QuickBooks V3.0的IPP .Net SDK。
我可以对客户帐户数据执行CRUD操作。如何使用servicecontext执行信用卡交易?
这是我的示例代码,
#app/models/frequency.rb
class Frequency
validates :code, presence: true
end
#app/models/drug.rb
class DrugValidator < ActiveModel::Validator
def validate(record)
drug_attributes = {name: record.name}
if Drug.where(name: record.name).any?
record.errors[:base] << "The drug #{record.name} already exists in system."
end
end
end
class Drug
validates_with DrugValidator, if: (lambda {|drug| drug.name.present?})
end
> pf = Frequency.find_or_create_by(code: 'Q24')
Frequency Load (0.4ms) SELECT "frequencies".* FROM "frequencies" WHERE "frequencies"."code" = $1 LIMIT 1 [["code", "Q24"]]
=> #<Frequency id: 7, code: "Q24", created_at: "2015-11-02 03:41:34", updated_at: "2015-11-02 03:41:34">
> pf.persisted?
=> true
> pf.valid?
=> true
> pf.new_record?
=> false
> pd = Drug.find_or_create_by(name: 'SomeDrug', unit: 'tablet')
=> #<Drug id: 10, name: "SomeDrug", created_at: "2015-11-05 07:42:46", updated_at: "2015-11-05 07:42:46", unit: "tablet">
> pd.persisted?
=> true
> pd.new_record?
=> false
> pd.valid?
=> false
> pd.errors.messages
=> {:base=>["The drug SomeDrug already exists in system."]}
答案 0 :(得分:0)
您可以向我发送示例代码,以便将客户信用额度添加到quickbooks
public static void test()
{
string accessToken = "12432543252345";
string accessTokenSecret = "5b1cb122b340db43d4bae6bb880c8a284499";
string consumerKey = "qyprdWTsI8u6Qq3fwiIUvkweM2mabZ";
string consumerSecret = "9KH9mFlGy5CPSUQCOV2lM3lHGs05AK5TtdS0QLWv";
OAuthRequestValidator oauthValidator = new OAuthRequestValidator(
accessToken, accessTokenSecret, consumerKey, consumerSecret);
string appToken = "5b1cb122b340db43d4bae6bb880c8a28449";
string companyID = "32534654";
ServiceContext context = new ServiceContext(appToken, companyID, IntuitServicesType.QBO, oauthValidator);
DataService service = new DataService(context);
Customer customer = new Customer
{
GivenName = "Mary",
Title = "Ms.",
MiddleName = "Jayne",
FamilyName = "Cooper",
Id = "1234214"
};
//Mandatory Fields
customer.CCDetail.Number = "444747447474474";
customer.CCDetail.CcExpiryMonth = 12;
customer.CCDetail.CcExpiryYear = 2018;
Customer resultCustomer = service.Add(customer) as Customer;
}
您可以验证以上代码吗? mail id adarsh.p@nxtlive.com