Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
purchase_order = {
'type': 'purchase_order' ,
'secure_hash': 'b31c890a5e57c07666bd0ba0f104634f4edb0fed46cf66a2d67396a398898af3',
'pr_data': {
"merchant_id": "9a8e58eae43d01fd162d3c879f264d4d",
"currency": "USD",
"amount_cents": 2714,
"shipping_cents": 123,
"tax_cents": 123,
"finalize_on_create": true,
"invoice_on_create": false,
"order_items": [{
"title": "Stack of Paper",
"price_ea_cents": 1234,
"price_total_cents": 2468,
"quantity": 2
}],
"shopper_id": "fc6b34af2331d7f8d14c61e89facda94",
"payment_term": {
"corporate_account_id": "f6e711a148fe1b578eca5de7276c4e3d"
}
}
}
postMessage(JSON.stringify(purchase_order), 'http://localhost:3000')
launched_message = { type: 'launched', destination: 'checkout' }
postMessage(JSON.stringify(launched_message), 'http://localhost:3000')
# After you created the purchase order object above to match your local db, copy that and paste it into the rails console.
purchase_order = {
'type': 'purchase_order' ,
'secure_hash': 'b31c890a5e57c07666bd0ba0f104634f4edb0fed46cf66a2d67396a398898af3',
'pr_data': {
"merchant_id": "9a8e58eae43d01fd162d3c879f264d4d",
"currency": "USD",
"amount_cents": 2714,
"shipping_cents": 123,
"tax_cents": 123,
"finalize_on_create": true,
"invoice_on_create": false,
"order_items": [{
"title": "Stack of Paper",
"price_ea_cents": 1234,
"price_total_cents": 2468,
"quantity": 2
}],
"shopper_id": "fc6b34af2331d7f8d14c61e89facda94",
"payment_term": {
"corporate_account_id": "f6e711a148fe1b578eca5de7276c4e3d"
}
}
}
# then copy and paste the following:
order_hash = JSON.parse(purchase_order.to_json)['pr_data']
hash_string = Checkout::V4PurchaseOrderHashSupplier.create_input_string order_hash
hash = Checkout::V4PurchaseOrderHashSupplier.create_hash Merchant.first.active_api_keys.first.cleartext_key, hash_string
hash
@thomascrumrine

This comment has been minimized.

Copy link
Owner Author

@thomascrumrine thomascrumrine commented May 16, 2018

Steps:

  • start the server locally
  • go to localhost:3000/checkout
  • replace merchant_id with one that matches your local DB. In rails console: Merchant.first.uuid
  • copy and paste the above nonsense with the changed merchant id.

Note: If you actually want to complete the checkout process (not necessary to just view) you will need to change more of those uuids (in addition to the merchant id above) to ones that match your local DB. Here is how to get them form the Rails console (just copy and paste):

  • corporate_account_id: Merchant.first.corporate_accounts.active_accounts.first.uuid
  • shopper_id: Merchant.first.corporate_accounts.active_accounts.first.team_members.first.user.uuid
    Then follow the steps in secure_hash.rb above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.