Yukarıda verilmiş olan adrese istek atmanız yeterli olacaktır. Test ortamı ve Gerçek ortam için 'Base Address' istediğiniz gibi kullanabilirsiniz.
Servise gönderilmesi gereken parametreler şu şekildedir:
JSON C# GO Java PHP Python Ruby TypeScript Curl
Copy {
"MerchantUniqueCode" : "aaa"
}
Copy using System ;
using System . Net . Http ;
using System . Text ;
using System . Threading . Tasks ;
using Newtonsoft . Json ;
public class Program
{
private static readonly HttpClient client = new HttpClient ();
private static async Task Main ( string [] args)
{
var data = new
{
MerchantUniqueCode = "aaa"
};
client . DefaultRequestHeaders . Add ( "apikeypublic" , "%PUBLICKEY%" );
client . DefaultRequestHeaders . Add ( "apiclientpublic" , "%PUBLICCLIENT%" );
var content = new StringContent ( JsonConvert . SerializeObject (data) , Encoding . UTF8 , "application/json" );
var response = await client . PostAsync ( "{{Base Adres}}/api/paywall/payment/end3d" , content);
var responseString = await response . Content . ReadAsStringAsync ();
var responseObject = JsonConvert . DeserializeObject < Response >(responseString);
Console . WriteLine ( "ErrorCode: " + responseObject . ErrorCode );
Console . WriteLine ( "Result: " + responseObject . Result );
Console . WriteLine ( "Message: " + responseObject . Message );
}
public class Response
{
public int ErrorCode { get ; set ; }
public bool Result { get ; set ; }
public string Message { get ; set ; }
public string Body { get ; set ; }
}
}
Copy package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
type Response struct {
ErrorCode int
Result bool
Message string
Body string
}
type Request struct {
MerchantUniqueCode string `json:"MerchantUniqueCode"`
}
func main () {
url := "{{Base Adres}}/api/paywall/payment/end3d"
reqBody := & Request {
MerchantUniqueCode: "aaa" ,
}
reqBodyBytes := new ( bytes . Buffer )
json. NewEncoder (reqBodyBytes). Encode (reqBody)
req, _ := http. NewRequest ( "POST" , url, reqBodyBytes)
req.Header. Set ( "Content-Type" , "application/json" )
req.Header. Set ( "apikeypublic" , "%PUBLICKEY%" )
req.Header. Set ( "apiclientpublic" , "%PUBLICCLIENT%" )
client := & http . Client {}
resp, err := client. Do (req)
if err != nil {
panic (err)
}
defer resp.Body. Close ()
body, _ := ioutil. ReadAll (resp.Body)
var responseObj Response
json. Unmarshal (body, & responseObj)
fmt. Println ( "ErrorCode:" , responseObj.ErrorCode)
fmt. Println ( "Result:" , responseObj.Result)
fmt. Println ( "Message:" , responseObj.Message)
}
Copy import okhttp3 . * ;
import org . json . * ;
public class Main {
public static void main ( String [] args) {
OkHttpClient client = new OkHttpClient() ;
MediaType mediaType = MediaType . parse ( "application/json" );
JSONObject json = new JSONObject() ;
json . put ( "MerchantUniqueCode" , "aaa" );
RequestBody body = RequestBody . create (mediaType , json . toString ());
Request request = new Request . Builder ()
. url ( "{{Base Adres}}/api/paywall/payment/end3d" )
. post (body)
. addHeader ( "Content-Type" , "application/json" )
. addHeader ( "apikeypublic" , "%PUBLICKEY%" )
. addHeader ( "apiclientpublic" , "%PUBLICCLIENT%" )
. build ();
try {
Response response = client . newCall (request) . execute ();
String responseString = response . body () . string ();
// Parse the response
JSONObject jsonResponse = new JSONObject(responseString) ;
System . out . println ( "ErrorCode: " + jsonResponse . getInt ( "ErrorCode" ));
System . out . println ( "Result: " + jsonResponse . getBoolean ( "Result" ));
System . out . println ( "Message: " + jsonResponse . getString ( "Message" ));
} catch ( IOException e) {
e . printStackTrace ();
}
}
}
Copy <? php
$url = '{{Base Adres}}/api/paywall/payment/end3d' ;
$data = array (
"MerchantUniqueCode" => "aaa"
);
$options = array (
'http' => array (
'header' => "Content-type: application/json\r\n" .
"apikeypublic: %PUBLICKEY%\r\n" .
"apiclientpublic: %PUBLICCLIENT%\r\n" ,
'method' => 'POST' ,
'content' => json_encode ( $data ),
) ,
);
$context = stream_context_create ( $options ) ;
$result = file_get_contents ( $url , false , $context ) ;
if ($result === FALSE ) { /* Handle error */ }
// Decode
$response = json_decode ( $result ) ;
// ErrorCode-Result-Message
echo "ErrorCode: " . $response -> ErrorCode . "\n" ;
echo "Result: " . ($response -> Result ? "true" : "false" ) . "\n" ;
echo "Message: " . $response -> Message . "\n" ;
?>
Copy import requests
import json
url = ' {{ Base Adres }} /api/paywall/payment/end3d'
headers = {
'Content-Type' : 'application/json' ,
'apikeypublic' : '%PUBLICKEY%' ,
'apiclientpublic' : '%PUBLICCLIENT%'
}
data = {
"MerchantUniqueCode" : "aaa"
}
response = requests . post (url, headers = headers, data = json. dumps (data))
# Parsing the response
response_json = response . json ()
print ( 'ErrorCode:' , response_json[ 'ErrorCode' ])
print ( 'Result:' , response_json[ 'Result' ])
print ( 'Message:' , response_json[ 'Message' ])
Copy require 'net/http'
require 'uri'
require 'json'
uri = URI . parse( "{{Base Adres}}/api/paywall/payment/end3d" )
request = Net :: HTTP :: Post . new (uri)
request . content_type = "application/json"
request[ "Apikeypublic" ] = "%PUBLICKEY%"
request[ "Apiclientpublic" ] = "%PUBLICCLIENT%"
request . body = JSON . dump({
"MerchantUniqueCode" => "aaa"
})
req_options = {
use_ssl: uri . scheme == "https" ,
}
response = Net :: HTTP . start(uri . hostname , uri . port , req_options) do | http |
http . request(request)
end
response = JSON . parse(response . body)
puts "ErrorCode: #{response[ 'ErrorCode' ]} "
puts "Result: #{response[ 'Result' ]} "
puts "Message: #{response[ 'Message' ]} "
Copy import * as https from 'https' ;
const data = JSON .stringify ({
"MerchantUniqueCode" : "aaa"
});
const options = {
hostname : '{{Base Adres}}' ,
port : 443 ,
path : '/api/paywall/payment/end3d' ,
method : 'POST' ,
headers : {
'Content-Type' : 'application/json' ,
'apikeypublic' : '%PUBLICKEY%' ,
'apiclientpublic' : '%PUBLICCLIENT%'
}
};
const req = https .request (options , (res) => {
res .on ( 'data' , (d) => {
// Parse the response
const response = JSON .parse ( d .toString ());
console .log ( `ErrorCode: ${ response .ErrorCode } ` );
console .log ( `Result: ${ response .Result } ` );
console .log ( `Message: ${ response .Message } ` );
});
});
req .on ( 'error' , (error) => {
console .error (error);
});
req .write (data);
req .end ();
Copy curl --location --request POST '{{Base Adres}}/api/paywall/payment/end3d' \
--header 'Content-Type: application/json' \
--header 'apikeypublic: %PUBLICKEY%' \
--header 'apiclientpublic: %PUBLICCLIENT%' \
--data-raw '{
"MerchantUniqueCode": "aaa"
}'