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)); }
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_lookup_an_auth_using_a_merchant_refNum_Then_it_should_return_a_valid_auth_async() { _auth = _cardService.Authorize(_auth); Pagerator <Authorization> auths = await _cardService.GetAuthsAsync(Authorization.Builder() .MerchantRefNum(_auth.MerchantRefNum()) .Build()); var authList = auths.GetResults(); Assert.That(authList.Count, Is.EqualTo(1)); Assert.That(AuthorizationsAreEquivalent(authList.First(), _auth)); }
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 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)); }
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")); }
/* * 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); }
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)); }
public static Authorization CreateSampleIncompleteAuthorization() { return(Authorization.Builder() .MerchantRefNum(Guid.NewGuid().ToString()) .Amount(6666) .Card() .CardNum("4111111111111111") .Cvv("123") .CardExpiry() .Month(06) .Year(DateTime.Now.AddYears(1).Year) .Done() .Done() //.BillingDetails() // .Zip("M5H 2N2") // .Done() .Build()); }
public static Authorization CreateSampleCustomAuthorization(string type) { return(Authorization.Builder() .MerchantRefNum(Guid.NewGuid().ToString()) .Amount(ExceptionType[type]) .Card() .CardNum("4111111111111111") .Cvv("123") .CardExpiry() .Month(06) .Year(DateTime.Now.AddYears(1).Year) .Done() .Done() .BillingDetails() .Zip("M5H 2N2") .Done() .Build()); }
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())); }
public static Authorization CreateSampleComplexAuthorization() { return(Authorization.Builder() .MerchantRefNum(Guid.NewGuid().ToString()) .Amount(6666) .Card() .CardNum("4111111111111111") .Cvv("123") .CardExpiry() .Month(06) .Year(DateTime.Now.AddYears(1).Year) .Done() .Done() .Authentication() .Eci(5) .Cavv("AAABCIEjYgAAAAAAlCNiENiWiV+=") .Xid("OU9rcTRCY1VJTFlDWTFESXFtTHU=") .ThreeDEnrollment("Y") .ThreeDResult("Y") .SignatureStatus("Y") .Done() .BillingDetails() .Street("100 Queen Street West") .City("Toronto") .State("ON") .Country("CA") .Zip("M5H 2N2") .Done() .ShippingDetails() .Carrier("UPS") .ShipMethod("N") .Street("100 Queen Street West") .City("Toronto") .State("ON") .Country("CA") .Zip("M5H 2N2") .Done() .CustomerIp("204.91.0.12") .Description("I like turtles.") .Build()); }
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])); }
public void Init() { _cardService = SampleFactory.CreateSampleCardPaymentService(); _auth = SampleFactory.CreateSampleCustomAuthorization("noException"); }