Last active
May 25, 2021 15:19
-
-
Save tommycrumrine/ff8defc42ca7acb0647fb940f7fd934b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps:
localhost:3000/checkout
merchant_id
with one that matches your local DB. In rails console:Merchant.first.uuid
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):
Merchant.first.corporate_accounts.active_accounts.first.uuid
Merchant.first.corporate_accounts.active_accounts.first.team_members.first.user.uuid
Then follow the steps in
secure_hash.rb
above.