From db4ee624c0b09277b90abcf9c5cf945fc6978d70 Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Tue, 13 Mar 2018 12:54:01 +0100 Subject: php order --- doc/merchant-api.content.texi | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'doc') 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) -- cgit v1.2.3