private string BuildPayload(WebhookKind kind, string id)
        {
            var currentTime = DateTime.Now.ToUniversalTime().ToString("u");
            var payload     = string.Format("<notification><timestamp type=\"datetime\">{0}</timestamp><kind>{1}</kind><subject>{2}</subject></notification>", currentTime, kind, SubjectSampleXml(kind, id));

            return(Convert.ToBase64String(Encoding.GetEncoding(0).GetBytes(payload)) + '\n');
        }
 private string SubjectSampleXml(WebhookKind kind, string id)
 {
     if (kind == WebhookKind.SUB_MERCHANT_ACCOUNT_APPROVED) {
         return MerchantAccountApprovedSampleXml(id);
     } else if (kind == WebhookKind.SUB_MERCHANT_ACCOUNT_DECLINED) {
         return MerchantAccountDeclinedSampleXml(id);
     } else if (kind == WebhookKind.TRANSACTION_DISBURSED) {
         return TransactionDisbursedSampleXml(id);
     } else if (kind == WebhookKind.DISBURSEMENT_EXCEPTION) {
         return DisbursementExceptionSampleXml(id);
     } else if (kind == WebhookKind.DISBURSEMENT) {
         return DisbursementSampleXml(id);
     } else if (kind == WebhookKind.PARTNER_MERCHANT_CONNECTED) {
         return PartnerMerchantConnectedSampleXml(id);
     } else if (kind == WebhookKind.PARTNER_MERCHANT_DISCONNECTED) {
         return PartnerMerchantDisconnectedSampleXml(id);
     } else if (kind == WebhookKind.PARTNER_MERCHANT_DECLINED) {
         return PartnerMerchantDeclinedSampleXml(id);
     } else if (kind == WebhookKind.DISPUTE_OPENED) {
         return DisputeOpenedSampleXml(id);
     } else if (kind == WebhookKind.DISPUTE_LOST) {
         return DisputeLostSampleXml(id);
     } else if (kind == WebhookKind.DISPUTE_WON) {
         return DisputeWonSampleXml(id);
     } else if (kind == WebhookKind.SUBSCRIPTION_CHARGED_SUCCESSFULLY) {
         return SubscriptionChargedSuccessfullySampleXml(id);
     } else if (kind == WebhookKind.CHECK) {
         return CheckSampleXml();
     } else {
         return SubscriptionXml(id);
     }
 }
 private string SubjectSampleXml(WebhookKind kind, string id)
 {
     if (kind == WebhookKind.SUB_MERCHANT_ACCOUNT_APPROVED)
     {
         return(MerchantAccountApprovedSampleXml(id));
     }
     else if (kind == WebhookKind.SUB_MERCHANT_ACCOUNT_DECLINED)
     {
         return(MerchantAccountDeclinedSampleXml(id));
     }
     else if (kind == WebhookKind.TRANSACTION_DISBURSED)
     {
         return(TransactionDisbursedSampleXml(id));
     }
     else if (kind == WebhookKind.DISBURSEMENT_EXCEPTION)
     {
         return(DisbursementExceptionSampleXml(id));
     }
     else if (kind == WebhookKind.DISBURSEMENT)
     {
         return(DisbursementSampleXml(id));
     }
     else if (kind == WebhookKind.PARTNER_MERCHANT_CONNECTED)
     {
         return(PartnerMerchantConnectedSampleXml(id));
     }
     else if (kind == WebhookKind.PARTNER_MERCHANT_DISCONNECTED)
     {
         return(PartnerMerchantDisconnectedSampleXml(id));
     }
     else if (kind == WebhookKind.PARTNER_MERCHANT_DECLINED)
     {
         return(PartnerMerchantDeclinedSampleXml(id));
     }
     else if (kind == WebhookKind.DISPUTE_OPENED)
     {
         return(DisputeOpenedSampleXml(id));
     }
     else if (kind == WebhookKind.DISPUTE_LOST)
     {
         return(DisputeLostSampleXml(id));
     }
     else if (kind == WebhookKind.DISPUTE_WON)
     {
         return(DisputeWonSampleXml(id));
     }
     else if (kind == WebhookKind.SUBSCRIPTION_CHARGED_SUCCESSFULLY)
     {
         return(SubscriptionChargedSuccessfullySampleXml(id));
     }
     else if (kind == WebhookKind.CHECK)
     {
         return(CheckSampleXml());
     }
     else
     {
         return(SubscriptionXml(id));
     }
 }
 public virtual Dictionary<string, string> SampleNotification(WebhookKind kind, string id)
 {
     var response = new Dictionary<string, string>();
     string payload = BuildPayload(kind, id);
     response["bt_payload"] = payload;
     response["bt_signature"] = BuildSignature(payload);
     return response;
 }
        public virtual Dictionary <string, string> SampleNotification(WebhookKind kind, string id, string sourceMerchantId = null)
        {
            var    response = new Dictionary <string, string>();
            string payload  = BuildPayload(kind, id, sourceMerchantId);

            response["bt_payload"]   = payload;
            response["bt_signature"] = BuildSignature(payload);
            return(response);
        }
        private string BuildPayload(WebhookKind kind, string id, string sourceMerchantId)
        {
            var currentTime         = DateTime.Now.ToUniversalTime().ToString("u");
            var sourceMerchantIdXml = "";

            if (sourceMerchantId != null)
            {
                sourceMerchantIdXml = string.Format("<source-merchant-id>{0}</source-merchant-id>", sourceMerchantId);
            }
            var payload = string.Format("<notification><timestamp type=\"datetime\">{0}</timestamp><kind>{1}</kind>{2}<subject>{3}</subject></notification>", currentTime, kind, sourceMerchantIdXml, SubjectSampleXml(kind, id));

            return(Convert.ToBase64String(Encoding.GetEncoding(0).GetBytes(payload)) + '\n');
        }
 private string SubjectSampleXml(WebhookKind kind, string id)
 {
     if (kind == WebhookKind.SUB_MERCHANT_ACCOUNT_APPROVED)
     {
         return(MerchantAccountApprovedSampleXml(id));
     }
     else if (kind == WebhookKind.SUB_MERCHANT_ACCOUNT_DECLINED)
     {
         return(MerchantAccountDeclinedSampleXml(id));
     }
     else if (kind == WebhookKind.TRANSACTION_DISBURSED)
     {
         return(TransactionDisbursedSampleXml(id));
     }
     else if (kind == WebhookKind.TRANSACTION_SETTLED)
     {
         return(TransactionSettledSampleXml(id));
     }
     else if (kind == WebhookKind.TRANSACTION_SETTLEMENT_DECLINED)
     {
         return(TransactionSettlementDeclinedSampleXml(id));
     }
     else if (kind == WebhookKind.DISBURSEMENT_EXCEPTION)
     {
         return(DisbursementExceptionSampleXml(id));
     }
     else if (kind == WebhookKind.DISBURSEMENT)
     {
         return(DisbursementSampleXml(id));
     }
     else if (kind == WebhookKind.PARTNER_MERCHANT_CONNECTED)
     {
         return(PartnerMerchantConnectedSampleXml(id));
     }
     else if (kind == WebhookKind.PARTNER_MERCHANT_DISCONNECTED)
     {
         return(PartnerMerchantDisconnectedSampleXml(id));
     }
     else if (kind == WebhookKind.CONNECTED_MERCHANT_STATUS_TRANSITIONED)
     {
         return(ConnectedMerchantStatusTransitionedSampleXml(id));
     }
     else if (kind == WebhookKind.CONNECTED_MERCHANT_PAYPAL_STATUS_CHANGED)
     {
         return(ConnectedMerchantPayPalStatusChangedSampleXml(id));
     }
     else if (kind == WebhookKind.PARTNER_MERCHANT_DECLINED)
     {
         return(PartnerMerchantDeclinedSampleXml(id));
     }
     else if (kind == WebhookKind.OAUTH_ACCESS_REVOKED)
     {
         return(OAuthAccessRevokedSampleXml(id));
     }
     else if (kind == WebhookKind.DISPUTE_OPENED)
     {
         return(DisputeOpenedSampleXml(id));
     }
     else if (kind == WebhookKind.DISPUTE_LOST)
     {
         return(DisputeLostSampleXml(id));
     }
     else if (kind == WebhookKind.DISPUTE_WON)
     {
         return(DisputeWonSampleXml(id));
     }
     else if (kind == WebhookKind.SUBSCRIPTION_CHARGED_SUCCESSFULLY)
     {
         return(SubscriptionChargedSuccessfullySampleXml(id));
     }
     else if (kind == WebhookKind.SUBSCRIPTION_CHARGED_UNSUCCESSFULLY)
     {
         return(SubscriptionChargedUnsuccessfullySampleXml(id));
     }
     else if (kind == WebhookKind.CHECK)
     {
         return(CheckSampleXml());
     }
     else if (kind == WebhookKind.ACCOUNT_UPDATER_DAILY_REPORT)
     {
         return(AccountUpdaterDailyReportSampleXml(id));
     }
     else if (kind == WebhookKind.IDEAL_PAYMENT_COMPLETE)
     {
         return(IdealPaymentCompleteSampleXml(id));
     }
     else if (kind == WebhookKind.IDEAL_PAYMENT_FAILED)
     {
         return(IdealPaymentFailedSampleXml(id));
     }
     else if (kind == WebhookKind.GRANTED_PAYMENT_INSTRUMENT_UPDATE)
     {
         return(GrantedPaymentInstrumentUpdateSampleXml());
     }
     else if (kind == WebhookKind.LOCAL_PAYMENT_COMPLETED)
     {
         return(LocalPaymentCompletedSampleXml());
     }
     else
     {
         return(SubscriptionXml(id));
     }
 }
 private string BuildPayload(WebhookKind kind, string id)
 {
     var currentTime = DateTime.Now.ToUniversalTime().ToString("u");
     var payload = string.Format("<notification><timestamp type=\"datetime\">{0}</timestamp><kind>{1}</kind><subject>{2}</subject></notification>", currentTime, kind, SubjectSampleXml(kind, id));
     return Convert.ToBase64String(Encoding.Default.GetBytes(payload)) + '\n';
 }
예제 #9
0
 private string SubjectSampleXml(WebhookKind kind, string id)
 {
     if (kind == WebhookKind.SUB_MERCHANT_ACCOUNT_APPROVED)
     {
         return(MerchantAccountApprovedSampleXml(id));
     }
     else if (kind == WebhookKind.SUB_MERCHANT_ACCOUNT_DECLINED)
     {
         return(MerchantAccountDeclinedSampleXml(id));
     }
     else if (kind == WebhookKind.TRANSACTION_DISBURSED)
     {
         return(TransactionDisbursedSampleXml(id));
     }
     else if (kind == WebhookKind.TRANSACTION_SETTLED)
     {
         return(TransactionSettledSampleXml(id));
     }
     else if (kind == WebhookKind.TRANSACTION_SETTLEMENT_DECLINED)
     {
         return(TransactionSettlementDeclinedSampleXml(id));
     }
     else if (kind == WebhookKind.DISBURSEMENT_EXCEPTION)
     {
         return(DisbursementExceptionSampleXml(id));
     }
     else if (kind == WebhookKind.DISBURSEMENT)
     {
         return(DisbursementSampleXml(id));
     }
     else if (kind == WebhookKind.PARTNER_MERCHANT_CONNECTED)
     {
         return(PartnerMerchantConnectedSampleXml(id));
     }
     else if (kind == WebhookKind.PARTNER_MERCHANT_DISCONNECTED)
     {
         return(PartnerMerchantDisconnectedSampleXml(id));
     }
     else if (kind == WebhookKind.CONNECTED_MERCHANT_STATUS_TRANSITIONED)
     {
         return(ConnectedMerchantStatusTransitionedSampleXml(id));
     }
     else if (kind == WebhookKind.CONNECTED_MERCHANT_PAYPAL_STATUS_CHANGED)
     {
         return(ConnectedMerchantPayPalStatusChangedSampleXml(id));
     }
     else if (kind == WebhookKind.PARTNER_MERCHANT_DECLINED)
     {
         return(PartnerMerchantDeclinedSampleXml(id));
     }
     else if (kind == WebhookKind.OAUTH_ACCESS_REVOKED)
     {
         return(OAuthAccessRevokedSampleXml(id));
     }
     else if (kind == WebhookKind.DISPUTE_OPENED)
     {
         return(DisputeOpenedSampleXml(id));
     }
     else if (kind == WebhookKind.DISPUTE_LOST)
     {
         return(DisputeLostSampleXml(id));
     }
     else if (kind == WebhookKind.DISPUTE_WON)
     {
         return(DisputeWonSampleXml(id));
     }
     else if (kind == WebhookKind.DISPUTE_ACCEPTED)
     {
         return(DisputeAcceptedSampleXml(id));
     }
     else if (kind == WebhookKind.DISPUTE_DISPUTED)
     {
         return(DisputeDisputedSampleXml(id));
     }
     else if (kind == WebhookKind.DISPUTE_EXPIRED)
     {
         return(DisputeExpiredSampleXml(id));
     }
     else if (kind == WebhookKind.SUBSCRIPTION_CHARGED_SUCCESSFULLY)
     {
         return(SubscriptionChargedSuccessfullySampleXml(id));
     }
     else if (kind == WebhookKind.SUBSCRIPTION_CHARGED_UNSUCCESSFULLY)
     {
         return(SubscriptionChargedUnsuccessfullySampleXml(id));
     }
     else if (kind == WebhookKind.CHECK)
     {
         return(CheckSampleXml());
     }
     else if (kind == WebhookKind.ACCOUNT_UPDATER_DAILY_REPORT)
     {
         return(AccountUpdaterDailyReportSampleXml(id));
         // NEXT_MAJOR_VERSION Remove this class as legacy Ideal has been removed/disabled in the Braintree Gateway
         // DEPRECATED If you're looking to accept iDEAL as a payment method contact [email protected] for a solution.
     }
     else if (kind == WebhookKind.IDEAL_PAYMENT_COMPLETE)
     {
         return(IdealPaymentCompleteSampleXml(id));
         // NEXT_MAJOR_VERSION Remove this class as legacy Ideal has been removed/disabled in the Braintree Gateway
         // DEPRECATED If you're looking to accept iDEAL as a payment method contact [email protected] for a solution.
     }
     else if (kind == WebhookKind.IDEAL_PAYMENT_FAILED)
     {
         return(IdealPaymentFailedSampleXml(id));
     }
     else if (kind == WebhookKind.GRANTED_PAYMENT_INSTRUMENT_UPDATE)
     {
         // NEXT_MAJOR_VERSION remove GRANTED_PAYMENT_INSTRUMENT_UPDATE branch
         return(GrantedPaymentInstrumentUpdateSampleXml());
     }
     else if (kind == WebhookKind.GRANTOR_UPDATED_GRANTED_PAYMENT_METHOD)
     {
         return(GrantedPaymentInstrumentUpdateSampleXml());
     }
     else if (kind == WebhookKind.RECIPIENT_UPDATED_GRANTED_PAYMENT_METHOD)
     {
         return(GrantedPaymentInstrumentUpdateSampleXml());
     }
     else if (kind == WebhookKind.PAYMENT_METHOD_REVOKED_BY_CUSTOMER)
     {
         return(PaymentMethodRevokedByCustomerSampleXml(id));
     }
     else if (kind == WebhookKind.LOCAL_PAYMENT_COMPLETED)
     {
         return(LocalPaymentCompletedSampleXml());
     }
     else
     {
         return(SubscriptionXml(id));
     }
 }