public void APMRefundPendingTransaction() { var PaymentMethod = new AlternativePaymentMethod { AlternativePaymentMethodType = AlternativePaymentType.TESTPAY, ReturnUrl = "https://www.example.com/returnUrl", StatusUpdateUrl = "https://www.example.com/statusUrl", Descriptor = "Test Transaction", Country = "DE", AccountHolderName = "James Mason" }; try { var response = PaymentMethod.Charge(10m) .WithCurrency("EUR") .WithDescription("New APM") .Execute(); Assert.IsNotNull(response); Assert.AreEqual("01", response.ResponseCode); var refund = response.Refund(10m) .WithCurrency("EUR") .WithAlternativePaymentType(AlternativePaymentType.TESTPAY) .Execute(); } catch (GatewayException ex) { Assert.AreEqual("FAILED", ex.ResponseMessage); } }
public void PayPalCharge_fullCycle() { var response = paymentMethod.Charge(1.34m) .WithCurrency(currency) .WithDescription("New APM") .Execute(); Assert.IsNotNull(response); Assert.AreEqual("SUCCESS", response.ResponseCode); Assert.AreEqual("INITIATED", response.ResponseMessage); Console.WriteLine("copy the link and open it in a browser, do the login wih your paypal credentials and authorize the payment in the paypal form. You will be redirected to a blank page with a printed message like this: { \"success\": true }. This has to be done within a 25 seconds timeframe."); Console.WriteLine(response.AlternativePaymentResponse.RedirectUrl); Thread.Sleep(25000); var startDate = DateTime.Now; var responseFind = ReportingService.FindTransactionsPaged(1, 1) .WithTransactionId(response.TransactionId) .Where(SearchCriteria.StartDate, startDate) .And(SearchCriteria.EndDate, startDate) .Execute(); Assert.IsNotNull(responseFind); Assert.IsTrue(responseFind.TotalRecordCount > 0); var transactionSummary = responseFind.Results.FirstOrDefault(); Assert.IsTrue(transactionSummary.AlternativePaymentResponse is AlternativePaymentResponse); Assert.AreEqual(AlternativePaymentType.PAYPAL.ToString().ToLower(), transactionSummary.AlternativePaymentResponse.ProviderName); Assert.AreEqual("PENDING", transactionSummary.TransactionStatus); Assert.IsNotNull(transactionSummary.AlternativePaymentResponse.ProviderReference); var transaction = Transaction.FromId(transactionSummary.TransactionId, null, PaymentMethodType.APM); transaction.AlternativePaymentResponse = transactionSummary.AlternativePaymentResponse; response = transaction.Confirm().Execute(); Assert.IsNotNull(response); Assert.AreEqual("SUCCESS", response.ResponseCode); Assert.AreEqual("CAPTURED", response.ResponseMessage); }
public void APMForCharge() { var PaymentMethodDetails = new AlternativePaymentMethod { AlternativePaymentMethodType = AlternativePaymentType.SOFORT, ReturnUrl = "https://www.example.com/returnUrl", StatusUpdateUrl = "https://www.example.com/statusUrl", Descriptor = "Test Transaction", Country = "DE", AccountHolderName = "James Mason" }; var response = PaymentMethodDetails.Charge(15m) .WithCurrency("EUR") .Execute(); Assert.IsNotNull(response); Assert.AreEqual("01", response.ResponseCode, response.ResponseMessage); }
public void APMPayByBanckApp() { var paymentMethod = new AlternativePaymentMethod { AlternativePaymentMethodType = AlternativePaymentType.PAYBYBANKAPP, ReturnUrl = "https://www.example.com/returnUrl", StatusUpdateUrl = "https://www.example.com/statusUrl", Descriptor = "Test Transaction", Country = "GB", AccountHolderName = "James Mason" }; var response = paymentMethod.Charge(10m) .WithCurrency("GBP") .WithDescription("New APM") .Execute(); Assert.IsNotNull(response); Assert.AreEqual("01", response.ResponseCode); }
public void APMPayPal() { var paymentMethod = new AlternativePaymentMethod { AlternativePaymentMethodType = AlternativePaymentType.PAYPAL, ReturnUrl = "https://7b8e82a17ac00346e91e984f42a2a5fb.m.pipedream.net", StatusUpdateUrl = "https://7b8e82a17ac00346e91e984f42a2a5fb.m.pipedream.net", CancelUrl = "https://7b8e82a17ac00346e91e984f42a2a5fb.m.pipedream.net", Descriptor = "Test Transaction", Country = "US", AccountHolderName = "James Mason" }; Decimal amount = 10m; string currency = "USD"; var transaction = paymentMethod.Charge(amount) .WithCurrency(currency) .WithDescription("New APM") .Execute(); Assert.IsNotNull(transaction); Assert.AreEqual("00", transaction.ResponseCode); Assert.IsNotNull(transaction.AlternativePaymentResponse.SessionToken); Console.WriteLine("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + transaction.AlternativePaymentResponse.SessionToken); Thread.Sleep(30000); transaction.AlternativePaymentResponse.ProviderReference = "SMKGK7K2BLEUA"; var response = transaction.Confirm(amount) .WithCurrency(currency) .WithAlternativePaymentType(AlternativePaymentType.PAYPAL) .Execute(); Assert.IsNotNull(response); Assert.AreEqual("00", response.ResponseCode); }
public void APMWithoutCurrency() { var PaymentMethod = new AlternativePaymentMethod { AlternativePaymentMethodType = AlternativePaymentType.SOFORTUBERWEISUNG, ReturnUrl = "https://www.example.com/returnUrl", StatusUpdateUrl = "https://www.example.com/statusUrl", Descriptor = "Test Transaction", Country = "DE", AccountHolderName = "James Mason" }; try { var response = PaymentMethod.Charge(10m) .WithDescription("New APM") .Execute(); } catch (BuilderException ex) { Assert.AreEqual("Currency cannot be null for this transaction type.", ex.Message); } }
public void TestAlternativePaymentMethodForCharge_withAlternativePaymentMethodResponse() { var PaymentMethodDetails = new AlternativePaymentMethod { AlternativePaymentMethodType = AlternativePaymentType.TESTPAY, ReturnUrl = "https://www.example.com/returnUrl", StatusUpdateUrl = "https://www.example.com/statusUrl", Descriptor = "Test Transaction", Country = "DE", AccountHolderName = "James Mason" }; var response = PaymentMethodDetails.Charge(10m) .WithCurrency("EUR") .WithDescription("New APM") .Execute(); Assert.IsNotNull(response); Assert.IsNotNull(response?.AlternativePaymentResponse.AccountHolderName); Assert.IsNotNull(response?.AlternativePaymentResponse.Country); Assert.IsNotNull(response?.AlternativePaymentResponse.PaymentPurpose); Assert.IsNotNull(response?.AlternativePaymentResponse.RedirectUrl); Assert.AreEqual("01", response.ResponseCode, response.ResponseMessage); }