ΧΡΗΣΤΟΣ ΠΑΠΑΓΙΑΝΝΗΣ

ΧΡΗΣΤΟΣ-ΠΑΠΑΓΙΑΝΝΗΣ



public class TransactionResult
{
public int ErrorCode { get; set; }
public string ErrorText { get; set; }
public decimal Amount { get; set; }
public Guid TransactionId { get; set; }
}

public async Task ChargeAsync(string merchantId,
string apiKey, string vivaWalletToken)
{
var cl = new RestClient("http://demo.vivapayments.com/api/") {
Authenticator = new HttpBasicAuthenticator(merchantId, apiKey)
};
var request = new RestRequest("transactions", Method.POST) {
RequestFormat = DataFormat.Json
};

request.AddParameter("PaymentToken", vivaWalletToken);

var response = await cl.ExecuteTaskAsync(request);

return response.ResponseStatus == ResponseStatus.Completed &&
response.StatusCode == System.Net.HttpStatusCode.OK ? response.Data : null;
}