I have been using Stripe inside my Django project with no problems so far, everything is working, however I am confused about the payment_method parameter. At the moment I have it set to pm_card_visa because that's what the documentation told me to do, however I believe this is causing me problems as when I put in a dummy Mastercard number that Stripe gives you, it is still defaulting to use the default 4242 4242 4242 card.
How can I dynamically set the payment_method variable?
pm_card_visa is a 'shortcut' to the 4242424242424242 test card. You instead need to put in whatever Payment Method ID you get from Elements. https://stripe.com/docs/payments/accept-a-payment
$create = $stripe->paymentIntents->create([
'amount' => 100,
'currency' => 'usd',
'payment_method_types' => ['card'],
]);
$id = $create->id;
$method = $stripe->paymentMethods->create([
'type' => 'card',
'card' => [
'number' => '4242424242424242',
'exp_month' => 12),
'exp_year' => 2022 ),
'cvc' => '314',
],
]);
$payment = $stripe->paymentIntents->confirm(
$id,
['payment_method' => $method]
);
Related
I am developing one API which is responsible for registering the users and the data should store in database upto this part it's working fine, i want to add regex patterns for validation part ,for example if the user mobile number not matches with the regex pattern then it should return a response like Please enter valid mobile number like this i want How to acheive this thing please help me ..
UserController.php
public function Registration(Request $request){
$this->validate($request, [
'firstName'=>'required|string|between:3,15',
'email'=>'required|email',
'password'=>'required|regex:/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!#$%^&*-]).{6,}$/',
'mobile'=>'required|digits:10',
]);
$admin = new AdminModel([
'firstName' => $request->input('firstName'),
'email' => $request->input('email'),
'password' => bcrypt($request->input('password')),
'mobile' => $request->input('mobile'),
]);
$admin->save();
return response()->json(['message' => 'Admin registered successfully']);
}
Add validation messages
$this->validate($request, [
'firstName'=>'required|string|between:3,15',
'email'=>'required|email',
'password'=>'required|regex:/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!#$%^&*-]).{6,}$/',
'mobile'=>'required|digits:10',
],[
'mobile.required' => 'Please enter mobile number',
'mobile.digits' => 'Please enter valid mobile number',
]);
I have the Problem when creating an salesorder with Vtiger Webservice,
The sales order is created but somehow the tax is not added.
I thought it has something to do with the parameter : hdnTaxType
Cause even if I add this value 'group' it does not apply the Tax to the Salesorder.
I have to manually add The Taxtype 'group' then the system adds the tax.
thats why i tried to add values like:
'tax1' => '7.00',
and
'group_tax' =>[
'group_tax_percentage1' => '7.0'
],
nothing so far did help...
has anybody an Idea what the problem is?
Thank you
Tobi
$salesOrder =[
'lastname' => $customer['lastname'],
'subject' => 'Order from 01.01.1018',
'sostatus' => '1',
'assigned_user_id' => '',
'bill_street' => 'Rechunngsstrasse 123',
'ship_street' =>'Lieferungsstrasse 123',
'productid' => '14x4325',
'currency_id' => '21x1',
'carrier' => 'DHL',
'txtAdjustment' => '13',
'salescommission' => '12',
'exciseduty' => '15',
'hdnTaxType' => 'group',
'tax1' => '7.00',
'hdnS_H_Amount' => '22.22',
'group_tax' =>[
'group_tax_percentage1' => '7.0'
],
'LineItems' => [
0 => [
"taxid" => "33x1",
'productid'=>'14x6',
'listprice'=>'20.53',
'quantity'=>'3',
'comment' => "Product123"
]
]
Webservices in Vtiger are not complete.
In this case you can register your own webservice that makes your queries, or check the SalesOrder in the after-save event
In custom validation as shown below:
'custom' => array(
'attribute-name' => array(
'rule-name' => 'custom-message',
),
),
How is it possible to define regex along with the attribute-name-{regex} as well?!
Example:
'custom' => array(
'institute_regex:{/d{1}}' => array(
'required' => 'the field is required',
),
),
I think that might be what you were looking for ages ago, but anyway, here is what I did.
Had to find a way to define custom validation messages (in another language) for inputs dynamically generated in the frontend. The result is that I would get the following type of classes:
project_name-1, -2, -3 etc to keep it simple.
So what I did, and it worked just fine for me was adding the following lines to my validation.php file (whatever the language is):
'project_name-*' => [
'required' => 'Please name your project.',
],
And voilĂ , I hope it will help someone!
In my CakePHP, my routes.php file looks like this:
Router::connect('/premios/:category',
array('controller' => 'prizes', 'action' => 'category'),
array(
'category' => '\bmarcas|restaurantes|combustibles|peluqueria\b',
));
This way whenever a user enters the /premios url, the next parameter is matched with the "category" regex. This works perfect.
The problem is that when I want to generate a pretty url for the category, let's say, "peluqueria", using this line of code generates a "non-pretty" url:
Router::url(array('controller' => 'prizes', 'action' => 'category', 'peluqueria')); ?>
Instead of generating a pretty URL (/premios/peluqueria) it generates a non pretty url (/prizes/category/peluqueria).
What am I doing wrong? Or is this a limitation of the Router::url function?
A workaround would be to define every connect, avoiding the regex, but it isn't a pretty as the current solution plus it would get annoying when the categories count start to grow.
Any ideas?
You have to actually name the category parameter in Router::url, like this
Router::url(array('controller' => 'prizes',
'action' => 'category',
'category' => 'peluqueria'));
And you'd probably want to pass that "category" parameter to the category action in Prizes, so you're missing something
Router::connect(
'/premios/:category',
array('controller' => 'prizes', 'action' => 'category'),
array(
'pass' => array('category'),
'category' => '\bmarcas|restaurantes|combustibles|peluqueria\b'
)
);
Look this part of the docs with more detention :)
Realtime updates are kicking my ass! I have my entire fb app working except for this one area and I'm just not sure what I'm doing wrong.
My app is approved using these permissions:
"scope" => "offline_access,publish_stream,read_stream,user_location,user_status",
Next, I subscribe using these settings:
$subscribe = array( 'access_token'=> substr($my_access_token,13),
'object' => 'user',
'fields' => 'name,feed',
'callback_url' => $fbconfig['callback'],
'verify_token' => $fbconfig['secret']);
Via my app I post a status update on behaf of Bill Smith (userid: 000041143) and
that appears on Bill Smith's wall just fine. Next, using a an account for John
Doe (userid: 000004842 which has NOT authorized my app) I comment on the status post
made on Bill Smith's wall and this triggers the callback but what I'm getting (see below)
is an entry telling me that John Doe's wall has changed and no mention of Bill Smiths
wall is ever made.
Here's the notification given in the callback:
updates = Array
(
[object] => user
[entry] => Array
(
[0] => Array
(
[uid] => 000004842
[id] => 000004842
[time] => 1325101631
[changed_fields] => Array
(
[0] => feed
)
)
[1] => Array
(
[uid] => 000004842
[id] => 000004842
[time] => 1325101651
[changed_fields] => Array
(
[0] => feed
)
)
)
)
As you can see, this is not a notification that a comment has been made to Bill Smiths wall but that one has been made to John Doe's... I dont get this... I must be doing SOMETHING wrong!
I had similar issues before with photo IDs turning up 'wrong', the issue occurred because I was treating it as an INT but PHP was truncating it because it was too big, I had to treat it as a string. Could this be your issue perhaps?