Beispiel #1
0
 string policyPostTicket(string type, string action, PaymentTicket ticket)
 {
     return(type + "\n" +
            action + "\n\n" +
            "clave-modulo:" + KEY + "\n" +
            "claveapp:" + KEY + "\n" +
            "host:" + AWS_S3_URL_BASE_VIRTUAL_HOSTED + "\n" +
            "x-amz-date:" + iso8601CurrentTime + "\n" +
            "x-api-key:" + AMAZON_INTERCERAMIC_API_KEY + "\n\n" +
            "clave-modulo;claveapp;host;x-amz-date;x-api-key\n" +
            ComputeSha256Hash(JsonUtility.ToJson(ticket)));
 }
Beispiel #2
0
    void SendAmazonS3Request(string type, string action, string content_type, PaymentTicket ticket)
    {
        transform.GetComponent <ViewsManager>().showPopUpNoAnim(2);
        transform.GetComponent <ViewsManager>().popUps[2].GetComponent <LoadingManager>().startSpinning();
        this.ticket = ticket;
        Debug.Log("Si entre");
        Hashtable headers = new Hashtable();

        dateString = System.DateTime.UtcNow.AddSeconds(120.0f).ToString("yyyyMMdd");

        System.DateTime currentTime = System.DateTime.UtcNow;
        iso8601CurrentTime = currentTime.ToString("s", System.Globalization.CultureInfo.InvariantCulture);
        iso8601CurrentTime = iso8601CurrentTime.Replace(" ", "").Replace("-", "").Replace(":", "");

        string policy = policyPostTicket(type, action, ticket);

        string signature = ComputeSha256Hash(policy);

        string authorization = "AWS4-HMAC-SHA256\n" +
                               iso8601CurrentTime + "Z" + "\n" +
                               dateString + "/" + AMAZON_REGION + "/" + AMAZON_SERVICE + "/aws4_request\n" +
                               signature;

        headers.Add("x-amz-date", iso8601CurrentTime);
        headers.Add("x-api-key", AMAZON_INTERCERAMIC_API_KEY);
        headers.Add("clave-modulo", KEY);
        headers.Add("claveapp", KEY);
        headers.Add("Prop_id", prop_id);
        headers.Add("Contacto_id", contact_id);
        headers.Add("Content-Type", content_type);
        signature_global = HexaFromByte(HmacSHA256(authorization, getSignatureKey(AWS_SECRET_ACCESS_KEY, dateString, AMAZON_REGION, AMAZON_SERVICE)));
        headers.Add("Authorization", " AWS4-HMAC-SHA256 Credential=" + AWS_ACCESS_KEY_ID + "/" + dateString + "/" + AMAZON_REGION + "/" + AMAZON_SERVICE + "/aws4_request" +
                    ", SignedHeaders=clave-modulo;claveapp;host;x-amz-date;x-api-key, Signature=" + HexaFromByte(HmacSHA256(authorization, getSignatureKey(AWS_SECRET_ACCESS_KEY, dateString, AMAZON_REGION, AMAZON_SERVICE))));

        // Setup the request url to be sent to Amazon
        WWW www = buildWWW(type, action, headers);

        // Send the request in this coroutine so as not to wait busily
        StartCoroutine(WaitForRequest(www));
    }
Beispiel #3
0
 public void sendPaymentResponse(String prop_id, PaymentTicket ticket)
 {
     this.prop_id = prop_id;
     Debug.Log("prop_id " + this.prop_id);
     SendAmazonS3Request("POST", "/" + ENVIRONMENT + "/enviarespuestapago", "application/json", ticket);
 }