Obtener subscripción
Obtiene información de una sola suscripción
curl --location --request POST 'https://api-test.payvalida.com/subscriptions/merchants/api/get/subscription' \
--header 'Content-Type: application/json' \
--data-raw '{
"merchant": "kuanto",
"subscription_id": "5c77976a-e6dc-4e58-b046-bc366740f4f7",
"request_id": "123",
"checksum": "57b901965399ada47ac38169759ee1c115166ec9b2aca725d5137204058b3f66b33b68ba84304752bf879d061b5568f650ed28ac4bd5272f9926fb2e763f8d17"
}'Ejemplos
package main
import (
"bytes"
"crypto/sha512"
"encoding/hex"
"fmt"
"io/ioutil"
"net/http"
"time"
)
func main() {
url := "https://api-test.payvalida.com/subscriptions/merchants/api/get/subscription"
merchant := "kuanto"
request_id := "month"
subscription_id := "5c77976a-e6dc-4e58-b046-bc366740f4f7"
fixedHash := "FIXED_HASH"
checksum := createChecksum(merchant, subscription_id, request_id, fixedHash)
payload := []byte(fmt.Sprintf(`{
"merchant": "%s",
"request_id": "%s",
"subscription_id": "%s",
"checksum":"%s",
}`, merchant, request_id, subscription_id, checksum))
req, err := http.NewRequest("POST", url, bytes.NewBuffer(payload))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
// Read response body
responseData, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return
}
// Print response data
fmt.Println("Response:", string(responseData))
}
func createChecksum(merchant, subscription_id, request_id, fixedHash string) string {
checksumData := merchant + subscription_id + request_id + fixedHash
hash := sha512.Sum512([]byte(checksumData))
checksum := hex.EncodeToString(hash[:])
return checksum
}
Last updated