public void AuthorizationVoidTest() { var pay = PaymentTest.CreatePaymentAuthorization(); var authorizationId = pay.transactions[0].related_resources[0].authorization.id; var authorize = Authorization.Get(TestingUtil.GetApiContext(), authorizationId); var authorizationResponse = authorize.Void(TestingUtil.GetApiContext()); Assert.AreEqual("voided", authorizationResponse.state); }
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 PlanGetTest() { var plan = Plan.Get(TestingUtil.GetApiContext(), "P-0V2939118D268823YFYLVH4Y"); Assert.IsNotNull(plan); Assert.AreEqual("T-Shirt of the Month Club Plan", plan.name); Assert.AreEqual("Template creation.", plan.description); Assert.AreEqual("FIXED", plan.type); }
public void PayoutItemGetTest() { var payoutItemId = "G2CFT8SJRB7RN"; var payoutItemDetails = PayoutItem.Get(TestingUtil.GetApiContext(), payoutItemId); Assert.IsNotNull(payoutItemDetails); Assert.AreEqual(payoutItemId, payoutItemDetails.payout_item_id); Assert.AreEqual("8NX77PFLN255E", payoutItemDetails.payout_batch_id); }
public void AgreementSearchTest() { var startDate = "2014-10-01"; var endDate = "2014-10-14"; var transactions = Agreement.ListTransactions(TestingUtil.GetApiContext(), "I-9STXMKR58UNN", startDate, endDate); Assert.IsNotNull(transactions); Assert.IsNotNull(transactions.agreement_transaction_list); }
public void CaptureRefundTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var pay = PaymentTest.CreatePaymentAuthorization(apiContext); this.RecordConnectionDetails(); Assert.NotNull(pay); Assert.NotNull(pay.transactions); Assert.True(pay.transactions.Count > 0); var transaction = pay.transactions[0]; Assert.NotNull(transaction.related_resources); Assert.True(transaction.related_resources.Count > 0); var resource = transaction.related_resources[0]; Assert.NotNull(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.Equal("completed", responseRefund.state); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void WebhookDeleteTest() { var webhook = WebhookTest.GetWebhook(); webhook.url = "https://" + Guid.NewGuid().ToString() + ".com/paypal_webhooks"; var createdWebhook = webhook.Create(TestingUtil.GetApiContext()); createdWebhook.Delete(TestingUtil.GetApiContext()); TestingUtil.AssertThrownException <HttpException>(() => Webhook.Get(TestingUtil.GetApiContext(), createdWebhook.id)); }
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.Equal("Pending", response.state); }
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.Equal("voided", response.state); }
public void AgreementGetTest() { var agreementId = "I-RDJKRLEBYWYH"; var agreement = Agreement.Get(TestingUtil.GetApiContext(), agreementId); Assert.AreEqual(agreementId, agreement.id); Assert.AreEqual("Agreement for T-Shirt of the Month Club", agreement.description); Assert.AreEqual("2016-02-19T08:00:00Z", agreement.start_date); Assert.IsNotNull(agreement.plan); }
public void AgreementExecuteTest() { var agreement = new Agreement() { token = "EC-2CD33889A9699491E" }; var executedAgreement = agreement.Execute(TestingUtil.GetApiContext()); Assert.AreEqual("I-ASXCM9U5MJJV", executedAgreement.id); }
public void InvoiceQrCodeTest() { var invoice = GetInvoice(); var createdInvoice = invoice.Create(TestingUtil.GetApiContext()); var qrCode = Invoice.QrCode(TestingUtil.GetApiContext(), createdInvoice.id); Assert.IsNotNull(qrCode); Assert.IsTrue(!string.IsNullOrEmpty(qrCode.image)); createdInvoice.Delete(TestingUtil.GetApiContext()); }
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 <PayPal.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.Equal("completed", response.state); }
public void InvoiceCreateTest() { var invoice = GetInvoice(); invoice.merchant_info.address.phone = null; invoice.shipping_info.address.phone = null; var createdInvoice = invoice.Create(TestingUtil.GetApiContext()); Assert.IsNotNull(createdInvoice.id); Assert.AreEqual(invoice.note, createdInvoice.note); }
public void PayoutCreateTest() { 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(TestingUtil.GetApiContext(), false); 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); }
public void OrderGetTest() { try { var orderId = "O-2HT09787H36911800"; var order = Order.Get(TestingUtil.GetApiContext(), orderId); Assert.AreEqual(orderId, order.id); } finally { TestingUtil.RecordConnectionDetails(); } }
public void WebhookCreateTest() { var webhook = WebhookTest.GetWebhook(); webhook.url = "https://" + Guid.NewGuid().ToString() + ".com/paypal_webhooks"; var createdWebhook = webhook.Create(TestingUtil.GetApiContext()); Assert.IsNotNull(createdWebhook); Assert.IsTrue(!string.IsNullOrEmpty(createdWebhook.id)); // Cleanup createdWebhook.Delete(TestingUtil.GetApiContext()); }
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 PaymentListHistoryTest() { try { var context = TestingUtil.GetApiContext(); var paymentHistory = Payment.List(context, count: 10); Assert.IsTrue(paymentHistory.count > 0 && paymentHistory.count <= 10); } finally { TestingUtil.RecordConnectionDetails(); } }
public void WebhookGetListTest() { try { var webhookList = Webhook.GetAll(TestingUtil.GetApiContext()); Assert.IsNotNull(webhookList); Assert.IsNotNull(webhookList.webhooks); } finally { TestingUtil.RecordConnectionDetails(); } }
public void PaymentCreateAndGetTest() { try { var context = TestingUtil.GetApiContext(); var pay = CreatePaymentForSale(); var retrievedPayment = Payment.Get(context, pay.id); Assert.AreEqual(pay.id, retrievedPayment.id); } finally { TestingUtil.RecordConnectionDetails(); } }
public void WebhookGetListTest() { try { var webhookList = Webhook.GetAll(TestingUtil.GetApiContext()); Assert.IsNotNull(webhookList); Assert.IsNotNull(webhookList.webhooks); } catch (ConnectionException ex) { TestingUtil.WriteConnectionExceptionDetails(ex); throw; } }
public void WebProfileCreateTest() { var profile = WebProfileTest.GetWebProfile(); profile.name = Guid.NewGuid().ToString(); var response = profile.Create(TestingUtil.GetApiContext()); Assert.IsNotNull(response); Assert.IsNotNull(response.id); // Delete the profile profile = WebProfile.Get(TestingUtil.GetApiContext(), response.id); profile.Delete(TestingUtil.GetApiContext()); }
public void PlanListTest() { try { var planList = Plan.List(TestingUtil.GetApiContext()); Assert.IsNotNull(planList); Assert.IsNotNull(planList.plans); Assert.IsTrue(planList.plans.Count > 0); } finally { TestingUtil.RecordConnectionDetails(); } }
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 FuturePaymentTest() { try { var context = TestingUtil.GetApiContext(); var futurePayment = CreateFuturePayment(); var retrievedPayment = FuturePayment.Get(context, futurePayment.id); Assert.AreEqual(futurePayment.id, retrievedPayment.id); } finally { TestingUtil.RecordConnectionDetails(); } }
public void PaymentListHistoryTest() { try { var context = TestingUtil.GetApiContext(); var paymentHistory = Payment.List(context, count: 10); Assert.IsTrue(paymentHistory.count > 0 && paymentHistory.count <= 10); } catch (ConnectionException ex) { TestingUtil.WriteConnectionExceptionDetails(ex); throw; } }