Author

Topic: Could someone explain how to implement bitcoinpayflow.com (Read 1213 times)

hero member
Activity: 603
Merit: 500
I need a basic step by step really, I have no idea where to put the code  Undecided There will be a small reward for the best answer.

http://www.bitcoinpayflow.com/dashboard

Creating Orders

POST /orders

Request

{
    "foreign_order_id" : "1234",
    "total_amount" : "23.223",
    "custom_field" : "foobar",
    "auth_token" : auth_token
}


Response

{
  "order" : { "bitcoin_address" : "1F2vgWSRcfRzZz1LetFxrk6qfWhpTeW32s"}
}

view raw gistfile1.txt This Gist brought to you by GitHub.
Handling Payment Notifications

We send payment notifications to the URL you specify. It is important for you to verify the post is from us.

1) Create a string with parameter pairs under "Payment Notification" in alphabetical order, it should look like this: param1=v1params2=v2.... Do not include the signature.

2) Add your access token in front of the string

3) Perform a SHA2 hash function

Post http://yourwebsite.com/payment_notification

Parameters
{
  "Payment Notification" :
  {
    "foreign_order_id" : "A1234",
    "amount" : "2.20",
    "transaction_fee" : 0.0,
    "bitcoin_address" : "1AFZ6Cv8q96rFaS9T8fR1y2j2CjNDcTIVD",
    "number_of_confirmations" : 1,
    "transaction_timestamp" : 1307671121,
    "category" : "receive"/"send",
    "order_status" : "satisfied"/"open",
    "signature" : "unique signature for this request"
   }
}

You can send yourself a test payment notification using this link:
http://www.bitcoinpayflow.com/test_pn

view raw gistfile1.txt This Gist brought to you by GitHub.
Creating Additional Access Tokens

We provide you with your primary access token upon signup. Additional access tokens can be created to provide order and payment notifications for individual customers. For example, if you are building a Bitcoin marketplace, an access token can be created for each individual seller. We handle tracking of each order, and forward payments directly to the seller.

POST /tokens

Request

{
  "auth_token" : "Your primary access token"
  "token" : { "bitcoin_address" : "Bitcoin address associated with this token" }
}



Response

{
  "token" : { "hash_id" : "43a7441a186d22266a0456842bca1934" }
}
 

view raw gistfile1.txt This Gist brought to you by GitHub.
Implementation Examples

Ruby example for creating an order:

require "rubygems"
require "net/http"

@base_url = "https://www.bitcoinpayflow.com"
@access_token = "yourtoken"

# create an order:
uri = URI.parse("#{@base_url}/orders")
http = Net::HTTP.new(uri.host, uri.port)

request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data({"auth_token" => @access_token, "foreign_order_id" => "order123",
                       "total_amount" => 0.01, "custom_field" => "blah blah blah"})

response = http.request(request)
puts "Response: #{response.body}"

Jump to: