var ipSets = new CfnIPSet(scope, "IPSet", new CfnIPSetProps
{
Name = "IPTest",
Addresses = new string[] { "1.2.3.4/32" },
IpAddressVersion = "IPV4",
Scope= "REGIONAL"
});
new CfnWebACL.RuleProperty()
{
Name = "Black-List-Rules",
Priority = 5,
//statement not properly translated
Statement = new CfnWebACL.StatementOneProperty
{
IpSetReferenceStatement = ipSets.AttrArn
},
VisibilityConfig = new CfnWebACL.VisibilityConfigProperty
{
SampledRequestsEnabled = true,
CloudWatchMetricsEnabled = true,
MetricName = "Black-List-Rules"
},
Action = new CfnWebACL.RuleActionProperty
{
Allow = new CfnWebACL.RuleActionProperty { Allow = false}
},
}
TestWebACL Error reason: Your statement has multiple values set for a field that requires exactly one value., field: STATEMENT, parameter: Statement (Service: Wafv2, Status Code: 400, Request ID: dd0d6492-5aa9-41e2-ac15-ee7bc133d705, Extended Request ID: null)
C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7922:49
_ Kernel._wrapSandboxCode (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:8395:20)
_ Kernel._create (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7922:26)
_ Kernel.create (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7666:21)
_ KernelHost.processRequest (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7446:28)
_ KernelHost.run (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7384:14)
_ Immediate._onImmediate (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7387:37)
_ processImmediate (internal/timers.js:456:21)
cloud formation (cdk synth)
{
"Action": {
"Block": {
"block": true
}
},
"Name": "Black-List-Rules",
"Priority": 5,
"Statement": {}, //missing
"VisibilityConfig": {
"CloudWatchMetricsEnabled": true,
"MetricName": "Black-List-Rules",
"SampledRequestsEnabled": true
}
}
Solved
["Statement"] = new Dictionary<string, object>
{
["OrStatement"] = new Dictionary<string, object>
{
["Statements"] = new [] {
new Dictionary<string, object>
{
["IpSetReferenceStatement"] = new Dictionary<string , object> {
["Arn"] = ipSetsOne.AttrArn
},
},
new Dictionary<string, object>
{
["IpSetReferenceStatement"] = new Dictionary<string , object> {
["Arn"] = ipSetsTwo.AttrArn
},
}
}
}
},
https://docs.aws.amazon.com/cdk/latest/guide/cfn_layer.html
I'm using Braintree SDK in .NET. Implemented the SDK and followed the documentation.
Created Sandbox Merchant Account
Created Sandbox Personal Account
I'm using the Access Token for the transaction. Please refer the following code snippet:
//--------------------------- Get Token for client ---------------------------
public PaypalHelper.Paypal_ResponseObj<string> GetPaypalClientToken()
{
string PaypalAccessToken = "XXXXXXXXXXXXXXXXXXX";
if (PaypalAccessToken != null)
{
BraintreeGateway gateway = new BraintreeGateway(PaypalAccessToken);
string clientToken = gateway.ClientToken.Generate();
return new PaypalHelper.Paypal_ResponseObj<string>()
{
Code = HttpStatusCode.OK,
Message = "Payment from paypal successfully initiated.",
Response = clientToken
};
}
else
{
return new PaypalHelper.Paypal_ResponseObj<string>()
{
Code = HttpStatusCode.Unauthorized,
Message = "Unauthorized! Paypal access token is not set or invalid.",
Response = null
};
}
}
//--------------------------- Do Paypal transaction ---------------------------
public PaypalHelper.Paypal_ResponseObj<Result<Transaction>> PayPalTransaction(string Nonce, decimal Amount)
{
if (!string.IsNullOrEmpty(Nonce) && !string.IsNullOrWhiteSpace(Nonce) && Amount > 0)
{
string PaypalAccessToken = "XXXXXXXXXXXXXXXXXXX";
if (PaypalAccessToken != null)
{
BraintreeGateway gateway = new BraintreeGateway(PaypalAccessToken);
var request = new TransactionRequest
{
Amount = Amount,
PaymentMethodNonce = Nonce,
Options = new TransactionOptionsRequest
{
SubmitForSettlement = true
}
};
var result = gateway.Transaction.Sale(request);
if (result.IsSuccess())
{
if (result.Errors == null && result.Target != null)
{
return new PaypalHelper.Paypal_ResponseObj<Result<Transaction>>()
{
Code = HttpStatusCode.OK,
Message = "Payment from paypal successfully initiated.",
Response = result
};
}
else
{
return new PaypalHelper.Paypal_ResponseObj<Result<Transaction>>()
{
Code = HttpStatusCode.Conflict,
Message = "Unable to process this request.",
Response = result
};
}
}
else
{
return new PaypalHelper.Paypal_ResponseObj<Result<Transaction>>()
{
Code = HttpStatusCode.Conflict,
Message = "Payment unsuccessfull.",
Response = result
};
}
}
else
{
return new PaypalHelper.Paypal_ResponseObj<Result<Transaction>>()
{
Code = HttpStatusCode.Unauthorized,
Message = "Un authorized! Paypal access token is not set or invalid.",
Response = null
};
}
}
else {
return new PaypalHelper.Paypal_ResponseObj<Result<Transaction>>()
{
Code = HttpStatusCode.BadRequest,
Message = "input can't be null!",
Response = null
};
}
}
Just to summarize all, we have a PayPal business account and we also created a Sandbox business merchant account and Sandbox personal account to test this scenario.
Please refer the following payload being sent to PayPal for the transaction:
{
"CreditCard":null,
"Amount":235.0000,
"DeviceData":null,
"DeviceSessionId":null,
"FraudMerchantId":null,
"Channel":null,
"OrderId":"SWS-O-RQ-894XX",
"Recurring":null,
"TransactionSource":null,
"MerchantAccountId":"USD",
"PurchaseOrderNumber":null,
"Customer":{
"Id":null,
"DeviceData":null,
"CustomerId":null,
"FirstName":"John",
"LastName":"Doe",
"Company":null,
"Email":"johndoe#swsn.com",
"Phone":"330459218319",
"Fax":null,
"Website":null,
"PaymentMethodNonce":null,
"DefaultPaymentMethodToken":null,
"CustomFields":null,
"CreditCard":null,
"UsBankAccount":null,
"RiskData":null,
"Options":null
},
"Descriptor":null,
"Industry":null,
"BillingAddress":null,
"ShippingAddress":{
"FirstName":"John",
"LastName":"Doe",
"Company":null,
"StreetAddress":"XX Boulevard Haussmann",
"ExtendedAddress":null,
"Locality":"Paris",
"Region":null,
"PostalCode":"75008",
"CountryCodeAlpha2":"FR",
"CountryCodeAlpha3":null,
"CountryCodeNumeric":null,
"CountryName":null
},
"PayPalAccount":null,
"TaxAmount":null,
"TaxExempt":null,
"Type":null,
"CustomFields":{
},
"Options":{
"HoldInEscrow":null,
"StoreInVault":null,
"StoreInVaultOnSuccess":null,
"AddBillingAddressToPaymentMethod":null,
"StoreShippingAddressInVault":null,
"SubmitForSettlement":true,
"VenmoSdkSession":null,
"PayeeId":null,
"PayeeEmail":null,
"SkipAdvancedFraudChecking":null,
"SkipAvs":null,
"SkipCvv":null,
"PayPal":null,
"ThreeDSecure":null,
"AmexRewards":null,
"Venmo":null,
"CreditCard":null
},
"ThreeDSecurePassThru":null,
"PaymentMethodToken":null,
"CustomerId":null,
"ShippingAddressId":null,
"BillingAddressId":null,
"VenmoSdkPaymentMethodCode":null,
"PaymentMethodNonce":"799178b2-1e00-0ac7-6db0-034a9a668b1a",
"ServiceFeeAmount":null,
"SharedPaymentMethodToken":null,
"SharedPaymentMethodNonce":null,
"SharedCustomerId":null,
"SharedShippingAddressId":null,
"SharedBillingAddressId":null,
"ThreeDSecureToken":null,
"RiskData":null,
"DiscountAmount":null,
"ShippingAmount":null,
"ShipsFromPostalCode":null,
"LineItems":null,
"ExternalVault":null
}
Please refer the following response object that we are getting from PayPal after initiating a transaction:
{
"CreditCardVerification":null,
"Transaction":{
"Id":"r9b19cwh",
"AddOns":[
],
"Amount":235,
"AvsErrorResponseCode":null,
"AvsPostalCodeResponseCode":"I",
"AvsStreetAddressResponseCode":"I",
"BillingAddress":{
"Id":null,
"CustomerId":null,
"FirstName":null,
"LastName":null,
"Company":null,
"StreetAddress":null,
"ExtendedAddress":null,
"Locality":null,
"Region":null,
"PostalCode":null,
"CountryCodeAlpha2":null,
"CountryCodeAlpha3":null,
"CountryCodeNumeric":null,
"CountryName":null,
"CreatedAt":null,
"UpdatedAt":null
},
"Channel":null,
"CreatedAt":"2020-03-31T19:25:43Z",
"CreditCard":{
"Bin":null,
"CardholderName":null,
"CardType":{
},
"CreatedAt":null,
"CustomerId":null,
"IsDefault":null,
"IsVenmoSdk":false,
"IsExpired":null,
"CustomerLocation":{
},
"LastFour":null,
"UniqueNumberIdentifier":null,
"Subscriptions":[
],
"Token":null,
"UpdatedAt":null,
"BillingAddress":{
"Id":null,
"CustomerId":null,
"FirstName":null,
"LastName":null,
"Company":null,
"StreetAddress":null,
"ExtendedAddress":null,
"Locality":null,
"Region":null,
"PostalCode":null,
"CountryCodeAlpha2":null,
"CountryCodeAlpha3":null,
"CountryCodeNumeric":null,
"CountryName":null,
"CreatedAt":null,
"UpdatedAt":null
},
"ExpirationMonth":null,
"ExpirationYear":null,
"Prepaid":{
},
"Payroll":{
},
"Debit":{
},
"Commercial":{
},
"Healthcare":{
},
"DurbinRegulated":{
},
"ImageUrl":"https://assets.braintreegateway.com/payment_method_logo/unknown.png?environment=sandbox",
"Verification":null,
"AccountType":null,
"CountryOfIssuance":"Unknown",
"IssuingBank":"Unknown",
"ProductId":"Unknown",
"ExpirationDate":"/",
"MaskedNumber":"**"
},
"CurrencyIsoCode":"USD",
"CustomerDetails":{
"Id":null,
"FirstName":"John",
"LastName":"Doe",
"Company":null,
"Email":"johndoe#swsln.com",
"Phone":"000459210000",
"Fax":null,
"Website":null
},
"CvvResponseCode":"I",
"Descriptor":{
"Name":null,
"Phone":null,
"Url":null
},
"Discounts":[
],
"Disputes":[
],
"GatewayRejectionReason":{
},
"MerchantAccountId":"USD",
"OrderId":"SWS-O-RQ-894XX",
"PlanId":null,
"ProcessorAuthorizationCode":null,
"ProcessorResponseType":{
},
"ProcessorResponseCode":"2046",
"ProcessorResponseText":"Declined",
"ProcessorSettlementResponseCode":null,
"ProcessorSettlementResponseText":null,
"AdditionalProcessorResponse":"2046 : TRANSACTION_REFUSED",
"VoiceReferralNumber":null,
"PurchaseOrderNumber":null,
"Recurring":false,
"RefundedTransactionId":null,
"RefundIds":[
],
"PartialSettlementTransactionIds":[
],
"AuthorizedTransactionId":null,
"SettlementBatchId":null,
"ShippingAddress":{
"Id":null,
"CustomerId":null,
"FirstName":"John",
"LastName":"Doe",
"Company":null,
"StreetAddress":"XX Boulevard XXXX",
"ExtendedAddress":null,
"Locality":"Paris",
"Region":null,
"PostalCode":"75008",
"CountryCodeAlpha2":"FR",
"CountryCodeAlpha3":"FRA",
"CountryCodeNumeric":"250",
"CountryName":"France",
"CreatedAt":null,
"UpdatedAt":null
},
"EscrowStatus":{
},
"Status":{
},
"StatusHistory":[
{
"Amount":235,
"Status":{
},
"Timestamp":"2020-03-31T19:25:48Z",
"Source":{
},
"User":null
}
],
"AuthorizationAdjustments":[
],
"SubscriptionId":null,
"SubscriptionDetails":{
"BillingPeriodEndDate":null,
"BillingPeriodStartDate":null
},
"TaxAmount":null,
"TaxExempt":false,
"Type":{
},
"UpdatedAt":"2020-03-31T19:25:48Z",
"CustomFields":{
},
"ServiceFeeAmount":null,
"DisbursementDetails":{
"SettlementAmount":null,
"SettlementCurrencyIsoCode":null,
"SettlementCurrencyExchangeRate":null,
"FundsHeld":null,
"Success":null,
"DisbursementDate":null
},
"ApplePayDetails":null,
"AndroidPayDetails":null,
"AmexExpressCheckoutDetails":null,
"PayPalDetails":{
"PayerEmail":"sb-zkd0t1338940#personal.example.com",
"PaymentId":null,
"AuthorizationId":null,
"Token":null,
"ImageUrl":"https://assets.braintreegateway.com/payment_method_logo/paypal.png?environment=sandbox",
"DebugId":"20ac958b09914",
"PayeeId":null,
"PayeeEmail":null,
"CustomField":null,
"PayerId":null,
"PayerFirstName":null,
"PayerLastName":null,
"PayerStatus":null,
"SellerProtectionStatus":null,
"CaptureId":null,
"RefundId":null,
"TransactionFeeAmount":null,
"TransactionFeeCurrencyIsoCode":null,
"RefundFromTransactionFeeAmount":null,
"RefundFromTransactionFeeCurrencyIsoCode":null,
"Description":null
},
"LocalPaymentDetails":null,
"CoinbaseDetails":null,
"VenmoAccountDetails":null,
"UsBankAccountDetails":null,
"IdealPaymentDetails":null,
"VisaCheckoutCardDetails":null,
"MasterpassCardDetails":null,
"SamsungPayCardDetails":null,
"PaymentInstrumentType":{
},
"RiskData":null,
"ThreeDSecureInfo":null,
"FacilitatedDetails":null,
"FacilitatorDetails":null,
"DiscountAmount":null,
"ShippingAmount":null,
"ShipsFromPostalCode":null,
"NetworkTransactionId":null,
"AuthorizationExpiresAt":null
},
"Subscription":null,
"Errors":{
"Count":0,
"DeepCount":0
},
"Parameters":{
"transaction[amount]":"235.00",
"transaction[order_id]":"SWS-O-RQ-894XX",
"transaction[payment_method_nonce]":"799178b2-1e00-0ac7-6db0-034a9a668bXX",
"transaction[merchant_account_id]":"USD",
"transaction[type]":"sale",
"transaction[customer][first_name]":"John",
"transaction[customer][last_name]":"Doe",
"transaction[customer][email]":"johndoe#swsln.com",
"transaction[customer][phone]":"330459218319",
"transaction[shipping][first_name]":"John",
"transaction[shipping][last_name]":"Doe",
"transaction[shipping][street_address]":"63 Boulevard Haussmann",
"transaction[shipping][locality]":"Paris",
"transaction[shipping][postal_code]":"75008",
"transaction[shipping][country_code_alpha2]":"FR",
"transaction[options][submit_for_settlement]":"true"
},
"Message":"Declined",
"Target":null
}
Anyone? who can help me to figure out this issue. Is there something I'm missing?
In Elasticsearch Document describe about Function Score Query show code as below
GET /_search
{
"query": {
"function_score": {
"query": { "match_all": {} },
"boost": "5",
"functions": [
{
"filter": { "match": { "test": "bar" } },
"random_score": {},
"weight": 23
},
{
"filter": { "match": { "test": "cat" } },
"weight": 42
}
],
"max_boost": 42,
"score_mode": "max",
"boost_mode": "multiply",
"min_score" : 42
}
}
}
I write this query to object initializer syntax
var searchRequest = new SearchRequest<ProductType>
{
Query = new FunctionScoreQuery()
{
Query = new MatchAllQuery {},
Boost = 5,
Functions = new List<IScoreFunction>
{
Filters...?
},
MaxBoost = 42,
ScoreMode = FunctionScoreMode.Max,
BoostMode = FunctionBoostMode.Max,
MinScore = 42
}
};
How to build filters in Functions?
The IScoreFunction interface allow only ExponentialDecayFunction, GaussDateDecayFunction, LinearGeoDecayFunction, FieldValueFactorFunction, RandomScoreFunction, WeightFunction, ScriptScoreFunction
Functions is a collection of IScoreFunction. In the example JSON, the first function is a random score function, and the second, a weight function. The linked Query DSL example has examples of the different functions, and here's an example to match the JSON above
var client = new ElasticClient();
var searchRequest = new SearchRequest<ProductType>
{
Query = new FunctionScoreQuery()
{
Query = new MatchAllQuery { },
Boost = 5,
Functions = new List<IScoreFunction>
{
new RandomScoreFunction
{
Filter = new MatchQuery
{
Field = "test",
Query = "bar"
},
Weight = 23
},
new WeightFunction
{
Filter = new MatchQuery
{
Field = "test",
Query = "cat"
},
Weight = 42
}
},
MaxBoost = 42,
ScoreMode = FunctionScoreMode.Max,
BoostMode = FunctionBoostMode.Multiply,
MinScore = 42
}
};
var searchResponse = client.Search<ProductType>(searchRequest);
I have a kendo grid in my application and i have added export to excel button to that kendo grid .
My question here is if select the small amount of data in kendo grid and when click on export button everything is working fine
but the problem is if select the large amount of data more than 1000 rows then the web page will become crash and it showing "Aw, Snap" Error
my environment : C#, Jquery, Kendo Grid
I have this code in my js
var tableToExcel = (function() {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(table, name) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
window.location.href = uri + base64(format(template, ctx))
}
})()
tableToExcel("table2excel");
it works fine when the data is small . but if the data is large more than 1000 it crashes the browser
I heard that Chrome can only handle HREF's that are roughly 2 million characters long. So can i handle this using Blob object ? if yes can somebody let me know how to use blob object in my case ?
Please help to resolve this issue .
It exports all data and custom selection using checkbox as well.
function excelExport() {
var exportAll = $('.selectrow').is(":checked");
var grid = $("#grid");
var rows = [{
cells: [
{ value: "column1" },
{ value: "column2" },
{ value: "column3" },
{ value: "column4" },
{ value: "column5" },
{ value: "column6" },
{ value: "column7" }
]
}];
if (exportAll) {
var dataDource = grid.getKendoGrid();
var trs = $("#grid").find('tr');
for (var i = 0; i < trs.length; i++) {
if ($(trs[i]).find(":checkbox").is(":checked")) {
var dataItem = dataDource.dataItem(trs[i]);
rows.push({
cells: [
{ value: dataItem.column1 },
{ value: dataItem.column2 },
{ value: dataItem.column3 },
{ value: dataItem.column4 },
{ value: dataItem.column5 },
{ value: dataItem.column6 },
{ value: dataItem.column7 }
]
})
}
}
}
else {
var dataSource = grid.data("kendoGrid").dataSource;
var trs = grid.find('tr');
for (var i = 1; i < dataSource._data.length; i++) {
var dataItem = dataSource._data[i];
rows.push({
cells: [
{ value: dataItem.column1 },
{ value: dataItem.column2 },
{ value: dataItem.column3 },
{ value: dataItem.column4 },
{ value: dataItem.column5 },
{ value: dataItem.column6 },
{ value: dataItem.column7 }
]
})
}
}
var workbook = new kendo.ooxml.Workbook({
sheets: [
{
columns: [
{ autoWidth: true },
{ autoWidth: true },
{ autoWidth: true },
{ autoWidth: true },
{ autoWidth: true },
{ autoWidth: true },
{ autoWidth: true },
{ autoWidth: true },
{ autoWidth: true }
],
title: "Exported Data Result",
rows: rows
}
]
});
kendo.saveAs({ dataURI: workbook.toDataURL(), fileName: "ExportedData" });
}