December 2, 2008, Tuesday, 336

BTPWS-PeerBuy

From DBWiki

Jump to: navigation, search

Contents

Performing a PeerBuy Purchase

Listing Available Sellers

When the person that is using your application has decided that they want to purchase a particular piece of digital content, you can list the sellers that are available for that particular piece of content, generate a valid Bitmunk contract and hand it over to any Bitmunk-compliant software. You can even put yourself in as a payee for the contract for providing the service to the person that is using your application.

http://www.sandbox.bitmunk.com:9080/api/xml/catalog/getsellerlist

Your GET request should contain the following URL-encoded parameters:

  • apiKey - The API key that was given to you.
  • mediaId - This should be the media ID that needs to be purchased.

The formatted GET request should look like this:

GET /api/xml/catalog/getsellerlist?apiKey=416a&mediaId=6491443 HTTP/1.1
Host: www.sandbox.bitmunk.com:9080
User-Agent: MySoftware/1.2

The following XML will be returned to you:

<?xml version="1.0" encoding="UTF-8"?>
<xml_response version="1.0">
 <seller_list version="2.0">
  <media_id>6491443</media_id>
  <seller version="2.0" id="220" username="bitmunk-sales">
   <server>Bitmunk Internal Sales Server</server>
   <uri>https://sales.sandbox.bitmunk.com:9120/bss/</uri>
   <rating>3.0,2.0</rating>
   <ware_ids>6491443</ware_ids>
  </seller>
  <seller version="2.0" id="32074" username="fakeuser">
   <server>Fake Sales Server</server>
   <uri>https://123.123.123.123:9120/bss/</uri>
   <rating>3.0,2.0</rating>
   <ware_ids>0c5914ab2ff3ceab0ea15e9c7591f717</ware_ids>
  </seller>
 </seller_list>
</xml_response>

Creating a PeerBuy Purchase Contract

Once the person that is using your application has decided which seller they want to perform the purchase through, you can generate a Bitmunk contract for them and hand it off to any Bitmunk-compliant software.

http://www.sandbox.bitmunk.com:9080/api/peerbuy

Your GET request should contain the following URL-encoded parameters:

  • apiKey - The API key that was given to you.
  • sskey - The Sales Server ID string. This is the combination of the seller ID, a dash, and the seller's server name.
  • wareId - The ware ID of the item that should be purchased.
  • payee - If you would like to add any payees to the contract, you must specify them here and they should be formatted like so:
    bitmunk_account_id:amount_in_usd:reason

The formatted GET request should look like this:

GET /api/xml/peerbuy?apiKey=416a&sskey=220-Bitmunk+Internal+Sales+Server&wareId=6491443&payee=37485:0.01:MySoftware+Royalty HTTP/1.1
Host: www.sandbox.bitmunk.com:9080
User-Agent: MySoftware/1.2

The following XML will be returned to you:

<?xml version="1.0" encoding="UTF-8"?>
<xml_response version="1.0">
 <contract version="2.0" id="0">
  <status state="none" error="none" message="ok"/>
  <buyer version="2.0" id="0" username="">
   <ip>0.0.0.0</ip>
  </buyer>
  <seller version="2.0" id="220" username="">
   <server>Bitmunk Internal Sales Server</server>
   <uri>https://sales.sandbox.bitmunk.com:9120/bss/</uri>
   <rating>0.0,0.0</rating>
  </seller>
  <manifest version="2.0">
   <ware version="2.0" id="6491443">
    <digital_work version="2.0">
     <media_info version="2.0" id="6491443" type="audio_song">
      <owner_id>32073</owner_id>
      <sellable>1</sellable>
      <status>claimed</status>
      <creator>Bitmunk Squad</creator>
      <title>Bitmunk Squad Theme Song</title>
      <sample_range>10:40</sample_range>
      <parent_media_ids/>
      <child_media_ids/>
      <details>
       <release_date>2007-01-12</release_date>
       <category>audio</category>
       <distribution_formats>mp3-bmwm</distribution_formats>
       <banned_countries/>
       <isrc/>
       <creator_description_id>0</creator_description_id>
       <artist>Bitmunk Squad</artist>
       <track>1</track>
       <length>0</length>
       <genre/>
       <publisher>Bitmunk Industrial Recording
1 Bitmunk Offices
Blacksburg VA, 24060</publisher>
       <publisher_description_id>0</publisher_description_id>
       <composer/>
       <composer_description_id>0</composer_description_id>
       <content_rating>not_rated</content_rating>
       <audio_albums/>
       <mixed_albums/>
       <cover_song>0</cover_song>
       <licenses>sc,sc-p2p,sc-wb</licenses>
       <picture_id>0</picture_id>
       <short_description>This song is a test song for purchase.</short_description>
       <long_description>This song is a test song for purchase on our sandbox open source    server.</long_description>
      </details>
      <royalties>
       <payee version="2.0" id="41067">
        <amount version="2.0" currency="usd">0.496</amount>
        <source>sva</source>
        <reason>Bitmunk Squad Artist Royalty</reason>
        <media_id>6491443</media_id>
       </payee>
       <payee version="2.0" id="1032">
        <amount version="2.0" currency="usd">0.0535</amount>
        <source>sva</source>
        <reason>Bitmunk Records Digital Distribution Fee</reason>
        <media_id>6491443</media_id>
       </payee>
      </royalties>
     </media_info>
     <file_info version="2.0" id="FID6491443mp3">
      <name/>
      <type>audio_song</type>
      <format>mp3</format>
      <size>6463502</size>
      <bitrate>0</bitrate>
      <uri/>
      <transferred/>
      <dkey algorithm=""/>
     </file_info>
    </digital_work>
    <payee version="2.0" id="10105">
     <amount version="2.0" currency="USD">0.5965000</amount>
     <source>sva</source>
     <reason>Bitmunk Squad Royalty</reason>
     <media_id>6491443</media_id>
    </payee>
    <payee version="2.0" id="10104">
     <amount version="2.0" currency="USD">0.0535000</amount>
     <source>CD Baby</source>
     <reason>Bitmunk Records Royalty</reason>
     <media_id>6491443</media_id>
    </payee>
    <payee version="2.0" id="2">
     <amount version="2.0" currency="USD">0.1247323</amount>
     <source>Bitmunk Internal Sales Server</source>
     <reason>Sale Price</reason>
     <media_id>6491443</media_id>
    </payee>
    <payee version="2.0" id="37485">
     <amount version="2.0" currency="USD">0.0100000</amount>
     <source>xml-api</source>
     <reason>MySoftware Royalty</reason>
     <media_id>0</media_id>
    </payee>
    <payee version="2.0" id="1">
     <amount version="2.0" currency="USD">0.1500000</amount>
     <source>SVA</source>
     <reason>Bitmunk transaction fee: 0.15 cents</reason>
     <media_id>0</media_id>
    </payee>
   </ware>
  </manifest>
 </contract>
</xml_response>

Loading the Purchase Contract

Once you have retrieved the contract as described on this page, you can save it to a file and invoke the Bitmunk Personal Edition software to load and process the contract. In Linux, you can do this by executing the following command:

bitmunk-personal-edition contractfile.bmc

in Windows, you can call the handler for the "BMC" file extension - which should start the Bitmunk Personal Edition software.