Skip to content

Instantly share code, notes, and snippets.

@mazikwyry
Last active December 16, 2015 02:29
Show Gist options
  • Save mazikwyry/5363274 to your computer and use it in GitHub Desktop.
Save mazikwyry/5363274 to your computer and use it in GitHub Desktop.
Old reqest and new one
NoMethodError (undefined method `[]' for nil:NilClass):
app/controllers/payments/google_checkout_controller.rb:36:in `notifications'
36: payment = GoogleCheckout.find_by_authorization(notification.shopping_cart.private_data["token"])
# We send command with shopping_cart.private_data = {token: token}
# And never have problems with getting private_data["token"] from new_order_notification
# There is no private_data["token"] in new reqest that we receive since april and here is the problem
{
"new_order_notification":{
"xmlns":"http://checkout.google.com/schema/2",
"serial_number":"714376209226986-00001-7",
"buyer_billing_address":{
"address1":"28 woodland avenue",
"contact_name":"J PRESTON-POWERS",
"company_name":null,
"address2":null,
"phone":"07779000900",
"fax":null,
"structured_name":{
"last_name":"PRESTON-POWERS",
"first_name":"J"
},
"email":"jp@carkoon.com",
"country_code":"GB",
"city":"hove",
"postal_code":"BN3 6BL",
"region":"E. SUSSEX"
},
"google_order_number":"714376209226986",
"order_summary":{
"google_order_number":"714376209226986",
"purchase_date":"2013-04-04T19:02:38.000Z",
"archived":"false",
"total_charge_amount":"0.0",
"total_refund_amount":"0.0",
"total_chargeback_amount":"0.0",
"buyer_shipping_address":{
"address1":"28 woodland avenue",
"contact_name":"M PRESTON-POWERS",
"company_name":null,
"address2":null,
"phone":"07999 970005",
"fax":null,
"structured_name":{
"last_name":"PRESTON-POWERS",
"first_name":"M"
},
"email":"jp@carkoon.com",
"country_code":"GB",
"city":"hove",
"postal_code":"BN3 6BL",
"region":"E. SUSSEX"
},
"promotions":null,
"order_total":"836.4",
"fulfillment_order_state":"NEW",
"financial_order_state":"REVIEWING",
"buyer_marketing_preferences":{
"email_allowed":"true"
},
"buyer_id":"221613849050716",
"order_adjustment":{
"merchant_codes":null,
"total_tax":"0.0",
"adjustment_total":"0.0"
},
"shopping_cart":{
#here should be our token
"items":{
"item":{
"item_description":"BF Platinum",
"merchant_item_id":null,
"unit_price":"836.4",
"quantity":"1",
"item_name":"Payment request from Bnktothefuture.com Ltd."
}
}
}
},
"timestamp":"2013-04-04T19:02:38.091Z",
"buyer_shipping_address":{
"address1":"28 woodland avenue",
"contact_name":"M PRESTON-POWERS",
"company_name":null,
"address2":null,
"phone":"07999 970005",
"fax":null,
"structured_name":{
"last_name":"PRESTON-POWERS",
"first_name":"M"
},
"email":"jp@carkoon.com",
"country_code":"GB",
"city":"hove",
"postal_code":"BN3 6BL",
"region":"E. SUSSEX"
},
"promotions":null,
"order_total":"836.4",
"fulfillment_order_state":"NEW",
"financial_order_state":"REVIEWING",
"buyer_marketing_preferences":{
"email_allowed":"true"
},
"buyer_id":"221613849050716",
"order_adjustment":{
"merchant_codes":null,
"total_tax":"0.0",
"adjustment_total":"0.0"
},
"shopping_cart":{
"items":{
"item":{
"item_description":"BF Platinum",
"merchant_item_id":null,
"unit_price":"836.4",
"quantity":"1",
"item_name":"Payment request from Bnktothefuture.com Ltd."
}
}
}
}
}
{
"new_order_notification":{
"xmlns":"http://checkout.google.com/schema/2",
"serial_number":"141648668772423-00001-7",
"buyer_billing_address":{
"phone":"07968385512",
"fax":null,
"structured_name":{
"last_name":"Brown",
"first_name":"C W"
},
"email":"craigyb81@gmail.com",
"contact_name":"C W Brown",
"company_name":null,
"address1":"Top Flat, 21 Meads Rd,",
"address2":"Wood Green",
"postal_code":"N22 6RN",
"country_code":"GB",
"city":"London",
"region":null
},
"google_order_number":"141648668772423",
"order_summary":{
"google_order_number":"141648668772423",
"purchase_date":"2013-03-14T00:46:57.000Z",
"total_charge_amount":"0.0",
"archived":"false",
"total_refund_amount":"0.0",
"total_chargeback_amount":"0.0",
"buyer_marketing_preferences":{
"email_allowed":"true"
},
"fulfillment_order_state":"NEW",
"financial_order_state":"REVIEWING",
"promotions":null,
"order_total":"4.8",
"buyer_shipping_address":{
"phone":"0116 223 1042",
"fax":null,
"structured_name":{
"last_name":"Brown",
"first_name":"Craig"
},
"email":"craigyb81@gmail.com",
"contact_name":"Craig Brown",
"company_name":null,
"address1":"Space Research Centre",
"address2":"University of Leicester",
"postal_code":"LE1 7RH",
"country_code":"GB",
"city":"Leicester",
"region":"LEICESTERSHIRE"
},
"buyer_id":"360419553489437",
"order_adjustment":{
"merchant_codes":null,
"total_tax":"0.0",
"adjustment_total":"0.0"
},
"shopping_cart":{
"merchant_private_data":{
"token":"b6711652-6ca6-471d-a0e6-5e85e92dfc31"
},
"items":{
"item":{
"item_description":null,
"unit_price":"4.8",
"quantity":"1",
"item_name":" Membership upgrade"
}
}
}
},
"timestamp":"2013-03-14T00:46:57.730Z",
"buyer_marketing_preferences":{
"email_allowed":"true"
},
"fulfillment_order_state":"NEW",
"financial_order_state":"REVIEWING",
"promotions":null,
"order_total":"4.8",
"buyer_shipping_address":{
"phone":"0116 223 1042",
"fax":null,
"structured_name":{
"last_name":"Brown",
"first_name":"Craig"
},
"email":"craigyb81@gmail.com",
"contact_name":"Craig Brown",
"company_name":null,
"address1":"Space Research Centre",
"address2":"University of Leicester",
"postal_code":"LE1 7RH",
"country_code":"GB",
"city":"Leicester",
"region":"LEICESTERSHIRE"
},
"buyer_id":"360419553489437",
"order_adjustment":{
"merchant_codes":null,
"total_tax":"0.0",
"adjustment_total":"0.0"
},
"shopping_cart":{
"merchant_private_data":{
"token":"b6711652-6ca6-471d-a0e6-5e85e92dfc31" #our token
},
"items":{
"item":{
"item_description":null,
"unit_price":"4.8",
"quantity":"1",
"item_name":" Membership upgrade"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment