public void AuthorizationGetTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var pay = PaymentTest.CreatePaymentAuthorization(apiContext); this.RecordConnectionDetails(); Assert.IsNotNull(pay); Assert.IsNotNull(pay.transactions); Assert.IsTrue(pay.transactions.Count > 0); var transaction = pay.transactions[0]; Assert.IsNotNull(transaction.related_resources); Assert.IsTrue(transaction.related_resources.Count > 0); var resource = transaction.related_resources[0]; Assert.IsNotNull(resource.authorization); var authorizationId = resource.authorization.id; var authorize = Authorization.Get(apiContext, authorizationId); this.RecordConnectionDetails(); Assert.AreEqual(authorizationId, authorize.id); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public static Payment CreateFuturePayment() { FuturePayment pay = new FuturePayment(); pay.intent = "sale"; CreditCard card = CreditCardTest.GetCreditCard(); List <FundingInstrument> fundingInstruments = new List <FundingInstrument>(); FundingInstrument fundingInstrument = new FundingInstrument(); fundingInstrument.credit_card = card; fundingInstruments.Add(fundingInstrument); Payer payer = new Payer(); payer.payment_method = "credit_card"; payer.funding_instruments = fundingInstruments; List <Transaction> transactionList = new List <Transaction>(); Transaction trans = new Transaction(); trans.amount = AmountTest.GetAmount(); transactionList.Add(trans); pay.transactions = transactionList; pay.payer = payer; Payment paymnt = pay.Create(TestingUtil.GetApiContext()); return(paymnt); }
public void PaymentNullAccessToken() { var payment = GetPaymentForSale(); string accessToken = null; TestingUtil.AssertThrownException <System.ArgumentNullException>(() => payment.Create(new APIContext(accessToken))); }
public void AgreementUpdateTest() { // Get the agreement to be used for verifying the update functionality var apiContext = TestingUtil.GetApiContext(); var agreementId = "I-HP4H4YJFCN07"; var agreement = Agreement.Get(apiContext, agreementId); // Create an update for the agreement var updatedDescription = Guid.NewGuid().ToString(); var patch = new Patch(); patch.op = "replace"; patch.path = "/"; patch.value = new Agreement() { description = updatedDescription }; var patchRequest = new PatchRequest(); patchRequest.Add(patch); // Update the agreement agreement.Update(apiContext, patchRequest); // Verify the agreement was successfully updated var updatedAgreement = Agreement.Get(apiContext, agreementId); Assert.AreEqual(agreementId, updatedAgreement.id); Assert.AreEqual(updatedDescription, updatedAgreement.description); }
public void PayoutItemDetailsCancelTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); // Create a single synchronous payout with an invalid email address. // This will cause the status to be marked as 'UNCLAIMED', allowing // us to cancel the payout. var payoutBatch = PayoutTest.CreateSingleSynchronousPayoutBatch(apiContext); this.RecordConnectionDetails(); Assert.IsNotNull(payoutBatch); Assert.IsNotNull(payoutBatch.items); Assert.IsTrue(payoutBatch.items.Count > 0); var payoutItem = payoutBatch.items[0]; if (payoutItem.transaction_status == PayoutTransactionStatus.UNCLAIMED) { var payoutItemDetails = PayoutItem.Cancel(apiContext, payoutItem.payout_item_id); this.RecordConnectionDetails(); Assert.IsNotNull(payoutItemDetails); Assert.AreEqual(PayoutTransactionStatus.RETURNED, payoutItemDetails.transaction_status); } } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void PlanCreateAndGetTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var plan = GetPlan(); var createdPlan = plan.Create(apiContext); this.RecordConnectionDetails(); Assert.IsTrue(!string.IsNullOrEmpty(createdPlan.id)); Assert.AreEqual(plan.name, createdPlan.name); var retrievedPlan = Plan.Get(apiContext, createdPlan.id); this.RecordConnectionDetails(); Assert.IsNotNull(retrievedPlan); Assert.AreEqual(createdPlan.id, retrievedPlan.id); Assert.AreEqual("T-Shirt of the Month Club Plan", retrievedPlan.name); Assert.AreEqual("Template creation.", retrievedPlan.description); Assert.AreEqual("FIXED", retrievedPlan.type); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void InvoiceQrCodeTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var invoice = GetInvoice(); var createdInvoice = invoice.Create(apiContext); this.RecordConnectionDetails(); var qrCode = Invoice.QrCode(apiContext, createdInvoice.id); this.RecordConnectionDetails(); Assert.IsNotNull(qrCode); Assert.IsTrue(!string.IsNullOrEmpty(qrCode.image)); createdInvoice.Delete(apiContext); this.RecordConnectionDetails(); } catch (ConnectionException) { this.RecordConnectionDetails(false); } }
public void APIContextInvalidAccessTokenConstructorTest() { TestingUtil.AssertThrownException <System.ArgumentNullException>(() => new APIContext("")); TestingUtil.AssertThrownException <System.ArgumentNullException>(() => new APIContext("", "xyz")); TestingUtil.AssertThrownException <System.ArgumentNullException>(() => new APIContext(null)); TestingUtil.AssertThrownException <System.ArgumentNullException>(() => new APIContext(null, "xyz")); }
public void WebhookEventValidateNotSupportedAuthAlgorithm() { TestingUtil.AssertThrownException <AlgorithmNotSupportedException>(() => WebhookEvent.ConvertAuthAlgorithmHeaderToHashAlgorithmName("SHA1withDSA")); TestingUtil.AssertThrownException <AlgorithmNotSupportedException>(() => WebhookEvent.ConvertAuthAlgorithmHeaderToHashAlgorithmName("SHA256withDSA")); TestingUtil.AssertThrownException <AlgorithmNotSupportedException>(() => WebhookEvent.ConvertAuthAlgorithmHeaderToHashAlgorithmName("SHA512withDSA")); TestingUtil.AssertThrownException <AlgorithmNotSupportedException>(() => WebhookEvent.ConvertAuthAlgorithmHeaderToHashAlgorithmName("MD5withDSA")); }
public void WebProfileGetListTest() { try { // Create a new profile var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var profileName = Guid.NewGuid().ToString(); var profile = WebProfileTest.GetWebProfile(); profile.name = profileName; var createdProfile = profile.Create(apiContext); this.RecordConnectionDetails(); // Get the list of profiles var profiles = WebProfile.GetList(apiContext); this.RecordConnectionDetails(); Assert.IsNotNull(profiles); Assert.IsTrue(profiles.Count > 0); // Delete the profile profile.id = createdProfile.id; profile.Delete(apiContext); this.RecordConnectionDetails(); } catch (ConnectionException) { this.RecordConnectionDetails(false); } }
public void WebProfileCreateAndGetTest() { try { // Create the profile var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var profile = WebProfileTest.GetWebProfile(); profile.name = Guid.NewGuid().ToString(); var response = profile.Create(apiContext); this.RecordConnectionDetails(); Assert.IsNotNull(response); Assert.IsNotNull(response.id); // Get the profile var profileId = response.id; var retrievedProfile = WebProfile.Get(apiContext, profileId); this.RecordConnectionDetails(); Assert.AreEqual(profileId, retrievedProfile.id); // Delete the profile retrievedProfile.Delete(apiContext); this.RecordConnectionDetails(); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void WebProfileDeleteTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); // Create a new profile var profileName = Guid.NewGuid().ToString(); var profile = WebProfileTest.GetWebProfile(); profile.name = profileName; var createdProfile = profile.Create(apiContext); this.RecordConnectionDetails(); // Get the profile object for the new profile profile = WebProfile.Get(apiContext, createdProfile.id); this.RecordConnectionDetails(); // Delete the profile profile.Delete(apiContext); this.RecordConnectionDetails(); Assert.AreEqual(204, (int)PayPalResource.LastResponseDetails.Value.StatusCode); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void WebhookCreateAndGetTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var webhook = WebhookTest.GetWebhook(); var url = "https://" + Guid.NewGuid().ToString() + ".com/paypal_webhooks"; webhook.url = url; var createdWebhook = webhook.Create(apiContext); this.RecordConnectionDetails(); Assert.IsNotNull(createdWebhook); Assert.IsTrue(!string.IsNullOrEmpty(createdWebhook.id)); var webhookId = createdWebhook.id; var retrievedWebhook = Webhook.Get(apiContext, webhookId); this.RecordConnectionDetails(); Assert.IsNotNull(retrievedWebhook); Assert.AreEqual(webhookId, retrievedWebhook.id); Assert.AreEqual(url, retrievedWebhook.url); // Cleanup retrievedWebhook.Delete(apiContext); this.RecordConnectionDetails(); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void PayoutCreateAndGetTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var payout = PayoutTest.GetPayout(); var payoutSenderBatchId = "batch_" + System.Guid.NewGuid().ToString().Substring(0, 8); payout.sender_batch_header.sender_batch_id = payoutSenderBatchId; var createdPayout = payout.Create(apiContext, false); this.RecordConnectionDetails(); Assert.IsNotNull(createdPayout); Assert.IsTrue(!string.IsNullOrEmpty(createdPayout.batch_header.payout_batch_id)); Assert.AreEqual(payoutSenderBatchId, createdPayout.batch_header.sender_batch_header.sender_batch_id); var payoutBatchId = createdPayout.batch_header.payout_batch_id; var retrievedPayout = Payout.Get(apiContext, payoutBatchId); this.RecordConnectionDetails(); Assert.IsNotNull(payout); Assert.AreEqual(payoutBatchId, retrievedPayout.batch_header.payout_batch_id); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void RefundIdTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var pay = PaymentTest.CreatePaymentAuthorization(apiContext); this.RecordConnectionDetails(); Assert.IsNotNull(pay); Assert.IsNotNull(pay.transactions); Assert.IsTrue(pay.transactions.Count > 0); var transaction = pay.transactions[0]; Assert.IsNotNull(transaction.related_resources); Assert.IsTrue(transaction.related_resources.Count > 0); var resource = transaction.related_resources[0]; Assert.IsNotNull(resource.authorization); var authorization = Authorization.Get(apiContext, resource.authorization.id); this.RecordConnectionDetails(); var cap = new Capture { amount = new Amount { total = "1", currency = "USD" } }; var response = authorization.Capture(apiContext, cap); this.RecordConnectionDetails(); var fund = new Refund { amount = new Amount { total = "1", currency = "USD" } }; apiContext.ResetRequestId(); var responseRefund = response.Refund(apiContext, fund); this.RecordConnectionDetails(); var retrievedRefund = Refund.Get(apiContext, responseRefund.id); this.RecordConnectionDetails(); Assert.AreEqual(responseRefund.id, retrievedRefund.id); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void WebProfilePartialUpdateTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); // Create a new profile var profileName = Guid.NewGuid().ToString(); var profile = WebProfileTest.GetWebProfile(); profile.name = profileName; var createdProfile = profile.Create(apiContext); this.RecordConnectionDetails(); // Get the profile object for the new profile profile = WebProfile.Get(apiContext, createdProfile.id); this.RecordConnectionDetails(); // Partially update the profile var newName = "New " + profileName; var patch1 = new Patch { op = "add", path = "/presentation/brand_name", value = newName }; var patch2 = new Patch { op = "remove", path = "/flow_config/landing_page_type" }; var patchRequest = new PatchRequest { patch1, patch2 }; profile.PartialUpdate(apiContext, patchRequest); this.RecordConnectionDetails(); // Get the profile again and verify it was successfully updated via the patch commands. var retrievedProfile = WebProfile.Get(apiContext, profile.id); this.RecordConnectionDetails(); Assert.AreEqual(newName, retrievedProfile.presentation.brand_name); Assert.IsTrue(string.IsNullOrEmpty(retrievedProfile.flow_config.landing_page_type)); // Delete the profile profile.Delete(apiContext); this.RecordConnectionDetails(); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void WebhookEventTypeSubscribedEventsTest() { var webhookEventTypeList = WebhookEventType.SubscribedEventTypes(TestingUtil.GetApiContext(), "45R80540W07069023"); Assert.IsNotNull(webhookEventTypeList); Assert.IsNotNull(webhookEventTypeList.event_types); Assert.AreEqual(2, webhookEventTypeList.event_types.Count); }
public void WebhookEventGetTest() { var webhookEventId = "8PT597110X687430LKGECATA"; var webhookEvent = WebhookEvent.Get(TestingUtil.GetApiContext(), webhookEventId); Assert.IsNotNull(webhookEvent); Assert.AreEqual(webhookEventId, webhookEvent.id); }
public void WebhookUpdateTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var webhook = WebhookTest.GetWebhook(); webhook.url = "https://" + Guid.NewGuid().ToString() + ".com/paypal_webhooks"; var createdWebhook = webhook.Create(apiContext); this.RecordConnectionDetails(); var newUrl = "https://update.com/paypal_webhooks/" + Guid.NewGuid().ToString(); var newEventTypeName = "PAYMENT.SALE.REFUNDED"; var patchRequest = new PatchRequest { new Patch { op = "replace", path = "/url", value = newUrl }, new Patch { op = "replace", path = "/event_types", value = new List <WebhookEventType> { new WebhookEventType { name = newEventTypeName } } } }; var updatedWebhook = createdWebhook.Update(apiContext, patchRequest); this.RecordConnectionDetails(); Assert.IsNotNull(updatedWebhook); Assert.AreEqual(createdWebhook.id, updatedWebhook.id); Assert.AreEqual(newUrl, updatedWebhook.url); Assert.IsNotNull(updatedWebhook.event_types); Assert.AreEqual(1, updatedWebhook.event_types.Count); Assert.AreEqual(newEventTypeName, updatedWebhook.event_types[0].name); // Cleanup updatedWebhook.Delete(apiContext); this.RecordConnectionDetails(); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void OAuthTokenCredentialMissingClientSecretTest() { var config = ConfigManager.Instance.GetProperties(); config[BaseConstants.ClientSecret] = ""; var oauthTokenCredential = new OAuthTokenCredential(config); TestingUtil.AssertThrownException <MissingCredentialException>(() => oauthTokenCredential.GetAccessToken()); }
public void AuthroizationReauthorizeTest() { var authorization = Authorization.Get(TestingUtil.GetApiContext(), "7GH53639GA425732B"); var reauthorizeAmount = new Amount(); reauthorizeAmount.currency = "USD"; reauthorizeAmount.total = "1"; authorization.amount = reauthorizeAmount; TestingUtil.AssertThrownException <PaymentsException>(() => authorization.Reauthorize(TestingUtil.GetApiContext())); }
public void AgreementExecuteTest() { var agreement = new Agreement() { token = "EC-2CD33889A9699491E" }; var executedAgreement = agreement.Execute(TestingUtil.GetApiContext()); Assert.AreEqual("I-ASXCM9U5MJJV", executedAgreement.id); }
public void OrderDoVoidTest() { var apiContext = TestingUtil.GetApiContext(); var order = GetExecutedPaymentOrder(apiContext); // Void the order and verify it was successfully voided var response = order.Void(apiContext); Assert.AreEqual("voided", response.state); }
public void OrderAuthorizeTest() { var apiContext = TestingUtil.GetApiContext(); var order = GetExecutedPaymentOrder(apiContext); // Authorize the order and verify it was successful (goes to 'Pending' state) var response = order.Authorize(apiContext); Assert.AreEqual("Pending", response.state); }
public void OrderCaptureTest() { var apiContext = TestingUtil.GetApiContext(); var order = GetExecutedPaymentOrder(apiContext); // Capture a payment for the order and verify it completed successfully var capture = CaptureTest.GetCapture(); var response = order.Capture(apiContext, capture); Assert.AreEqual("completed", response.state); }
public void AgreementSuspendTest() { var apiContext = TestingUtil.GetApiContext(); var agreementId = ""; var agreement = Agreement.Get(apiContext, agreementId); var agreementStateDescriptor = new AgreementStateDescriptor(); agreementStateDescriptor.note = "Suspending the agreement."; agreement.Suspend(apiContext, agreementStateDescriptor); var suspendedAgreement = Agreement.Get(apiContext, agreementId); }
public void AgreementReactivateTest() { var apiContext = TestingUtil.GetApiContext(); var agreementId = ""; var agreement = Agreement.Get(apiContext, agreementId); var agreementStateDescriptor = new AgreementStateDescriptor(); agreementStateDescriptor.note = "Re-activating the agreement."; agreement.ReActivate(apiContext, agreementStateDescriptor); var reactivatedAgreement = Agreement.Get(apiContext, agreementId); }
public void AgreementCancelTest() { var apiContext = TestingUtil.GetApiContext(); var agreementId = ""; var agreement = Agreement.Get(apiContext, agreementId); var agreementStateDescriptor = new AgreementStateDescriptor(); agreementStateDescriptor.note = "Canceling the agreement."; agreement.Cancel(apiContext, agreementStateDescriptor); var canceledAgreement = Agreement.Get(apiContext, agreementId); }
public static Refund GetRefund() { var refund = new Refund(); refund.capture_id = "101"; refund.id = "102"; refund.parent_payment = "103"; refund.sale_id = "104"; refund.state = "COMPLETED"; refund.amount = AmountTest.GetAmount(); refund.create_time = TestingUtil.GetCurrentDateISO(-1); refund.links = LinksTest.GetLinksList(); return(refund); }
public void CreditCardUpdateTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var creditCard = GetCreditCard().Create(apiContext); this.RecordConnectionDetails(); // Create a patch request to update the credit card. var patchRequest = new PatchRequest { new Patch { op = "replace", path = "/billing_address", value = new Address { line1 = "111 First Street", city = "Saratoga", country_code = "US", state = "CA", postal_code = "95070" } } }; var updatedCreditCard = creditCard.Update(apiContext, patchRequest); this.RecordConnectionDetails(); // Retrieve the credit card details from the vault and verify the // billing address was updated properly. var retrievedCreditCard = CreditCard.Get(apiContext, updatedCreditCard.id); this.RecordConnectionDetails(); Assert.IsNotNull(retrievedCreditCard); Assert.IsNotNull(retrievedCreditCard.billing_address); Assert.AreEqual("111 First Street", retrievedCreditCard.billing_address.line1); Assert.AreEqual("Saratoga", retrievedCreditCard.billing_address.city); Assert.AreEqual("US", retrievedCreditCard.billing_address.country_code); Assert.AreEqual("CA", retrievedCreditCard.billing_address.state); Assert.AreEqual("95070", retrievedCreditCard.billing_address.postal_code); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }