RIAEvangelist / node-dominos-pizza-api

This is a node.js wrapper for the dominos pizza apis
MIT License
534 stars 129 forks source link

Successful Order #45

Closed mynamebrody closed 8 years ago

mynamebrody commented 8 years ago

Also I tried last night to complete a full order using the module. It states it was Validated, Priced, and Ordered.. but I was not charged, I couldn't track it down (even on their website). I'm using the code for pizzadash but with actual customer and credit card information.

Also note: When I'm pricing the order, I've tried just outputting the entire returned order, it doesn't have a price on it, or estimated wait in the object?

julianh2o commented 8 years ago

So I've just managed yesterday to successfully order a pizza using the API for the first time after fixing the Phone number bug. Which branch are you using? I'd suggest recloning (or updating) the master branch and trying again. Without the phone fix I made yesterday, it probably wouldn't have worked.

Use this to print out the response you get from the place order callback and check the "Status" field. You should be able to figure out what went wrong by that. var util = require("util"); console.log(util.inspect(myObject, {showHidden: false, depth: null}));

If you still don't have any luck, post the output here and let me know. (don't forget to sanitize it for any personal info)

mynamebrody commented 8 years ago

Will do! I'll give it a shot tonight or tomorrow!

julianh2o commented 8 years ago

Great, thanks! If you drop into Glitter or post here, I'll see if I can be around to respond and help you get it running.

mynamebrody commented 8 years ago

Yeah, still having issues:

Dash Button Found
Order is Priced
Order is Validated
{ Order:
   { Address:
      { Type: 'House',
        Street: [SANITIZED],
        City: [SANITIZED],
        Region: [SANITIZED],
        PostalCode: [SANITIZED],
        StreetNumber: [SANITIZED],
        StreetName: [SANITIZED] },
     Coupons: [ { Code: '9193',
                Qty: 1,
                ID: 1,
                isNew: true,
                Status: 0,
                StatusItems: [ [Object] ] } ],
     CustomerID: '',
     Email: [SANITIZED],
     Extension: '',
     FirstName: 'Brody',
     LastName: 'Berson',
     LanguageCode: 'en',
     OrderChannel: 'OLO',
     OrderID: [SANITIZED],
     OrderMethod: 'Web',
     Payments: [ [Object] ],
     Phone: [SANITIZED],
     Products: [ { Code: '12SCREEN',
                Qty: 1,
                ID: 1,
                isNew: true,
                Options: { S: [Object], P: [Object] },
                Status: 0,
                CategoryCode: 'Pizza',
                FlavorCode: 'HANDTOSS',
                SizeCode: '12',
                SpecialtyCode: 'PIZZA' },
              { Code: 'B8PCSCB',
                Qty: 1,
                ID: 2,
                isNew: true,
                StatusItems: [ [Object] ],
                Status: 1,
                CategoryCode: 'Bread',
                FlavorCode: 'SCBRD',
                SizeCode: 'BRD8',
                SpecialtyCode: 'BRDSCB' } ],
     Market: 'UNITED_STATES',
     Currency: 'USD',
     ServiceMethod: 'Delivery',
     SourceOrganizationURI: 'order.dominos.com',
     StoreID: 6371,
     Tags: {},
     Version: '1.0',
     NoCombine: true,
     Partners: {},
     NewUser: true,
     metaData: {},
     BusinessDate: '',
     PriceOrderTime: '',
     IP: '73.229.234.2',
     Promotions: { Redeemable: [], Valid: [] },
     Status: -1,
     StatusItems: [ { Code: 'AutoAddedOrderId' },
                  { Code: 'PriceInformationRemoved' },
                  { Code: 'RuleExecutionError',
                    Message: 'BusinessRule ConditionalExecutionBusinessRule failed. Cause: java.lang.Long cannot be cast to java.lang.String' } ],
     PlaceOrderTime: '2015-09-27 19:01:51' },
  Offer: { CouponList: [], ProductOffer: '' },
  Status: -1,
  StatusItems: [ { Code: 'Failure' } ] }

Order placed!
julianh2o commented 8 years ago

Message: 'BusinessRule ConditionalExecutionBusinessRule failed. Cause: java.lang.Long cannot be cast to java.lang.String'

Seems that this is the cause.. If I had to guess, I'd say that has to do with something like your phone number or zip or something.. Perhaps something that was sanitized out. Are you surrounding your zip code in quotes? Check your other fields too, compare against examples perhaps?

madelinecameron commented 8 years ago

Have you tried switching price and validate? On Dominos, it validates then prices. It may be expecting certain keys that don't exist in the JSON you are passing.

I see a few are missing so that might be the issue. On Sep 27, 2015 6:36 PM, "Julian Hartline" notifications@github.com wrote:

Message: 'BusinessRule ConditionalExecutionBusinessRule failed. Cause: java.lang.Long cannot be cast to java.lang.String'

Seems that this is the cause.. If I had to guess, I'd say that has to do with something like your phone number or zip or something.. Perhaps something that was sanitized out. Are you surrounding your zip code in quotes? Check your other fields too, compare against examples perhaps?

— Reply to this email directly or view it on GitHub https://github.com/RIAEvangelist/node-dominos-pizza-api/issues/45#issuecomment-143603216 .

madelinecameron commented 8 years ago

Also, you seem to be missing the 'X' option and 'C' option on your pizza. I always include both of your those options because all pizzas on Dominos had those included

C is cheese (describes how much and what half you want it on ["1": "1/1"] is the basic)

X is either an upsell or sauce. If I remember right, other sauces also use an option code with an X as well. So assuming C is marinara, then the regular ["1": "1/1"] On Sep 27, 2015 6:46 PM, "Madeline Cameron" maddalic@gmail.com wrote:

Have you tried switching price and validate? On Dominos, it validates then prices. It may be expecting certain keys that don't exist in the JSON you are passing.

I see a few are missing so that might be the issue. On Sep 27, 2015 6:36 PM, "Julian Hartline" notifications@github.com wrote:

Message: 'BusinessRule ConditionalExecutionBusinessRule failed. Cause: java.lang.Long cannot be cast to java.lang.String'

Seems that this is the cause.. If I had to guess, I'd say that has to do with something like your phone number or zip or something.. Perhaps something that was sanitized out. Are you surrounding your zip code in quotes? Check your other fields too, compare against examples perhaps?

— Reply to this email directly or view it on GitHub https://github.com/RIAEvangelist/node-dominos-pizza-api/issues/45#issuecomment-143603216 .

mynamebrody commented 8 years ago

I am validating before pricing in the code, it's returning in opposite order though.. Also when validating and pricing, I'm logging the results and printing them out, the pizza has Options: { C: [Object], X: [Object], S: [Object], P: [Object] } in both validation and pricing, also at the bottom of validating there is this in the bottom of the result response: [ { Code: 'CreditCardPaymentNotAllowed' } ]

mynamebrody commented 8 years ago

Full response from the following:

            console.log(result.result);
            console.log(result.result.Order.Coupons);
            console.log(result.result.Order.Products);
            console.log(result.result.Order.StatusItems);
            console.log("Order is Priced\n\n\n");
Dash Button Found
{ Order:
   { Address:
      { Type: 'House',
        Street: [SANITIZED],
        City: [SANITIZED],
        Region: [SANITIZED],
        PostalCode: [SANITIZED]},
     Coupons: [ [Object] ],
     CustomerID: '',
     Email: [SANITIZED],
     Extension: '',
     FirstName: 'Brody',
     LastName: 'Berson',
     LanguageCode: 'en',
     OrderChannel: 'OLO',
     OrderID: '',
     OrderMethod: 'Web',
     OrderTaker: null,
     Payments: [ [Object] ],
     Phone: [SANITIZED],
     Products: [ [Object], [Object] ],
     Market: 'UNITED_STATES',
     Currency: 'USD',
     ServiceMethod: 'Delivery',
     SourceOrganizationURI: 'order.dominos.com',
     StoreID: 6371,
     Tags: {},
     Version: '1.0',
     NoCombine: true,
     Partners: {},
     NewUser: true,
     metaData: {},
     Amounts: {},
     BusinessDate: '',
     EstimatedWaitMinutes: '',
     PriceOrderTime: '',
     IP: '73.229.234.2',
     Status: -1,
     StatusItems: [ [Object] ],
     Promotions: { Redeemable: [], Valid: [] } },
  Offer: { CouponList: [], ProductOffer: '' },
  Status: -1,
  StatusItems: [ { Code: 'Failure' } ] }
[ { Code: '9193',
    Qty: 1,
    ID: 1,
    isNew: true,
    Status: 0,
    StatusItems: [ [Object] ] } ]
[ { Code: '12SCREEN',
    Qty: 1,
    ID: 1,
    isNew: true,
    Options: { C: [Object], X: [Object], S: [Object], P: [Object] },
    CategoryCode: 'Pizza',
    FlavorCode: 'HANDTOSS',
    SizeCode: '12',
    SpecialtyCode: 'PIZZA' },
  { Code: 'B8PCSCB',
    Qty: 1,
    ID: 1,
    isNew: true,
    Options: { C: [Object], X: [Object] },
    CategoryCode: 'Bread',
    FlavorCode: 'SCBRD',
    SizeCode: 'BRD8',
    SpecialtyCode: 'BRDSCB' } ]
[ { Code: 'CreditCardPaymentNotAllowed' } ]
Order is Validated

{ Order:
   { Address:
      { Type: 'House',
        Street: [SANITIZED],
        City: [SANITIZED],
        Region: [SANITIZED],
        PostalCode: [SANITIZED] },
     Coupons: [ [Object] ],
     CustomerID: '',
     Email: [SANITIZED],
     Extension: '',
     FirstName: 'Brody',
     LastName: 'Berson',
     LanguageCode: 'en',
     OrderChannel: 'OLO',
     OrderID: '',
     OrderMethod: 'Web',
     OrderTaker: null,
     Payments: [ [Object] ],
     Phone: [SANITIZED],
     Products: [ [Object], [Object] ],
     Market: 'UNITED_STATES',
     Currency: 'USD',
     ServiceMethod: 'Delivery',
     SourceOrganizationURI: 'order.dominos.com',
     StoreID: 6371,
     Tags: {},
     Version: '1.0',
     NoCombine: true,
     Partners: {},
     NewUser: true,
     metaData: {},
     Amounts: {},
     BusinessDate: '',
     EstimatedWaitMinutes: '',
     PriceOrderTime: '',
     IP: '73.229.234.2',
     Status: -1,
     StatusItems: [ [Object] ],
     Promotions: { Redeemable: [], Valid: [] } },
  Offer: { CouponList: [], ProductOffer: '' },
  Status: -1,
  StatusItems: [ { Code: 'Failure' } ] }
[ { Code: '9193',
    Qty: 1,
    ID: 1,
    isNew: true,
    Status: 0,
    StatusItems: [ [Object] ] } ]
[ { Code: '12SCREEN',
    Qty: 1,
    ID: 1,
    isNew: true,
    Options: { C: [Object], X: [Object], S: [Object], P: [Object] },
    CategoryCode: 'Pizza',
    FlavorCode: 'HANDTOSS',
    SizeCode: '12',
    SpecialtyCode: 'PIZZA' },
  { Code: 'B8PCSCB',
    Qty: 1,
    ID: 1,
    isNew: true,
    Options: { C: [Object], X: [Object] },
    CategoryCode: 'Bread',
    FlavorCode: 'SCBRD',
    SizeCode: 'BRD8',
    SpecialtyCode: 'BRDSCB' } ]
[ { Code: 'CreditCardPaymentNotAllowed' } ]
Order is Priced

{ Order:
   { Address:
      { Type: 'House',
        Street: [SANITIZED],
        City: [SANITIZED],
        Region: [SANITIZED],
        PostalCode: [SANITIZED],
        StreetNumber: [SANITIZED],
        StreetName: [SANITIZED] },
     Coupons: [ [Object] ],
     CustomerID: '',
     Email: [SANITIZED],
     Extension: '',
     FirstName: 'Brody',
     LastName: 'Berson',
     LanguageCode: 'en',
     OrderChannel: 'OLO',
     OrderID: [SANITIZED],
     OrderMethod: 'Web',
     Payments: [ [Object] ],
     Phone: [SANITIZED],
     Products: [ [Object], [Object] ],
     Market: 'UNITED_STATES',
     Currency: 'USD',
     ServiceMethod: 'Delivery',
     SourceOrganizationURI: 'order.dominos.com',
     StoreID: 6371,
     Tags: {},
     Version: '1.0',
     NoCombine: true,
     Partners: {},
     NewUser: true,
     metaData: {},
     BusinessDate: '',
     PriceOrderTime: '',
     IP: '73.229.234.2',
     Promotions: { Redeemable: [], Valid: [] },
     Status: -1,
     StatusItems: [ [Object], [Object], [Object] ],
     PlaceOrderTime: '2015-09-27 19:53:59' },
  Offer: { CouponList: [], ProductOffer: '' },
  Status: -1,
  StatusItems: [ { Code: 'Failure' } ] }
[ { Code: '9193',
    Qty: 1,
    ID: 1,
    isNew: true,
    Status: 0,
    StatusItems: [ [Object] ] } ]
[ { Code: '12SCREEN',
    Qty: 1,
    ID: 1,
    isNew: true,
    Options: { S: [Object], P: [Object] },
    Status: 0,
    CategoryCode: 'Pizza',
    FlavorCode: 'HANDTOSS',
    SizeCode: '12',
    SpecialtyCode: 'PIZZA' },
  { Code: 'B8PCSCB',
    Qty: 1,
    ID: 2,
    isNew: true,
    StatusItems: [ [Object] ],
    Status: 1,
    CategoryCode: 'Bread',
    FlavorCode: 'SCBRD',
    SizeCode: 'BRD8',
    SpecialtyCode: 'BRDSCB' } ]
[ { Code: 'AutoAddedOrderId' },
  { Code: 'PriceInformationRemoved' },
  { Code: 'RuleExecutionError',
    Message: 'BusinessRule ConditionalExecutionBusinessRule failed. Cause: java.lang.Long cannot be cast to java.lang.String' } ]
Order placed!
julianh2o commented 8 years ago

Try quoting the storeId. That would also cause that error, possibly.

mynamebrody commented 8 years ago

You're right it was the storeID not in quotes, I quoted my zipcode as well to be sure.

Dash Button Found
Order is Validated

Order is Priced

Price is { Menu: 20.75,
  Discount: 0,
  Surcharge: 1.99,
  Adjustment: 6.78,
  Net: 13.97,
  Tax: 1.19,
  Tax1: 1.19,
  Tax2: 0,
  Bottle: 0,
  Customer: 15.16,
  Payment: 15.16 }
Estimated Wait Time 20-30 minutes
Order placed!

Have it working with coupons, pizza is on it’s way, first successful order!

madelinecameron commented 8 years ago

Awesome to hear, what was the issue so that there is a record of it.

mynamebrody commented 8 years ago

the numbers were not in quotes, like you guys' said the zipcode and storeID, I was following your examples in the README so I didn't quote them.

RIAEvangelist commented 8 years ago

Sounds like we should do some validation and force the values to strings. before sending. maybe walk the whole tree.

Also, @madelinecameron for the Pizzas (and all other orders), we should use the supplied options from the menu. This way the order goes as intended for the order code.

Example PM_14SCREEN has a reference code of 14SCREEN and defaults to cheese mush and pep in the options. These are supplied by dominos

inorder to order a PM_14SCREEN you must use the code 14SCREEN as refrenced and pass the supplied options. It was a PAIN to figure that out, but it should be a better implementation now that we know they supply the right options for all items ;)

so we should be creating items from menu items @julianh2o this is along the lines you're working on right?

madelinecameron commented 8 years ago

Sorry for the delay. Are you meaning if someone references a premade / premium / whatever pizza, the options should be looked up and the options preset?

That is a pretty good idea.

RIAEvangelist commented 8 years ago

For any item, the default options are populated in the menu I believe. So we should use them. Basically everything we need for a default item is populated.