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 CaptureRefundTest() { 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(); Assert.AreEqual("completed", responseRefund.state); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
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 AgreementExecuteTest() { var agreement = new Agreement() { token = "EC-2CD33889A9699491E" }; var executedAgreement = agreement.Execute(TestingUtil.GetApiContext()); Assert.AreEqual("I-ASXCM9U5MJJV", executedAgreement.id); }
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 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 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 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 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 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; } }
public void AgreementCreateTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); // Create a new plan. var plan = PlanTest.GetPlan(); var createdPlan = plan.Create(apiContext); this.RecordConnectionDetails(); // Activate the plan. var patchRequest = new PatchRequest() { new Patch() { op = "replace", path = "/", value = new Plan() { state = "ACTIVE" } } }; createdPlan.Update(apiContext, patchRequest); this.RecordConnectionDetails(); // Create an agreement using the activated plan. var agreement = GetAgreement(); agreement.plan = new Plan() { id = createdPlan.id }; agreement.shipping_address = null; var createdAgreement = agreement.Create(apiContext); this.RecordConnectionDetails(); Assert.IsNull(createdAgreement.id); Assert.IsNotNull(createdAgreement.token); Assert.AreEqual(agreement.name, createdAgreement.name); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void PayoutItemGetTest() { try { var payoutItemId = "G2CFT8SJRB7RN"; var payoutItemDetails = PayoutItem.Get(TestingUtil.GetApiContext(), payoutItemId); this.RecordConnectionDetails(); Assert.IsNotNull(payoutItemDetails); Assert.AreEqual(payoutItemId, payoutItemDetails.payout_item_id); Assert.AreEqual("8NX77PFLN255E", payoutItemDetails.payout_batch_id); } catch (ConnectionException) { this.RecordConnectionDetails(false); } }
public void AgreementGetTest() { var apiContext = TestingUtil.GetApiContext(); var agreement = new Agreement() { token = "EC-2CD33889A9699491E" }; var executedAgreement = agreement.Execute(apiContext); var agreementId = executedAgreement.id; var retrievedAgreement = Agreement.Get(apiContext, agreementId); Assert.AreEqual(agreementId, retrievedAgreement.id); Assert.AreEqual("-6514356286402072739", retrievedAgreement.description); Assert.AreEqual("2015-02-19T08:00:00Z", retrievedAgreement.start_date); Assert.IsNotNull(retrievedAgreement.plan); }
public void WebhookEventValidateReceivedEventMissingWebhookIdTest() { var requestBody = "{\"id\":\"WH-2W7266712B616591M-36507203HX6402335\",\"create_time\":\"2015-05-12T18:14:14Z\",\"resource_type\":\"sale\",\"event_type\":\"PAYMENT.SALE.COMPLETED\",\"summary\":\"Payment completed for $ 20.0 USD\",\"resource\":{\"id\":\"7DW85331GX749735N\",\"create_time\":\"2015-05-12T18:13:18Z\",\"update_time\":\"2015-05-12T18:13:36Z\",\"amount\":{\"total\":\"20.00\",\"currency\":\"USD\"},\"payment_mode\":\"INSTANT_TRANSFER\",\"state\":\"completed\",\"protection_eligibility\":\"ELIGIBLE\",\"protection_eligibility_type\":\"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE\",\"parent_payment\":\"PAY-1A142943SV880364LKVJEFPQ\",\"transaction_fee\":{\"value\":\"0.88\",\"currency\":\"USD\"},\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/payments/sale/7DW85331GX749735N\",\"rel\":\"self\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/payments/sale/7DW85331GX749735N/refund\",\"rel\":\"refund\",\"method\":\"POST\"},{\"href\":\"https://api.sandbox.paypal.com/v1/payments/payment/PAY-1A142943SV880364LKVJEFPQ\",\"rel\":\"parent_payment\",\"method\":\"GET\"}]},\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-2W7266712B616591M-36507203HX6402335\",\"rel\":\"self\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-2W7266712B616591M-36507203HX6402335/resend\",\"rel\":\"resend\",\"method\":\"POST\"}]}"; var requestHeaders = new NameValueCollection { { "Paypal-Cert-Url", "https://api.sandbox.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-a5cafa77" }, { "Paypal-Auth-Version", "v2" }, { "Paypal-Transmission-Sig", "vSOIQFIZQHv8G2vpbOpD/4fSC4/MYhdHyv+AmgJyeJQq6q5avWyHIe/zL6qO5hle192HSqKbYveLoFXGJun2od2zXN3Q45VBXwdX3woXYGaNq532flAtiYin+tQ/0pNwRDsVIufCxa3a8HskaXy+YEfXNnwCSL287esD3HgOHmuAs0mYKQdbR4e8Evk8XOOQaZzGeV7GNXXz19gzzvyHbsbHmDz5VoRl9so5OoHqvnc5RtgjZfG8KA9lXh2MTPSbtdTLQb9ikKYnOGM+FasFMxk5stJisgmxaefpO9Q1qm3rCjaJ29aAOyDNr3Q7WkeN3w4bSXtFMwyRBOF28pJg9g==" }, { "Paypal-Transmission-Id", "b2384410-f8d2-11e4-8bf3-77339302725b" }, { "Paypal-Auth-Algo", "SHA256withRSA" }, { "Paypal-Transmission-Time", "2015-05-12T18:14:14Z" } }; var apiContext = TestingUtil.GetApiContext(); TestingUtil.AssertThrownException <PayPalException>(() => WebhookEvent.ValidateReceivedEvent(apiContext, requestHeaders, requestBody)); }
public void PlanUpdateTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); // Get a test plan for updating purposes. var plan = GetPlan(); var createdPlan = plan.Create(apiContext); this.RecordConnectionDetails(); var planId = createdPlan.id; // Create the patch request and update the description to a random value. var updatedDescription = Guid.NewGuid().ToString(); var patch = new Patch { op = "replace", path = "/", value = new Plan { description = updatedDescription } }; var patchRequest = new PatchRequest { patch }; // Update the plan. createdPlan.Update(apiContext, patchRequest); this.RecordConnectionDetails(); // Verify the plan was updated successfully. var updatedPlan = Plan.Get(apiContext, planId); this.RecordConnectionDetails(); Assert.AreEqual(planId, updatedPlan.id); Assert.AreEqual(updatedDescription, updatedPlan.description); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void PaymentListHistoryTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var paymentHistory = Payment.List(apiContext, count: 10); this.RecordConnectionDetails(); Assert.IsTrue(paymentHistory.count >= 0 && paymentHistory.count <= 10); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void PaymentStateTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var actual = CreatePaymentForSale(apiContext); this.RecordConnectionDetails(); Assert.AreEqual("approved", actual.state); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void OrderGetTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var orderId = "O-2HT09787H36911800"; var order = Order.Get(apiContext, orderId); this.RecordConnectionDetails(); Assert.AreEqual(orderId, order.id); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void CreditCardListTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var creditCardList = CreditCard.List(apiContext, startTime: "2014-11-01T19:27:56Z", endTime: "2014-12-25T19:27:56Z"); this.RecordConnectionDetails(); Assert.IsNotNull(creditCardList); Assert.IsTrue(creditCardList.total_items > 0); Assert.IsTrue(creditCardList.total_pages > 0); } catch (ConnectionException) { this.RecordConnectionDetails(false); } }
public void WebhookGetListTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var webhookList = Webhook.GetAll(apiContext); this.RecordConnectionDetails(); Assert.IsNotNull(webhookList); Assert.IsNotNull(webhookList.webhooks); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void WebhookEventTypeAvailableEventsTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var webhookEventTypeList = WebhookEventType.AvailableEventTypes(apiContext); this.RecordConnectionDetails(); Assert.IsNotNull(webhookEventTypeList); Assert.IsNotNull(webhookEventTypeList.event_types); Assert.IsTrue(webhookEventTypeList.event_types.Count > 2); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void SaleGetTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var saleId = "4V7971043K262623A"; var sale = Sale.Get(apiContext, saleId); this.RecordConnectionDetails(); Assert.IsNotNull(sale); Assert.AreEqual(saleId, sale.id); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void PlanListTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var planList = Plan.List(apiContext); this.RecordConnectionDetails(); Assert.IsNotNull(planList); Assert.IsNotNull(planList.plans); Assert.IsTrue(planList.plans.Count > 0); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void AgreementSearchTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var startDate = "2014-10-01"; var endDate = "2014-10-14"; var transactions = Agreement.ListTransactions(apiContext, "I-9STXMKR58UNN", startDate, endDate); this.RecordConnectionDetails(); Assert.IsNotNull(transactions); Assert.IsNotNull(transactions.agreement_transaction_list); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void FuturePaymentTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var futurePayment = CreateFuturePayment(); this.RecordConnectionDetails(); var retrievedPayment = FuturePayment.Get(apiContext, futurePayment.id); this.RecordConnectionDetails(); Assert.AreEqual(futurePayment.id, retrievedPayment.id); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void InvoiceCreateTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var invoice = GetInvoice(); invoice.merchant_info.address.phone = null; invoice.shipping_info.address.phone = null; var createdInvoice = invoice.Create(apiContext); this.RecordConnectionDetails(); Assert.IsNotNull(createdInvoice.id); Assert.AreEqual(invoice.note, createdInvoice.note); } catch (ConnectionException) { this.RecordConnectionDetails(false); } }
public void PaymentCreateAndGetTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var pay = CreatePaymentForSale(apiContext); this.RecordConnectionDetails(); var retrievedPayment = Payment.Get(apiContext, pay.id); this.RecordConnectionDetails(); Assert.AreEqual(pay.id, retrievedPayment.id); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void PlanDeleteTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var plan = GetPlan(); var createdPlan = plan.Create(apiContext); this.RecordConnectionDetails(); var planId = createdPlan.id; // Create a patch request that will delete the plan var patchRequest = new PatchRequest { new Patch { op = "replace", path = "/", value = new Plan { state = "DELETED" } } }; createdPlan.Update(apiContext, patchRequest); this.RecordConnectionDetails(); // Attempting to retrieve the plan should result in a PayPalException being thrown. TestingUtil.AssertThrownException <PaymentsException>(() => Plan.Get(apiContext, planId)); this.RecordConnectionDetails(); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void WebProfileUpdateTest() { 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(); // Update the profile var newName = "New " + profileName; profile.name = newName; profile.Update(apiContext); this.RecordConnectionDetails(); // Get the profile again and verify it was successfully updated. var retrievedProfile = WebProfile.Get(apiContext, profile.id); this.RecordConnectionDetails(); Assert.AreEqual(newName, retrievedProfile.name); // Delete the profile profile.Delete(apiContext); this.RecordConnectionDetails(); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }