Exemplo n.º 1
0
    /// <summary>
    /// Saves on database the updated information for a payment account with the notified information that
    /// means an change on the payment gateway for that object.
    /// Braintree sends notifications through Webhooks to a configured URL, our page at that address
    /// manage it and call this when matched the Kind of notification related to the creation request
    /// for a Sub-merchant or Merchant account (aka provider payment account).
    /// </summary>
    /// <param name="notification"></param>
    public static void RegisterProviderPaymentAccountCreationNotification(WebhookNotification notification, string signature, string payload)
    {
        // If is not a SubMerchant creation, skip (maybe a new main merchant account was created)
        if (!notification.MerchantAccount.IsSubMerchant)
        {
            return;
        }

        var providerID = LcUtils.ExtractInt(notification.MerchantAccount.Id, 0);

        // Is not valid user
        if (providerID == 0)
        {
            using (var logger = new LcLogger("PaymentGatewayWebhook"))
            {
                logger.Log("SubMerchantAccount:: Impossible to get the provider UserID from next MerchantAccountID: {0}", notification.MerchantAccount.Id);
                logger.Log("SubMerchantAccount:: Follows signature and payload");
                logger.LogData(signature);
                logger.LogData(payload);
                logger.Save();
            }
            return;
        }

        LcData.SetProviderPaymentAccount(
            providerID,
            notification.MerchantAccount.Id,
            notification.MerchantAccount.Status.ToString(),
            notification.Message,
            signature,
            payload
            );
    }
Exemplo n.º 2
0
        public void SampleNotification_ReturnsANotificationForGrantedVenmoAccountRevoked()
        {
            String webhookXmlResponse = "<notification>"
                                        + "<source-merchant-id>12345</source-merchant-id>"
                                        + "<timestamp type='datetime'>2018-10-10T22:46:41Z</timestamp>"
                                        + "<kind>granted_payment_method_revoked</kind>"
                                        + "<subject>"
                                        + "<venmo-account>"
                                        + "<created-at type='dateTime'>2018-10-11T21:28:37Z</created-at>"
                                        + "<updated-at type='dateTime'>2018-10-11T21:28:37Z</updated-at>"
                                        + "<default type='boolean'>true</default>"
                                        + "<image-url>https://assets.braintreegateway.com/payment_method_logo/mastercard.png?environment=test</image-url>"
                                        + "<token>venmo_token</token>"
                                        + "<source-description>Venmo Account: venmojoe</source-description>"
                                        + "<username>venmojoe</username>"
                                        + "<venmo-user-id>456</venmo-user-id>"
                                        + "<subscriptions type='array'/>"
                                        + "<customer-id>venmo_customer_id</customer-id>"
                                        + "<global-id>cGF5bWVudG1ldGhvZF92ZW5tb2FjY291bnQ</global-id>"
                                        + "</venmo-account>"
                                        + "</subject>"
                                        + "</notification>";
            String encodedPayload = Convert.ToBase64String(Encoding.GetEncoding(0).GetBytes(webhookXmlResponse)) + '\n';

            Dictionary <string, string> sampleNotification = TestHelper.SampleNotificationFromXml(gateway, encodedPayload);

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.GRANTED_PAYMENT_METHOD_REVOKED, notification.Kind);
            RevokedPaymentMethodMetadata metadata = notification.RevokedPaymentMethodMetadata;

            Assert.AreEqual("venmo_customer_id", metadata.CustomerId);
            Assert.AreEqual("venmo_token", metadata.Token);
            Assert.IsTrue(metadata.RevokedPaymentMethod is VenmoAccount);
        }
Exemplo n.º 3
0
        public void SampleNotification_ReturnsANotificationForGrantedPayPalAccountRevoked()
        {
            String webhookXmlResponse = "<notification>"
                                        + "<source-merchant-id>12345</source-merchant-id>"
                                        + "<timestamp type='datetime'>2018-10-10T22:46:41Z</timestamp>"
                                        + "<kind>granted_payment_method_revoked</kind>"
                                        + "<subject>"
                                        + "<paypal-account>"
                                        + "<billing-agreement-id>billing_agreement_id</billing-agreement-id>"
                                        + "<created-at type='dateTime'>2018-10-11T21:10:33Z</created-at>"
                                        + "<customer-id>paypal_customer_id</customer-id>"
                                        + "<default type='boolean'>true</default>"
                                        + "<email>[email protected]</email>"
                                        + "<global-id>cGF5bWVudG1ldGhvZF9wYXlwYWxfdG9rZW4</global-id>"
                                        + "<image-url>https://assets.braintreegateway.com/payment_method_logo/mastercard.png?environment=test</image-url>"
                                        + "<subscriptions type='array'></subscriptions>"
                                        + "<token>paypal_token</token>"
                                        + "<updated-at type='dateTime'>2018-10-11T21:10:33Z</updated-at>"
                                        + "<payer-id>a6a8e1a4</payer-id>"
                                        + "</paypal-account>"
                                        + "</subject>"
                                        + "</notification>";
            String encodedPayload = Convert.ToBase64String(Encoding.GetEncoding(0).GetBytes(webhookXmlResponse)) + '\n';

            Dictionary <string, string> sampleNotification = TestHelper.SampleNotificationFromXml(gateway, encodedPayload);

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.GRANTED_PAYMENT_METHOD_REVOKED, notification.Kind);
            RevokedPaymentMethodMetadata metadata = notification.RevokedPaymentMethodMetadata;

            Assert.AreEqual("paypal_customer_id", metadata.CustomerId);
            Assert.AreEqual("paypal_token", metadata.Token);
            Assert.IsTrue(metadata.RevokedPaymentMethod is PayPalAccount);
        }
Exemplo n.º 4
0
        public void SampleNotification_CanIncludeSourceMerchantId()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.SUBSCRIPTION_WENT_PAST_DUE, "my_id", "my_source_merchant_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual("my_source_merchant_id", notification.SourceMerchantId);
        }
        public void SampleNotification_ReturnsANotificationForCheck()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.CHECK, "");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.CHECK, notification.Kind);
        }
        public void SampleNotification_ReturnsANotificationForAPartnerMerchantDeclined()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.PARTNER_MERCHANT_DECLINED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.PARTNER_MERCHANT_DECLINED, notification.Kind);
            Assert.AreEqual("abc123", notification.PartnerMerchant.PartnerMerchantId);
        }
        public void SampleNotification_ReturnsANotificationForOAuthAccessRevocation()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.OAUTH_ACCESS_REVOKED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.OAUTH_ACCESS_REVOKED, notification.Kind);
            Assert.AreEqual("abc123", notification.OAuthAccessRevocation.MerchantId);
        }
Exemplo n.º 8
0
        public void SampleNotification_ReturnsANotificationForDisputeWonWebhook()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.DISPUTE_WON, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.DISPUTE_WON, notification.Kind);
            Assert.AreEqual("my_id", notification.Dispute.Id);
        }
        public void SampleNotification_ReturnsAParsableNotification()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.SUBSCRIPTION_WENT_PAST_DUE, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.SUBSCRIPTION_WENT_PAST_DUE, notification.Kind);
            Assert.AreEqual("my_id", notification.Subscription.Id);
            TestHelper.AreDatesEqual(DateTime.Now.ToUniversalTime(), notification.Timestamp.Value);
        }
        public void SampleNotification_ReturnsANotificationForAccountUpdaterDailyReport()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.ACCOUNT_UPDATER_DAILY_REPORT, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.ACCOUNT_UPDATER_DAILY_REPORT, notification.Kind);
            Assert.AreEqual("link-to-csv-report", notification.AccountUpdaterDailyReport.ReportUrl);
            Assert.AreEqual(DateTime.Parse("2016-01-14"), notification.AccountUpdaterDailyReport.ReportDate);
        }
        public void SampleNotification_ReturnsANotificationForAMerchantAccountDeclinedWebhook()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.SUB_MERCHANT_ACCOUNT_DECLINED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.SUB_MERCHANT_ACCOUNT_DECLINED, notification.Kind);
            Assert.AreEqual("my_id", notification.MerchantAccount.Id);
            Assert.AreEqual(ValidationErrorCode.MERCHANT_ACCOUNT_APPLICANT_DETAILS_DECLINED_OFAC, notification.Errors.ForObject("merchant-account").OnField("base")[0].Code);
            Assert.AreEqual("Applicant declined due to OFAC.", notification.Message);
        }
        public void SampleNotification_ReturnsANotificationForAConnectedMerchantPayPalStatusChanged()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.CONNECTED_MERCHANT_PAYPAL_STATUS_CHANGED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.CONNECTED_MERCHANT_PAYPAL_STATUS_CHANGED, notification.Kind);
            Assert.AreEqual("my_id", notification.ConnectedMerchantPayPalStatusChanged.MerchantPublicId);
            Assert.AreEqual("link", notification.ConnectedMerchantPayPalStatusChanged.Action);
            Assert.AreEqual("oauth_application_client_id", notification.ConnectedMerchantPayPalStatusChanged.OAuthApplicationClientId);
        }
        public void SampleNotification_ReturnsANotificationForDisputeLostWebhook()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.DISPUTE_LOST, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.DISPUTE_LOST, notification.Kind);
            Assert.AreEqual("my_id", notification.Dispute.Id);
            Assert.AreEqual(DisputeKind.CHARGEBACK, notification.Dispute.Kind);
            Assert.AreEqual(new DateTime(2014, 3, 21), notification.Dispute.DateOpened);
        }
Exemplo n.º 14
0
        public void SampleNotification_ReturnsANotificationForLocalPaymentReversed()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.LOCAL_PAYMENT_REVERSED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.LOCAL_PAYMENT_REVERSED, notification.Kind);
            LocalPaymentReversed localPayment = notification.LocalPaymentReversed;

            Assert.AreEqual("a-payment-id", localPayment.PaymentId);
        }
        public void SampleNotification_ReturnsANotificationForATransactionDisbursedWebhook()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.TRANSACTION_DISBURSED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.TRANSACTION_DISBURSED, notification.Kind);
            Assert.AreEqual(100.00, notification.Transaction.Amount);
            Assert.AreEqual("my_id", notification.Transaction.Id);
            Assert.IsTrue(notification.Transaction.DisbursementDetails.IsValid());
        }
        public void SampleNotification_ReturnsANotificationForAConnectedMerchantStatusTransitioned()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.CONNECTED_MERCHANT_STATUS_TRANSITIONED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.CONNECTED_MERCHANT_STATUS_TRANSITIONED, notification.Kind);
            Assert.AreEqual("my_id", notification.ConnectedMerchantStatusTransitioned.MerchantPublicId);
            Assert.AreEqual("new_status", notification.ConnectedMerchantStatusTransitioned.Status);
            Assert.AreEqual("oauth_application_client_id", notification.ConnectedMerchantStatusTransitioned.OAuthApplicationClientId);
        }
        public void SampleNotification_ReturnsANotificationForAPartnerMerchantDisconnected()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.PARTNER_MERCHANT_DISCONNECTED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.PARTNER_MERCHANT_DISCONNECTED, notification.Kind);
            Assert.AreEqual(null, notification.PartnerMerchant.MerchantPublicId);
            Assert.AreEqual(null, notification.PartnerMerchant.PublicKey);
            Assert.AreEqual(null, notification.PartnerMerchant.PrivateKey);
            Assert.AreEqual("abc123", notification.PartnerMerchant.PartnerMerchantId);
        }
Exemplo n.º 18
0
        public void SampleNotification_ReturnsANotificationForDisputeOpenedWebhook()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.DISPUTE_OPENED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.DISPUTE_OPENED, notification.Kind);
            Assert.AreEqual("my_id", notification.Dispute.Id);
            Assert.AreEqual("my_id", notification.Dispute.TransactionDetails.Id);
            Assert.AreEqual("250.00", notification.Dispute.TransactionDetails.Amount);
            Assert.AreEqual(DisputeStatus.OPEN, notification.Dispute.Status);
        }
Exemplo n.º 19
0
        // Handle the creation of a resource
        private void onLoanCreated(WebhookNotification notification)
        {
            // Do your work for the Loan Create event here,
            // but keep it fast -- the Webhook server may time out otherwise and re-call
            // your webhook again. For example, write the Loan ID to a database
            // or queue or run a background task to process this loan.

            System.Diagnostics.Debugger.Log(0, "LoanCreated",
                                            String.Format("Received Create notification for Loan {0} by User {1}",
                                                          notification.ResourceID, notification.UserID
                                                          ));
        }
Exemplo n.º 20
0
        public void SampleNotification_ReturnsANotificationForGrantedCreditCardRevoked()
        {
            String webhookXmlResponse = "<notification>"
                                        + "<source-merchant-id>12345</source-merchant-id>"
                                        + "<timestamp type='datetime'>2018-10-10T22:46:41Z</timestamp>"
                                        + "<kind>granted_payment_method_revoked</kind>"
                                        + "<subject>"
                                        + "<credit-card>"
                                        + "<bin>555555</bin>"
                                        + "<card-type>MasterCard</card-type>"
                                        + "<cardholder-name>Amber Ankunding</cardholder-name>"
                                        + "<commercial>Unknown</commercial>"
                                        + "<country-of-issuance>Unknown</country-of-issuance>"
                                        + "<created-at type='datetime'>2018-10-10T22:46:41Z</created-at>"
                                        + "<customer-id>credit_card_customer_id</customer-id>"
                                        + "<customer-location>US</customer-location>"
                                        + "<debit>Unknown</debit>"
                                        + "<default type='boolean'>true</default>"
                                        + "<durbin-regulated>Unknown</durbin-regulated>"
                                        + "<expiration-month>06</expiration-month>"
                                        + "<expiration-year>2020</expiration-year>"
                                        + "<expired type='boolean'>false</expired>"
                                        + "<global-id>cGF5bWVudG1ldGhvZF8zcHQ2d2hz</global-id>"
                                        + "<healthcare>Unknown</healthcare>"
                                        + "<image-url>https://assets.braintreegateway.com/payment_method_logo/mastercard.png?environment=test</image-url>"
                                        + "<issuing-bank>Unknown</issuing-bank>"
                                        + "<last-4>4444</last-4>"
                                        + "<payroll>Unknown</payroll>"
                                        + "<prepaid>Unknown</prepaid>"
                                        + "<product-id>Unknown</product-id>"
                                        + "<subscriptions type='array'/>"
                                        + "<token>credit_card_token</token>"
                                        + "<unique-number-identifier>08199d188e37460163207f714faf074a</unique-number-identifier>"
                                        + "<updated-at type='datetime'>2018-10-10T22:46:41Z</updated-at>"
                                        + "<venmo-sdk type='boolean'>false</venmo-sdk>"
                                        + "<verifications type='array'/>"
                                        + "</credit-card>"
                                        + "</subject>"
                                        + "</notification>";
            String encodedPayload = Convert.ToBase64String(Encoding.GetEncoding(0).GetBytes(webhookXmlResponse)) + '\n';

            Dictionary <string, string> sampleNotification = TestHelper.SampleNotificationFromXml(gateway, encodedPayload);

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.GRANTED_PAYMENT_METHOD_REVOKED, notification.Kind);
            RevokedPaymentMethodMetadata metadata = notification.RevokedPaymentMethodMetadata;

            Assert.AreEqual("credit_card_customer_id", metadata.CustomerId);
            Assert.AreEqual("credit_card_token", metadata.Token);
            Assert.IsTrue(metadata.RevokedPaymentMethod is CreditCard);
        }
        public void SampleNotification_ReturnsANotificationForAMerchantAccountApprovedWebhook()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.SUB_MERCHANT_ACCOUNT_APPROVED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.SUB_MERCHANT_ACCOUNT_APPROVED, notification.Kind);
            Assert.AreEqual("my_id", notification.MerchantAccount.Id);
            Assert.AreEqual(MerchantAccountStatus.ACTIVE, notification.MerchantAccount.Status);
            Assert.AreEqual("master_ma_for_my_id", notification.MerchantAccount.MasterMerchantAccount.Id);
            Assert.AreEqual(MerchantAccountStatus.ACTIVE, notification.MerchantAccount.MasterMerchantAccount.Status);
            TestHelper.AreDatesEqual(DateTime.Now.ToUniversalTime(), notification.Timestamp.Value);
        }
Exemplo n.º 22
0
        /// <summary>
        /// A string representation of the WebhookNotification including indentation
        /// </summary>
        /// <param name="webhookNotification">The WebhookNotification object</param>
        /// <param name="indentationTabs">The number of tabs to insert in front of each member</param>
        /// <returns>A string representation of the WebhookNotification including indentation</returns>
        public static string ToString(this WebhookNotification webhookNotification, int indentationTabs)
        {
            StringBuilder output = new StringBuilder();

            if (webhookNotification != null)
            {
                output.AppendLine();
                output.AddSpacesInFront(indentationTabs).AppendLine("ServiceUri : " + webhookNotification.ServiceUri);
                output.AddSpacesInFront(indentationTabs).Append("Properties : " + webhookNotification.Properties.ToString(indentationTabs + DefaultIndentationTabs));
            }

            return(output.ToString());
        }
Exemplo n.º 23
0
        public void WebhookTesting_SampleNotification_ReturnsANotificationForGrantedVenmoAccountRevoked()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.GRANTED_PAYMENT_METHOD_REVOKED, "granted_payment_method_revoked_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.GRANTED_PAYMENT_METHOD_REVOKED, notification.Kind);
            RevokedPaymentMethodMetadata metadata = notification.RevokedPaymentMethodMetadata;

            Assert.AreEqual("venmo_customer_id", metadata.CustomerId);
            Assert.AreEqual("granted_payment_method_revoked_id", metadata.Token);
            Assert.IsTrue(metadata.RevokedPaymentMethod is VenmoAccount);
        }
Exemplo n.º 24
0
        public void SampleNotification_ReturnsANotificationForAPartnerMerchantConnected()
        {
            Dictionary <String, String> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.PARTNER_MERCHANT_CONNECTED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.PARTNER_MERCHANT_CONNECTED, notification.Kind);
            Assert.AreEqual("public_id", notification.PartnerMerchant.MerchantPublicId);
            Assert.AreEqual("public_key", notification.PartnerMerchant.PublicKey);
            Assert.AreEqual("private_key", notification.PartnerMerchant.PrivateKey);
            Assert.AreEqual("cse_key", notification.PartnerMerchant.ClientSideEncryptionKey);
            Assert.AreEqual("abc123", notification.PartnerMerchant.PartnerMerchantId);
        }
        public void SampleNotification_ReturnsANotificationForLocalPaymentCompleted()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.LOCAL_PAYMENT_COMPLETED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.LOCAL_PAYMENT_COMPLETED, notification.Kind);
            LocalPaymentCompleted localPayment = notification.LocalPaymentCompleted;

            Assert.AreEqual("a-payment-id", localPayment.PaymentId);
            Assert.AreEqual("a-payer-id", localPayment.PayerId);
            Assert.AreEqual("ee257d98-de40-47e8-96b3-a6954ea7a9a4", localPayment.PaymentMethodNonce);
            Assert.NotNull(localPayment.Transaction);
        }
Exemplo n.º 26
0
        public void SampleNotification_ReturnsANotificationForDisputeExpiredWebhook()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.DISPUTE_EXPIRED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.DISPUTE_EXPIRED, notification.Kind);
            Assert.AreEqual("my_id", notification.Dispute.Id);
            Assert.AreEqual("my_id", notification.Dispute.TransactionDetails.Id);
            Assert.AreEqual("250.00", notification.Dispute.TransactionDetails.Amount);
            Assert.AreEqual(DisputeStatus.EXPIRED, notification.Dispute.Status);
            Assert.AreEqual(DisputeKind.CHARGEBACK, notification.Dispute.Kind);
            Assert.AreEqual(new DateTime(2014, 3, 21), notification.Dispute.DateOpened);
        }
        public void SampleNotification_ReturnsANotificationForPaymentMethodRevokedByCustomer()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.PAYMENT_METHOD_REVOKED_BY_CUSTOMER, "my_payment_method_token");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.PAYMENT_METHOD_REVOKED_BY_CUSTOMER, notification.Kind);
            RevokedPaymentMethodMetadata metadata = notification.RevokedPaymentMethodMetadata;

            Assert.AreEqual("my_payment_method_token", metadata.Token);
            Assert.IsTrue(metadata.RevokedPaymentMethod is PayPalAccount);
            PayPalAccount paypalAccount = (PayPalAccount)metadata.RevokedPaymentMethod;

            Assert.IsNotNull(paypalAccount.RevokedAt);
        }
        public void SampleNotification_ReturnsANotificationForSubscriptionChargedSuccessfully()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.SUBSCRIPTION_CHARGED_SUCCESSFULLY, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.SUBSCRIPTION_CHARGED_SUCCESSFULLY, notification.Kind);
            Assert.AreEqual("my_id", notification.Subscription.Id);
            Assert.AreEqual(1, notification.Subscription.Transactions.Count);

            Transaction transaction = notification.Subscription.Transactions[0];

            Assert.AreEqual(TransactionStatus.SUBMITTED_FOR_SETTLEMENT, transaction.Status);
            Assert.AreEqual(49.99m, transaction.Amount);
        }
        /// <summary>
        /// Execute the cmdlet
        /// </summary>
        public override void ExecuteCmdlet()
        {
            Utilities.ValidateUri(this.ServiceUri, "ServiceUri");

            var dictionary = this.Properties == null
                ? new Dictionary <string, string>()
                : this.Properties.Keys.Cast <object>().ToDictionary(key => (string)key, key => (string)this.Properties[key]);

            var action = new WebhookNotification
            {
                ServiceUri = this.ServiceUri,
                Properties = dictionary
            };

            WriteObject(action);
        }
Exemplo n.º 30
0
        public void SampleNotification_ReturnsANotificationForIdealPaymentFailed()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.IDEAL_PAYMENT_FAILED, "my_id");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.IDEAL_PAYMENT_FAILED, notification.Kind);
            IdealPayment idealPayment = notification.IdealPayment;

            Assert.AreEqual("my_id", idealPayment.Id);
            Assert.AreEqual("FAILED", idealPayment.Status);
            Assert.AreEqual("ORDERABC", idealPayment.OrderId);
            Assert.AreEqual(10.00m, idealPayment.Amount);
            Assert.AreEqual("https://example.com", idealPayment.ApprovalUrl);
            Assert.AreEqual("1234567890", idealPayment.IdealTransactionId);
        }
 /// <summary>
 /// Method call to handle the web hook notification.
 /// </summary>
 /// <param name="notification">
 /// The notification.
 /// </param>
 /// <returns>
 /// The <see cref="ActionResult"/>.
 /// </returns>
 protected abstract ActionResult HandleWebhookNotification(WebhookNotification notification);