public void When_I_lookup_an_auth_using_an_auth_id_Then_it_should_return_a_valid_auth_sync() { _auth = _cardService.Authorize(_auth); var returnedAuth = _cardService.Get(new Authorization(_auth.Id())); Assert.That(returnedAuth.Status(), Is.EqualTo("COMPLETED")); Assert.That(AuthorizationsAreEquivalent(_auth, returnedAuth), Is.True); }
public void When_I_void_an_auth_with_an_amount_too_large_Then_it_should_return_throw_RequestDeclinedException_async() { _auth = _cardService.Authorize(_auth); AuthorizationReversal authReversal = AuthorizationReversal.Builder() .MerchantRefNum(_auth.MerchantRefNum()) .Amount(1000000) //Amount voided > authorized amount .AuthorizationId(_auth.Id()) .Build(); Assert.ThrowsAsync <Paysafe.Common.RequestDeclinedException>(async() => await _cardService.ReverseAuthAsync(authReversal)); }
private Request GetInternal(Authorization auth) { auth.SetRequiredFields(new List <string> { GlobalConstants.Id }); auth.CheckRequiredFields(); return(new Request( method: RequestType.Get, uri: PrepareUri("/auths/" + auth.Id()) )); }
public async Task When_I_settle_an_auth_Then_it_should_return_a_valid_response_async() { _auth = await _cardService.AuthorizeAsync(_auth); Settlement settle = Settlement.Builder() .MerchantRefNum(_auth.MerchantRefNum()) .AuthorizationId(_auth.Id()) .Build(); Settlement response = await _cardService.SettlementAsync(settle); Assert.That(response.Status(), Is.EqualTo("PENDING")); }
public async Task When_I_partially_void_an_auth_Then_it_should_return_a_valid_response_async() { _auth = _cardService.Authorize(_auth); AuthorizationReversal authReversal = AuthorizationReversal.Builder() .MerchantRefNum(_auth.MerchantRefNum()) .Amount(111) //Amount voided < authorized amount .AuthorizationId(_auth.Id()) .Build(); AuthorizationReversal response = await _cardService.ReverseAuthAsync(authReversal); Assert.That(response.Status(), Is.EqualTo("COMPLETED")); }
public void When_I_void_an_auth_Then_it_should_return_a_valid_response_sync() { _auth = _cardService.Authorize(_auth); AuthorizationReversal authReversal = AuthorizationReversal.Builder() .MerchantRefNum(_auth.MerchantRefNum()) .Amount(6666) // Amount voided == authorized amount .AuthorizationId(_auth.Id()) .Build(); AuthorizationReversal response = _cardService.ReverseAuth(authReversal); Assert.That(response.Status(), Is.EqualTo("COMPLETED")); }
public void When_I_cancel_a_settlement_Then_it_should_return_a_valid_response_sync() { _auth = _cardService.Authorize(_auth); Settlement settle = Settlement.Builder() .MerchantRefNum(_auth.MerchantRefNum()) .AuthorizationId(_auth.Id()) .Build(); settle = _cardService.Settlement(settle); Settlement response = _cardService.CancelSettlement(settle); Assert.That(response.Status(), Is.EqualTo("CANCELLED")); }
public async Task When_I_lookup_a_settlement_using_a_settlement_id_Then_it_should_return_a_valid_settlement_async() { _auth = await _cardService.AuthorizeAsync(_auth); Settlement settle = Settlement.Builder() .MerchantRefNum(_auth.MerchantRefNum()) .AuthorizationId(_auth.Id()) .Build(); settle = await _cardService.SettlementAsync(settle); var returnedSettle = await _cardService.GetAsync(new Settlement(settle.Id())); Assert.That(SettlementsAreEquivalent(settle, returnedSettle)); }
/* * Helpers */ private bool AuthorizationsAreEquivalent(Authorization auth1, Authorization auth2) { if (!auth1.Id().Equals(auth2.Id()) || !auth1.Card().LastDigits().Equals(auth2.Card().LastDigits()) || !auth1.TxnTime().Equals(auth2.TxnTime()) || !auth1.AuthCode().Equals(auth2.AuthCode()) || !auth1.Amount().Equals(auth2.Amount()) || !auth1.CurrencyCode().Equals(auth2.CurrencyCode()) || !auth1.Status().Equals(auth2.Status())) { return(false); } return(true); }
/// <summary> /// Get the authorization /// </summary> /// <param name="auth">Authorization</param> /// <returns>Authorization</returns> public Authorization Get(Authorization auth) { auth.SetRequiredFields(new List <string> { GlobalConstants.Id }); auth.CheckRequiredFields(); Request request = new Request( method: RequestType.Get, uri: PrepareUri("/auths/" + auth.Id()) ); dynamic response = _client.ProcessRequest(request); return(new Authorization(response)); }
public async Task When_I_refund_a_pending_settlement_Then_it_should_throw_RequestDeclinedException_async() { _auth = await _cardService.AuthorizeAsync(_auth); Settlement settle = Settlement.Builder() .MerchantRefNum(_auth.MerchantRefNum()) .AuthorizationId(_auth.Id()) .Build(); settle = await _cardService.SettlementAsync(settle); Assert.ThrowsAsync <Paysafe.Common.RequestDeclinedException>(async() => await _cardService.RefundAsync(Refund.Builder() .MerchantRefNum(settle.MerchantRefNum()) .SettlementId(settle.Id()) .Build())); }
public void When_I_refund_a_pending_settlement_Then_it_should_throw_RequestDeclinedException_sync() { _auth = _cardService.Authorize(_auth); Settlement settle = Settlement.Builder() .MerchantRefNum(_auth.MerchantRefNum()) .AuthorizationId(_auth.Id()) .Build(); settle = _cardService.Settlement(settle); Assert.Throws <Paysafe.Common.RequestDeclinedException>(() => _cardService.Refund(Refund.Builder() .MerchantRefNum(settle.MerchantRefNum()) .SettlementId(settle.Id()) .Build())); }
public void When_I_lookup_a_reversal_using_a_reversal_id_Then_it_should_return_a_valid_reversal_sync() { _auth = _cardService.Authorize(_auth); AuthorizationReversal authReversal = AuthorizationReversal.Builder() .MerchantRefNum(_auth.MerchantRefNum()) .Amount(6666) .AuthorizationId(_auth.Id()) .Build(); authReversal = _cardService.ReverseAuth(authReversal); AuthorizationReversal returnedReversal = _cardService.Get(new AuthorizationReversal(authReversal.Id())); Assert.That(returnedReversal.Status(), Is.EqualTo("COMPLETED")); Assert.That(AuthorizationReversalsAreEquivalent(authReversal, returnedReversal)); }
private Request ApproveHeldAuthInternal(Authorization auth) { auth.SetRequiredFields(new List <string> { GlobalConstants.Id }); auth.CheckRequiredFields(); Authorization tmpAuth = new Authorization(); tmpAuth.Status("COMPLETED"); return(new Request( method: RequestType.Put, uri: PrepareUri("/auths/" + auth.Id()), body: tmpAuth )); }
public async Task When_I_lookup_a_settlement_using_a_merchant_refNum_Then_it_should_return_a_valid_settlement_async() { _auth = await _cardService.AuthorizeAsync(_auth); Settlement settle = Settlement.Builder() .MerchantRefNum(_auth.MerchantRefNum()) .AuthorizationId(_auth.Id()) .Build(); settle = await _cardService.SettlementAsync(settle); Pagerator <Settlement> settlements = await _cardService.GetSettlementsAsync(Settlement.Builder() .MerchantRefNum(settle.MerchantRefNum()) .Build()); var settleList = settlements.GetResults(); Assert.That(settleList.Count, Is.EqualTo(1)); Assert.That(SettlementsAreEquivalent(settle, settleList.First())); }
/// <summary> /// Cancel the Authorization /// </summary> /// <param name="auth">Authorization</param> /// <returns>Authorization</returns> public Authorization CancelHeldAuth(Authorization auth) { auth.SetRequiredFields(new List <string> { GlobalConstants.Id }); auth.CheckRequiredFields(); Authorization tmpAuth = new Authorization(); tmpAuth.Status("CANCELLED"); Request request = new Request( method: RequestType.Put, uri: PrepareUri("/auths/" + auth.Id()), body: tmpAuth ); dynamic response = _client.ProcessRequest(request); return(new Authorization(response)); }
public async Task When_I_lookup_a_reversal_using_a_merchant_refNum_Then_it_should_return_a_valid_reversal_async() { _auth = await _cardService.AuthorizeAsync(_auth); AuthorizationReversal authReversal = AuthorizationReversal.Builder() .MerchantRefNum(_auth.MerchantRefNum()) .Amount(6666) .AuthorizationId(_auth.Id()) .Build(); authReversal = await _cardService.ReverseAuthAsync(authReversal); Pagerator <AuthorizationReversal> authReversals = await _cardService.GetAuthReversalsAsync(AuthorizationReversal.Builder() .MerchantRefNum(authReversal.MerchantRefNum()) .Build()); var authRevList = authReversals.GetResults(); Assert.That(authRevList.Count, Is.EqualTo(1)); Assert.That(AuthorizationReversalsAreEquivalent(authReversal, authRevList[0])); }