API – Paycoin method

Enables your customers to buy your goods with a coin they have defined in their account. The payment is totally anonymous, as only a cointoken is exchanged.

URI (using GET)
https://{environment}.paycento.com/paycentoservice.svc/paycoin/?oauth_consumer_key={consumerkey}&articlehash={hashedtoken}&coindata={coindata}

Don’t forget to URLencode the parameters in the URL, otherwise the coindata part could fail.

URI (using POST)
https://{environment}.paycento.com/paycentoservice.svc/paycoin/?oauth_consumer_key={consumerkey}&articlehash={hashedtoken}
URI parameter Value
Method type GET or POST
Content type application/json
Parameter name Description
environment apiĀ  (production) or sandbox (development)
consumerkey consumerkey of your merchant application
hashedtoken hash that is a created by first concatenating following variables:

  • article id
  • article cost
  • article currency
  • article url
  • coin token
  • article type
  • usersession id

This concatenation must then be hashed by the wallet key of the merchant (where the coin money should end).

PHP example:
$hmac_data = $article_id . $article_cost . $currency. $article_url. $coin_token. $article_type. $session_id;
$hashedToken = base64_encode(hash_hmac(‘sha1′, $hmacData, $wallet_key, true));

coindata this parameter is only to be provided in the GET variant. The coindata is a concatenated xml-like string.

See the POST data explication, you just have to add all the xml members in one string.
PHP example:
$coindata = “<CoinData><ArticleId>”.$article_id.”</ArticleId><ArticleCost>”.$article_cost.”</ArticleCost><CurrencyCode>”.$currency.”</CurrencyCode><Articlecallbackurl>”.$article_url.”</Articlecallbackurl>”;
$coindata .= “<CodeToken>”.$coin_token.”</CodeToken><Articletype>”.$article_type.”</Articletype><UserSession>”.$session_id.”</UserSession><Description>”.$short_description.”</Description><Tags>”.$article_tags.”</Tags><Ipaddress>”.$_SERVER['REMOTE_ADDR'].”</Ipaddress></CoinData>”;

When calling the POST variant of the pay coin method, you must provide the data in the body of the object:

POST data
<CoinData>
<ArticleId>…</ArticleId>
<ArticleCost>…</ArticleCost>
<CurrencyCode>…</CurrencyCode>
<Articlecallbackurl>…</Articlecallbackurl>
<CodeToken>…</CodeToken>
<Articletype>…</Articletype>
<UserSession>…</UserSession>
<Description>…</Description>
<Articletags>…</Articletags>
<Ipaddress>…</Ipaddress>
</CoinData>

returns a string that is the concatenation of the original provided parameters, and a hashed string including the transaction id of the payment.

Response string
on success, format is:

    • OK
    • |
    • amount=(price article * 100)
    • ccy=(currency article)
    • articleid=(id of article)
    • articlesession=(session of user)
    • cointoken=(token of used coin)
    • tx=(transaction id)
    • shasign=(calculated HMAC hash)

The calculated HMAC hash contains:

        • Article id
        • Article cost (actual article price * 100)
        • Currency code
        • Coin token
        • User session id
        • transaction id

The concatenation of those values is hashed by the wallet key of the merchants wallet.

on error, format is:

  • NOK
  • |
  • error message description

Leave a Reply