public string Generate() { var request = new PagarMeRequest(_service, "GET", "/transactions/card_hash_key"); request.UseEncryptionKey = true; var response = request.Execute(); var key = JsonHelper.Deserialize <CardHashKey>(_service, response.Body); return(Encrypt(key)); }
public string Generate() { var request = new PagarMeRequest(_service, "GET", "/transactions/card_hash_key"); request.UseEncryptionKey = true; var response = request.Execute(); var key = JsonHelper.Deserialize<CardHashKey>(_service, response.Body); return Encrypt(key); }
private string Encrypt(CardHashKey key) { var args = new List <Tuple <string, string> >(); args.Add(new Tuple <string, string>("card_number", CardNumber)); args.Add(new Tuple <string, string>("card_expiration_date", CardExpirationDate)); args.Add(new Tuple <string, string>("card_holder_name", CardHolderName)); args.Add(new Tuple <string, string>("card_cvv", CardCvv)); var encrypted = EncryptRsa(key.PublicKey, Encoding.UTF8.GetBytes(PagarMeRequest.BuildQueryString(args))); return(key.Id + "_" + Convert.ToBase64String(encrypted)); }
public async Task <string> GenerateAsync() { var request = new PagarMeRequest(_service, "GET", "/transactions/card_hash_key") { UseEncryptionKey = true }; var response = await request.ExecuteAsync(); var key = JsonHelper.Deserialize <CardHashKey>(_service, response.Body); return(Encrypt(key)); }