diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2018-03-13 12:54:01 +0100 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2018-03-13 12:54:01 +0100 |
commit | db4ee624c0b09277b90abcf9c5cf945fc6978d70 (patch) | |
tree | 67952729cc4574959365994c2ce488af25f4901c /doc | |
parent | 831f926898cb740f75d3f1351d0fe5b9e92ab989 (diff) |
php order
Diffstat (limited to 'doc')
-rw-r--r-- | doc/merchant-api.content.texi | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/doc/merchant-api.content.texi b/doc/merchant-api.content.texi index 6efe1c58..b491fa2d 100644 --- a/doc/merchant-api.content.texi +++ b/doc/merchant-api.content.texi @@ -104,6 +104,10 @@ It uses the requests library for HTTP requests. This version of the tutorial has examples for the command line with cURL. @end ifset +@ifset LANG_PHP +This version of the tutorial has examples for PHP, +using the pecl_http package. +@end ifset @c Versions for other languages/environments are available as well. @@ -191,6 +195,23 @@ curl -i 'https://backend.demo.taler.net/' \ @end verbatim @end example @end ifset +@ifset LANG_PHP +@set GOT_LANG 1 +@example +@verbatim +php > $c = curl_init("https://backend.demo.taler.net/"); +php > $options = array(CURLOPT_RETURNTRANSFER => true, +php ( CURLOPT_CUSTOMREQUEST => "GET", +php ( CURLOPT_HTTPHEADER => array("Authorization: ApiKey sandbox")); +php > curl_setopt_array ($c, $options); +php > $r = curl_exec ($c); +php > echo curl_getinfo ($c, CURLINFO_HTTP_CODE); +200 +php > echo $r; +Hello, I'm a merchant's Taler backend. This HTTP server is not for humans. +@end verbatim +@end example +@end ifset @ifclear GOT_LANG @example (example not available for this language) @@ -298,6 +319,30 @@ curl -i -X POST 'https://backend.demo.taler.net/order' \ @end verbatim @end example @end ifset +@ifset LANG_PHP +@set GOT_LANG 1 +@example +@verbatim +php > $c = curl_init("https://backend.demo.taler.net/order"); +php > $json = array("order"=> +php ( array("amount"=>"KUDOS:1", +php ( "fulfillent_url"=>"https://example.com/thanks.html", +php ( "summary"=>"nice product")); +php > $options = array(CURLOPT_RETURNTRANSFER=>true, +php ( CURLOPT_CUSTOMREQUEST=>"POST", +php ( CURLOPT_POSTFIELDS=>json_encode($json), +php ( CURLOPT_HTTPHEADER=>array("Authorization: ApiKey sandbox")); +php > curl_setopt_array($c, $options); +php > $r = curl_exec($c); +php > echo curl_getinfo($c, CURLINFO_HTTP_CODE); +200 +php > echo $r; +{ + "order_id": "2018.072.12.48.51-014DKDKBMHPDP" +} +@end verbatim +@end example +@end ifset @ifclear GOT_LANG @example (example not available for this language) |