简体   繁体   中英

How to create customer & items in quickbook through api in rails?

I want to create invoice in my Quickbooks account through API from my rails application, but it requires to add customer and item before creating invoice. But I can't get the idea how to add customer and items through API. Can you suggest me???

Thanks.

Start here:

Follow the docs ( https://developer.intuit.com/docs/0100_accounting ) and implement OAuth to connect to QuickBooks Online.

Create customers by HTTP POSTing a JSON request to QuickBooks Online:

The JSON request will look something like this:

{
    "BillAddr": {
        "Line1": "123 Main Street",
        "City": "Mountain View",
        "Country": "USA",
        "CountrySubDivisionCode": "CA",
        "PostalCode": "94042"
    },
    "Notes": "Here are other details.",
    "Title": "Mr",
    "GivenName": "James",
    "MiddleName": "B",
    "FamilyName": "King",
    "Suffix": "Jr",
    "FullyQualifiedName": "King Groceries",
    "CompanyName": "King Groceries",
    "DisplayName": "King's Groceries",
    "PrimaryPhone": {
        "FreeFormNumber": "(555) 555-5555"
    },
    "PrimaryEmailAddr": {
        "Address": "jdrew@myemail.com"
    }
}

You'll get back something like this:

{
    "Customer": {
        "Taxable": true,
        "BillAddr": {
            "Id": "112",
            "Line1": "123 Main Street",
            "City": "Mountain View",
            "Country": "USA",
            "CountrySubDivisionCode": "CA",
            "PostalCode": "94042"
        },
        "Notes": "Here are other details.",
        "Job": false,
        "BillWithParent": false,
        "Balance": 0,
        "BalanceWithJobs": 0,
        "CurrencyRef": {
            "value": "USD",
            "name": "United States Dollar"
        },
        "PreferredDeliveryMethod": "Print",
        "domain": "QBO",
        "sparse": false,
        "Id": "67",
        "SyncToken": "0",
        "MetaData": {
            "CreateTime": "2015-07-23T10:58:12-07:00",
            "LastUpdatedTime": "2015-07-23T10:58:12-07:00"
        },
        "Title": "Mr",
        "GivenName": "James",
        "MiddleName": "B",
        "FamilyName": "King",
        "Suffix": "Jr",
        "FullyQualifiedName": "King's Groceries",
        "CompanyName": "King Groceries",
        "DisplayName": "King's Groceries",
        "PrintOnCheckName": "King Groceries",
        "Active": true,
        "PrimaryPhone": {
            "FreeFormNumber": "(555) 555-5555"
        },
        "PrimaryEmailAddr": {
            "Address": "jdrew@myemail.com"
        },
        "DefaultTaxCodeRef": {
            "value": "2"
        }
    },
    "time": "2015-07-23T10:58:12.099-07:00"
}

Make sure you save that Id attribute, you'll need that later.

The process for creating Items is similar. Docs:

Everything is just standard OAuth requests. Go grab an OAuth library for Rails and you should be all set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM