// Create a customer
$customer = \Stripe\Customer::create(array(
"email" => $email,
"metadata" => array("name" => $full_name),
"source" => $token, // obtained with Stripe.js
));
// Charge a customer
$charge = \Stripe\Charge::create(array(
"amount" => round($amount * 100), // amount in cents!,
"currency" => "usd",
"customer" => $customer->id,
"description" => $description,
"metadata" => array("name" => $customer->metadata->name,"exp_month" => $exp_month, "exp_year" => $exp_year, "address_zip" => $area_pincode,
"address_line1" => $billing_address, "phone" => $phone_number, "cvv" => $cvv_code),
"receipt_email" => $customer->email,
));
This code works fine but after the charge created I am getting the name null on the source key can anyone help me to figure it out due to this the payment is not working on the live environment. This is the charge response
Stripe\Charge Object
(
[_opts:protected] => Stripe\Util\RequestOptions Object
(
[headers] => Array
(
)
[apiKey] => sk_test_UsVZ1TRkIExFae3jiWUHvb2r
)
[_values:protected] => Array
(
[id] => ch_1A3jQVG5CbtVORSys2Ho0vYD
[object] => charge
[amount] => 5600
[amount_refunded] => 0
[application] =>
[application_fee] =>
[balance_transaction] => txn_1A3jQVG5CbtVORSyduH3NX76
[captured] => 1
[created] => 1491042347
[currency] => usd
[customer] =>
[description] => hello world
[destination] =>
[dispute] =>
[failure_code] =>
[failure_message] =>
[fraud_details] => Array
(
)
[invoice] =>
[livemode] =>
[metadata] => Stripe\AttachedObject Object
(
[_opts:protected] => Stripe\Util\RequestOptions Object
(
[headers] => Array
(
)
[apiKey] => sk_test_UsVZ1TRkIExFae3jiWUHvb2r
)
[_values:protected] => Array
(
[name] => kartik
[exp_month] => 03
[exp_year] => 25
[address_zip] => 1745236
[address_line1] => palampur
[phone] => 8956235689
[cvv] => 123
)
[_unsavedValues:protected] => Stripe\Util\Set Object
(
[_elts:Stripe\Util\Set:private] => Array
(
)
)
[_transientValues:protected] => Stripe\Util\Set Object
(
[_elts:Stripe\Util\Set:private] => Array
(
)
)
[_retrieveOptions:protected] => Array
(
)
[_lastResponse:protected] =>
)
[on_behalf_of] =>
[order] =>
[outcome] => Stripe\StripeObject Object
(
[_opts:protected] => Stripe\Util\RequestOptions Object
(
[headers] => Array
(
)
[apiKey] => sk_test_UsVZ1TRkIExFae3jiWUHvb2r
)
[_values:protected] => Array
(
[network_status] => approved_by_network
[reason] =>
[risk_level] => normal
[seller_message] => Payment complete.
[type] => authorized
)
[_unsavedValues:protected] => Stripe\Util\Set Object
(
[_elts:Stripe\Util\Set:private] => Array
(
)
)
[_transientValues:protected] => Stripe\Util\Set Object
(
[_elts:Stripe\Util\Set:private] => Array
(
)
)
[_retrieveOptions:protected] => Array
(
)
[_lastResponse:protected] =>
)
[paid] => 1
[receipt_email] =>
[receipt_number] =>
[refunded] =>
[refunds] => Stripe\Collection Object
(
[_requestParams:protected] => Array
(
)
[_opts:protected] => Stripe\Util\RequestOptions Object
(
[headers] => Array
(
)
[apiKey] => sk_test_UsVZ1TRkIExFae3jiWUHvb2r
)
[_values:protected] => Array
(
[object] => list
[data] => Array
(
)
[has_more] =>
[total_count] => 0
[url] => /v1/charges/ch_1A3jQVG5CbtVORSys2Ho0vYD/refunds
)
[_unsavedValues:protected] => Stripe\Util\Set Object
(
[_elts:Stripe\Util\Set:private] => Array
(
)
)
[_transientValues:protected] => Stripe\Util\Set Object
(
[_elts:Stripe\Util\Set:private] => Array
(
)
)
[_retrieveOptions:protected] => Array
(
)
[_lastResponse:protected] =>
)
[review] =>
[shipping] =>
[source] => Stripe\Card Object
(
[_opts:protected] => Stripe\Util\RequestOptions Object
(
[headers] => Array
(
)
[apiKey] => sk_test_UsVZ1TRkIExFae3jiWUHvb2r
)
[_values:protected] => Array
(
[id] => card_1A3jQSG5CbtVORSysMV7SyBs
[object] => card
[address_city] =>
[address_country] =>
[address_line1] =>
[address_line1_check] =>
[address_line2] =>
[address_state] =>
[address_zip] =>
[address_zip_check] =>
[brand] => Visa
[country] => US
[customer] =>
[cvc_check] => pass
[dynamic_last4] =>
[exp_month] => 3
[exp_year] => 2025
[fingerprint] => EJUqgq2clF6JUp8f
[funding] => credit
[last4] => 4242
[metadata] => Stripe\AttachedObject Object
(
[_opts:protected] => Stripe\Util\RequestOptions Object
(
[headers] => Array
(
)
[apiKey] => sk_test_UsVZ1TRkIExFae3jiWUHvb2r
)
[_values:protected] => Array
(
)
[_unsavedValues:protected] => Stripe\Util\Set Object
(
[_elts:Stripe\Util\Set:private] => Array
(
)
)
[_transientValues:protected] => Stripe\Util\Set Object
(
[_elts:Stripe\Util\Set:private] => Array
(
)
)
[_retrieveOptions:protected] => Array
(
)
[_lastResponse:protected] =>
)
[name] =>
[tokenization_method] =>
)
[_unsavedValues:protected] => Stripe\Util\Set Object
(
[_elts:Stripe\Util\Set:private] => Array
(
)
)
[_transientValues:protected] => Stripe\Util\Set Object
(
[_elts:Stripe\Util\Set:private] => Array
(
)
)
[_retrieveOptions:protected] => Array
(
)
[_lastResponse:protected] =>
)
[source_transfer] =>
[statement_descriptor] =>
[status] => succeeded
[transfer_group] =>
)
[_unsavedValues:protected] => Stripe\Util\Set Object
(
[_elts:Stripe\Util\Set:private] => Array
(
)
)
[_transientValues:protected] => Stripe\Util\Set Object
(
[_elts:Stripe\Util\Set:private] => Array
(
)
)
[_retrieveOptions:protected] => Array
(
)
[_lastResponse:protected] => Stripe\ApiResponse Object
(
[headers] => Array
(
[Server] => nginx
[Date] => Sat, 01 Apr 2017 10:25:47 GMT
[Content-Type] => application/json
[Content-Length] => 1926
[Connection] => keep-alive
[Access-Control-Allow-Credentials] => true
[Access-Control-Allow-Methods] => GET, POST, HEAD, OPTIONS, DELETE
[Access-Control-Allow-Origin] => *
[Access-Control-Max-Age] => 300
[Cache-Control] => no-cache, no-store
[Request-Id] => req_AOWT4rpoHd0H0A
[Stripe-Version] => 2017-02-14
[Strict-Transport-Security] => max-age=31556926; includeSubDomains
)
[body] => {
"id": "ch_1A3jQVG5CbtVORSys2Ho0vYD",
"object": "charge",
"amount": 5600,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"balance_transaction": "txn_1A3jQVG5CbtVORSyduH3NX76",
"captured": true,
"created": 1491042347,
"currency": "usd",
"customer": null,
"description": "hello world",
"destination": null,
"dispute": null,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {
"name": "kartik",
"exp_month": "03",
"exp_year": "25",
"address_zip": "1745236",
"address_line1": "palampur",
"phone": "8956235689",
"cvv": "123"
},
"on_behalf_of": null,
"order": null,
"outcome": {
"network_status": "approved_by_network",
"reason": null,
"risk_level": "normal",
"seller_message": "Payment complete.",
"type": "authorized"
},
"paid": true,
"receipt_email": null,
"receipt_number": null,
"refunded": false,
"refunds": {
"object": "list",
"data": [],
"has_more": false,
"total_count": 0,
"url": "/v1/charges/ch_1A3jQVG5CbtVORSys2Ho0vYD/refunds"
},
"review": null,
"shipping": null,
"source": {
"id": "card_1A3jQSG5CbtVORSysMV7SyBs",
"object": "card",
"address_city": null,
"address_country": null,
"address_line1": null,
"address_line1_check": null,
"address_line2": null,
"address_state": null,
"address_zip": null,
"address_zip_check": null,
"brand": "Visa",
"country": "US",
"customer": null,
"cvc_check": "pass",
"dynamic_last4": null,
"exp_month": 3,
"exp_year": 2025,
"fingerprint": "EJUqgq2clF6JUp8f",
"funding": "credit",
"last4": "4242",
"metadata": {},
"name": null,
"tokenization_method": null
},
"source_transfer": null,
"statement_descriptor": null,
"status": "succeeded",
"transfer_group": null
}
[json] => Array
(
[id] => ch_1A3jQVG5CbtVORSys2Ho0vYD
[object] => charge
[amount] => 5600
[amount_refunded] => 0
[application] =>
[application_fee] =>
[balance_transaction] => txn_1A3jQVG5CbtVORSyduH3NX76
[captured] => 1
[created] => 1491042347
[currency] => usd
[customer] =>
[description] => hello world
[destination] =>
[dispute] =>
[failure_code] =>
[failure_message] =>
[fraud_details] => Array
(
)
[invoice] =>
[livemode] =>
[metadata] => Array
(
[name] => kartik
[exp_month] => 03
[exp_year] => 25
[address_zip] => 1745236
[address_line1] => palampur
[phone] => 8956235689
[cvv] => 123
)
[on_behalf_of] =>
[order] =>
[outcome] => Array
(
[network_status] => approved_by_network
[reason] =>
[risk_level] => normal
[seller_message] => Payment complete.
[type] => authorized
)
[paid] => 1
[receipt_email] =>
[receipt_number] =>
[refunded] =>
[refunds] => Array
(
[object] => list
[data] => Array
(
)
[has_more] =>
[total_count] => 0
[url] => /v1/charges/ch_1A3jQVG5CbtVORSys2Ho0vYD/refunds
)
[review] =>
[shipping] =>
[source] => Array
(
[id] => card_1A3jQSG5CbtVORSysMV7SyBs
[object] => card
[address_city] =>
[address_country] =>
[address_line1] =>
[address_line1_check] =>
[address_line2] =>
[address_state] =>
[address_zip] =>
[address_zip_check] =>
[brand] => Visa
[country] => US
[customer] =>
[cvc_check] => pass
[dynamic_last4] =>
[exp_month] => 3
[exp_year] => 2025
[fingerprint] => EJUqgq2clF6JUp8f
[funding] => credit
[last4] => 4242
[metadata] => Array
(
)
[name] =>
[tokenization_method] =>
)
[source_transfer] =>
[statement_descriptor] =>
[status] => succeeded
[transfer_group] =>
)
[code] => 200
)
)
here
I had the same problem. Return from PHP should be:
echo (json_encode(variable));
This will give you results you can use
Related
I am unsuccessfully trying to drop logs based on the value of the kv value field.
filter {
if [type] == "cef" {
mutate {
add_field => { "tmp_message" => "%{message}" }
split => ["message", "|"]
add_field => { "version" => "%{message[0]}" }
add_field => { "device_vendor" => "%{message[1]}" }
add_field => { "device_product" => "%{message[2]}" }
add_field => { "device_version" => "%{message[3]}" }
add_field => { "sig_id" => "%{message[4]}" }
add_field => { "sig_name" => "%{message[5]}" }
add_field => { "sig_severity" => "%{message[6]}" }
}
kv {
field_split => " "
trim_value => "<>\[\],"
}
mutate {
replace => { "message" => "%{tmp_message}" }
remove_field => [ "tmp_message" ]
}
}
if [FTNTFGTsrcintfrole_s] == "wan" {
drop { }
}
[FTNTFGTsrcintfrole_s] is one of the keys that are parsed out by kv. If the value of the key is "wan", it should drop the log. That's not happening.
How can I filter out those logs?
Edit: Here is an example of the parsed data
{
"dst" => "xxx.xxx.xxx.xxx",
"FTNTFGTtz" => "+0000",
"FTNTFGTsubtype" => "forward",
"message" => "%{tmp_message}",
"host" => "xxx.xxx.xxx.xxx",
"spt" => "59975",
"type" => "cef",
"deviceInboundInterface" => "ssl.root",
"FTNTFGTdstintfrole" => "wan",
"FTNTFGTduration" => "180",
"FTNTFGTdstcountry" => "United",
"FTNTFGTpolicyid" => "47",
"FTNTFGTpolicytype" => "policy",
"FTNTFGTpoluuid" => "801d40c2-3b60-51ea-d66a-293bf886d27e",
"FTNTFGTeventtime" => "1633506791693710149",
"sourceTranslatedAddress" => "xxx.xxx.xxx.xxx",
"dpt" => "8253",
"app" => "udp/8253",
"FTNTFGTpolicyname" => "xxxxxxxx",
"tags" => [
[0] "fortigate",
[1] "_mutate_error"
],
"act" => "accept",
"FTNTFGTlogid" => "0000000013",
"in" => "64",
"sourceTranslatedPort" => "59975",
"FTNTFGTsentpkt" => "1",
"FTNTFGTtrandisp" => "snat",
"FTNTFGTsrcintfrole" => "wan",
"#version" => "1",
"FTNTFGTrcvdpkt" => "1",
"deviceExternalId" => "xxxxx",
"FTNTFGTauthserver" => "xxxxx",
"#timestamp" => 2021-10-06T07:53:11.729Z,
"FTNTFGTsrccountry" => "Reserved",
"deviceOutboundInterface" => "wan1",
"proto" => "17",
"out" => "48",
"src" => "xxx.xxx.xxx.xxx",
"externalId" => "870512",
"FTNTFGTlevel" => "notice",
"FTNTFGTvd" => "root",
"duser" => "xxxxx",
"cat" => "traffic:forward",
"FTNTFGTappcat" => "unscanned"
}
I found the answer thanks to #YLR and #Filip. The SIEM was adding "_s" to the key name when creating the field leading me to believe that that was the original key name and in turn what I was filtering for. After seeing the log output and realizing that wasn't the case, I corrected the filter and it worked.
I'm trying to figure out how to store metadata directly into a Stripe CC payments subscription. I'm using the PHP SDK and have:
$test = $stripe->checkout->sessions->create([
'customer_email' => $_GET["who"],
'success_url' => $success_url,
'payment_method_types' => ['card'],
'cancel_url' => "https://www.example.com",
'line_items' => [
[
'price' => $price_plan_id,
'quantity' => 1,
],
],
'payment_intent_data' => [
'metadata' => [
'who' => $_GET["who"],
'total' => $_GET["total"],
'period' => $_GET["period"],
'description' => $_GET["description"],
'district' => $_GET["district"],
'what' => $_GET["what"],
'ip' => $_SERVER["REMOTE_ADDR"]
]
],
'mode' => $mode 'subscription',
]);
This gives me an error:
You can not pass payment_intent_data in subscription mode.
I've tried just doing:
$test = $stripe->checkout->sessions->create([
'customer_email' => $_GET["who"],
'success_url' => $success_url,
'payment_method_types' => ['card'],
'cancel_url' => "https://www.example.com",
'line_items' => [
[
'price' => $price_plan_id,
'quantity' => 1,
],
],
'metadata' => [
'who' => $_GET["who"],
'total' => $_GET["total"],
'period' => $_GET["period"],
'description' => $_GET["description"],
'district' => $_GET["district"],
'what' => $_GET["what"],
'ip' => $_SERVER["REMOTE_ADDR"]
],
'mode' => $mode 'subscription',
]);
And while it kind of works, its not assigned to the subscription (when you view it metadata is empty)
How do I go passing this along? I want to keep this data stored in the subscription element (not just the payment)
Thanks
You want to pass the metadata on to the resulting Subscription object by setting it in subscription_data.metadata: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-metadata
How get i sort my rows by field i get from model getter like this
* Returns the score for this team
*/
public function getScore() {
$score = 0;
if (!empty($this->bonus_points)) {
$score += $this->bonus_points;
}
foreach (Attempt::find()->where(['team_id' => $this->id, 'marked' => 1])->all() as $attempt) {
$score -= $attempt->cost;
$score += $attempt->reward;
}
return $score;
}
View Code
GridView::widget([
'id' => 'quickfire-grid',
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'filterPosition' => GridView::FILTER_POS_HEADER,
'tableOptions' => [
'class' => 'table'
],
'layout' => "{summary}\n{items}\n{pager}",
'columns' => [
['class' => 'yii\grid\CheckboxColumn'],
'name',
[
'attribute' => 'bonus_points',
'label' => 'Adjustment',
'filter' => false
],
[
'attribute' => 'score',
'label' => 'Score',
'filter' => false,
],
[
'label' => 'Adjust score',
'format' => 'raw',
'value' => function ($data) use ($game) {
return Html::input('text', 'score-' . $data->id, '0', ['id' => 'score-' . $data->id]) . ' ' . Html::a('Adjust score', '#', ['class' => 'btn btn-danger btn-adjust-score', 'data-team-id' => $data->id, 'data-href' => Url::toRoute(['adjust-scores', 'game_id' => $game->id, 'skipConfirmation' => true])]);
},
],
],
]);
Is it possible to sort grid by score field ? I think need to add some javascript code. I have read this article but there is no solution https://www.yiiframework.com/wiki/621/filter-sort-by-calculatedrelated-fields-in-gridview-yii-2-0.
Team::find()->select(['total_score' => 'ifnull(s.score, 0)+team.bonus_points'])
->leftJoin([
's' => Attempt::find()
->select('team_id, SUM(reward-cost) as score')
->where(['marked' => 1])
->groupBy('team_id')
], 's.team_id=team.id')
->orderBy('total_score')
Something like this) Modify select with your needs...
I am facing problem with Logstash KV filter:
Below is sample event:
2016-08-15T12:43:04.478Z 103.240.35.216 <190>date=2016-08-15 time=18:13:16 timezone="IST" device_name="CR25iNG" device_id=C2222-123 log_id=010302602002 log_type="Firewall" log_component="Appliance Access" log_subtype="Denied" status="Deny" priority=Information duration=0 fw_rule_id=0 user_name="" user_gp="" iap=0 ips_policy_id=0 appfilter_policy_id=0 application="" application_risk=0 application_technology="" application_category="" in_interface="PortA" out_interface="" src_mac=44:d9:e7:ba:5b:6c src_ip=172.16.16.19 src_country_code= dst_ip=255.255.255.255 dst_country_code= protocol="UDP" src_port=45541 dst_port=10001 sent_pkts=0 recv_pkts=0 sent_bytes=0 recv_bytes=0 tran_src_ip= tran_src_port=0 tran_dst_ip= tran_dst_port=0 srczonetype="" srczone="" dstzonetype="" dstzone="" dir_disp="" connid="" vconnid=""
Below is the KV filter output:
"#version" => "1",
"#timestamp" => "2016-08-16T13:48:30.602Z",
"type" => "cyberoam.input",
"host" => "ip-172-31-6-249",
"time" => "18:13:16",
"timezone" => "IST",
"status" => "Deny",
"priority" => "Information",
"duration" => "0",
"iap" => "0",
"application" => "",
"application_risk" => "0",
"application_technology" => "",
"application_category" => "",
"dst_country_code" => "protocol=UDP",
"recv_pkts" => "0",
"tran_src_ip" => "tran_src_port=0",
"tran_dst_ip" => "tran_dst_port=0",
"srczonetype" => "",
"srczone" => "",
"dstzonetype" => "",
"dstzone" => "",
"dir_disp" => "",
"syslog_severity_code" => 5,
"syslog_facility_code" => 1,
"syslog_facility" => "user-level",
"syslog_severity" => "notice",
"date" => "2016-08-15",
Problem:
"dst_country_code" => "protocol=UDP",
"tran_src_ip" => "tran_src_port=0",
"tran_dst_ip" => "tran_dst_port=0",
Above is due to empty keys "dst_country_code", "tran_src_ip" and "tran_dst_ip".
I was suggested to use mutate gsub to add default value to empty field by substituting =\w with ="".
But this never worked.
Pleas help.
I got response from Logstash community and that worked.
mutate {
gsub => [ 'message', '= ', '="" ' ]
}
Thanks.
In Kartik Yii2 Export, While exporting as Excel am getting This Page Cant't Reached Error in Localhost.
if i export as Text or CSV, export get worked but if i open the exported file Text or CSV, Half the
report is printing like html code
Help will be really appreciated.
GridCode:
<?php $gridColumns = [
['class' => 'yii\grid\SerialColumn'],
'membercode',
'member_name',
[
'attribute' => 'payment_category',
'format' => 'raw',
'label' => 'Payment Category',
'value' => function($model, $key, $index, $grid) {
$temp = $model->payment_category;
$si = Category::find()->where(['category_id' => $temp])->one();
return $si['category_name'];
},
],
'member_gender',
'member_address:ntext',
'payment_date',
'amount',
'receipt_no',
'payment_mode',
'pledge_amount',
'young_amount',
'tv_amount',
'building_amount',
[
'attribute' => 'payment_subcategory',
'format' => 'raw',
'value' => function($model, $key, $index, $grid) {
$exp = explode(',', $model->payment_subcategory);
$relation_name = ArrayHelper::map(Subcategory::find()->where(['subcategory_id' => $exp])->all(), 'subcategory_id', 'subcategory_name');
$relation = implode(',', $relation_name);
return $relation;
},
'filter' => Html::activeDropDownList($searchModel, 'payment_subcategory', ArrayHelper::map(Subcategory::find()->asArray()->all(), 'id', 'subcategory_name'),['class'=>'form-control','multiple' => true]),
],
['class' => 'yii\grid\ActionColumn'],
]; ?>
<?= ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'columnSelectorOptions'=>[
'label' => 'Columns',
'class' => 'btn btn-danger'
],
'fontAwesome' => true,
'dropdownOptions' => [
'label' => 'Export All',
'class' => 'btn btn-primary'
]
]); ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => $gridColumns,
'pager' => [
'firstPageLabel' => 'First',
'lastPageLabel' => 'Last',
],
]); ?>
Above is my Grid view Code.
Help will be really appreciated.
Updated:
Error geeting while exporting as CSV:
Error geeting while exporting as EXCEL
There is an issue in your gridview, one of the field in gridview carries "=" equal to sign. please check it out PhpOffice/PhpExcel
Try exportConfig settings this
<?= ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'columnSelectorOptions'=>[
'label' => 'Columns',
'class' => 'btn btn-danger'
],
'fontAwesome' => true,
'dropdownOptions' => [
'label' => 'Export All',
'class' => 'btn btn-primary'
]
'exportConfig' => [
ExportMenu::FORMAT_HTML => false,
ExportMenu::FORMAT_TEXT => false,
],
]); ?>
Try this code for your GridVew::Widget:
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => $gridColumns,
'exportConfig'=> [
GridView::CSV=>[
'label' => 'CSV',
'icon' => '',
'iconOptions' => '',
'showHeader' => false,
'showPageSummary' => false,
'showFooter' => false,
'showCaption' => false,
'filename' => 'yii',
'alertMsg' => 'created',
'options' => ['title' => 'Semicolon - Separated Values'],
'mime' => 'application/csv',
'config' => [
'colDelimiter' => ";",
'rowDelimiter' => "\r\n",
],
],
],
]);