Stripe: can't remove the email field from paymentElement? - stripe-payments

Has anyone managed to hide the email field in a Stripe paymentElement? This code successfully hides country, but leaves email visible:
const paymentElementOptions = {
layout : 'tabs',
fields : {
billingDetails : {
email : 'never',
address : {
country : 'never'
}
}
}
};
const paymentElement = elements.create('payment', paymentElementOptions);
The docs for billingDetails explicitly say that you can do this (here).
EDIT
I've just downloaded the Stripe demo code for 'Custom payment flow' and confirmed that it has exactly the same problem. Go here, select Web/HTML/Python, Custom payment flow, and the page shows the source code. The JS has 127 lines - replace lines 38-40 (the paymentElementOptions definition) with my code above, and the email field is still visible, but the Country field isn't. It only takes a few minutes to run up the demo from the download, if you've got Python 3.6+ installed, and the Python stripe package:
$ cd ~/Downloads/whatever
$ unzip stripe-sample-code.zip
$ export FLASK_APP=server.py
$ python3 -m flask run --port=4242
Now browse to http://localhost:4242/checkout.html.

Related

Groovy script for scriptrunner not sending emails

I have a working Groovy script provided by app vendor. I need help modify it a little so it will send an email to our DL with the list of accounts it process.
I don't have any knowledge of Groovy.
Can some one please assist? Groovy provided below:
package examples
{{{{{
import com.atlassian.confluence.security.login.LoginManager
import com.atlassian.confluence.user.UserAccessor
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.user.GroupManager
import com.atlassian.confluence.user.ConfluenceUser
import com.onresolve.scriptrunner.parameters.annotation.GroupPicker
import com.onresolve.scriptrunner.parameters.annotation.NumberInput
#NumberInput(label = 'Maximum users', description = 'The maximum number of users to allow in Confluence')
Integer maximumUsers
#GroupPicker(label = 'User group', description = 'The group of users to check (e.g. "confluence-users")')
Group selectedUserGroup
#GroupPicker(label = 'Deactivated user group', description = 'The group to add the deactivated users to (e.g. "deactivated-users"')
Group selectedDeactivatedGroup
def groupManager = ComponentLocator.getComponent(GroupManager)
def loginManager = ComponentLocator.getComponent(LoginManager)
def userAccessor = ComponentLocator.getComponent(UserAccessor)
// Set defaults in case the fields are not filled out
maximumUsers = maximumUsers ?: 500
def userGroup = selectedUserGroup ? groupManager.getGroup(selectedUserGroup.name) : groupManager.getGroup('confluence-users')
def deactivatedGroup = selectedDeactivatedGroup ? groupManager.getGroup(selectedDeactivatedGroup.name) : groupManager.getGroup('deactivated-users') ?: groupManager.createGroup('deactivated-users')
// Get all users from the selected user group
def users = userAccessor.getMembers(userGroup).asList()
// For the users found in the selected group, sort the users by last login date
Map<ConfluenceUser, Date> userWithLoginDate =
users.collectEntries {
[(it): (loginManager.getLoginInfo(it)?.lastSuccessfulLoginDate)]
}.sort { it -> it.value }
// Get all user keys
def sortedUsers = userWithLoginDate*.key
// Deactivate user accounts and add them to the deactivated group if the user list size is more than the allowed amount
if (sortedUsers.size() > maximumUsers) {
def deactivated = sortedUsers.subList(0, sortedUsers.size() - maximumUsers)
deactivated.each { user ->
groupManager.removeMembership(userGroup, user)
groupManager.addMembership(deactivatedGroup, user)
userAccessor.deactivateUser(user)
}
}
//Good to Know
//
// If you want this listener to run when a new user is added, you must also add the UserCreateEvent in the 'Events' field.
// When you add this as a listener, you need to provide a value for the 'Maximum users' field to define the maximum number of users you want to allow on your instance.
// The script uses the 'User group' field to search for users to deactivate. You will likely want to select the 'confluence-users' group, but you are free to select use any group.
// You will need to create a group for the deactivated users to be added to and then select that group for the 'Deactivated user group' field.
}}}}}
This Groovy script will be inserted into Script Runner which is installed in Atlassian Confluence.
I have the groovy and **I need help with it working to parse users that have not logged in for 90days and up.
Then send an email with the list.**
Script will auto disable those accounts.
I have no knowledge of Groovy/java.

Read Only Form Filling - PDFTron

I'm using WebViewer [1] from PDFTron to fill Form Fields in a PDF on Web [2]. There's a way to make some fields in Read Only Mode, so the user will not be able to add text to textfield, check the checkboxes?
I found this page on the documentation [3] but it seems that I can only set document in read only mode, instead I want only custom fields in read only, users will be able to fill some fields and not others.
I found also this page [4] on doc to set fields to readonly but in my case on WebViewer it doesn't work, in my browser the viewerLoaded events never get called; I tried to put the code in another part of the code but nothing happens.
Are there some hints or some working code that you guys use?
Thanks, Alberto
[1] https://www.pdftron.com/webviewer
[2] https://www.pdftron.com/pdf-sdk/form-filler
[3] https://www.pdftron.com/documentation/web/guides/annotations/annotation-permissions?searchTerm=readon#readonly-mode
[4] https://www.pdftron.com/documentation/web/guides/advanced/forms#set-fields-to-readonly
I managed to make it work with a modified version of this code [1]. The final result is:
$(document).on('documentLoaded', function() {
var docViewer = myWebViewer.getInstance().docViewer;
var annotManager = docViewer.getAnnotationManager();
annotManager.on('annotationChanged', function(e, annotations, action) {
// if the annotation change occurs because of an import then
// these are fields from inside the document
if (action === 'add' && e.imported) {
annotations.forEach(function(annot) {
if(annot.fieldName == 'read_only_field_name'){
annot.fieldFlags.set('ReadOnly', true);
}
});
}
});
});
[1] https://www.pdftron.com/documentation/web/guides/advanced/forms#set-fields-to-readonly

Retrieving currently logged in user's title/salutation fails

In NetSuite SuiteCommerce Advanced I am attempting to get the currently logged in users title (Mr, Mrs, etc.).
I am using the Commerce API and the function Customer::getFieldValues(). I am retrieving the column/field name salutation. When I execute this function it returns an empty object when it should return the users title/salutation. Note: I have confirmed the user has a title/salutation set as 'Mr'.
Any advice why SCA is not returning the user's title? This is sooo annoying of NS!
*Modules\MyOverrides\ProfileOverrides#1.0.0\SuiteScript\Profile.Model.js:
define('Profile.Model',['SC.Model', 'underscore', 'Utils'], function (SCModel, _, Utils)
{
'use strict';
return SCModel.extend({
name: 'Profile'
, get: function ()
{
//You can get the profile information only if you are logged in.
if (this.isLoggedIn && this.isSecure)
{
// Retrieve the currently logged in users saluation (eg Sir, Mr, Mrs, etc.)
// Why on earth does NS not return this!!!
var profile = customer.getFieldValues(['salutation']);
console.log("PROFILE", profile); // outputs "PROFILE {}"
...
*Edit: I incorrectly stated the file was
Modules\MyOverrides\AccountOverrides#1.0.0\SuiteScript\Account.Model.js: when it is actually Modules\MyOverrides\ProfileOverrides#1.0.0\SuiteScript\Profile.Model.js.

Get GitHub avatar from email or name

I'm trying to get the GitHub user picture (avatar) from users of GitHub.
I've found these API:
https://avatars.githubusercontent.com/<username>
https://avatars.githubusercontent.com/u/<userid>
But I can't find a way to get the avatar from the user email or the user display name.
I can't find documentation about that.
Is there some similar URL API to get what I'm looking for?
You can append .png to the URL for the User's profile to get redirected to their avatar. You can add the query param size to specify a size smaller than the default of 460px wide (i.e. it won't allow larger than 460).
Examples:
https://github.com/twbs.png
https://github.com/npm.png?size=200
https://github.com/github.png?size=40
https://developer.github.com/v3/users/#get-a-single-user
Use the /users/:user endpoint. Should be under avatar_url in the returned json.
For example, my avatar_url can be found by hitting this url.
Edit
There is another way I can think of that is kind of roundabout. Since GitHub uses Gravatar, if you know the email associated with the account, do an md5 hash of the lowercase, stripped email address and construct a url like http://www.gravatar.com/avatar/[md5_here].
This is an old post but nobody has proposed Github Search Users API with scope field :
using in:email : https://api.github.com/search/users?q=bmartel+in%3Aemail
using in:username : https://api.github.com/search/users?q=Bertrand+Martel+in%3Ausername
Or using new Graphql API v4 :
{
search(type: USER, query: "in:email bmartel", first: 1) {
userCount
edges {
node {
... on User {
avatarUrl
}
}
}
}
}
Using GraphQL API v4, this will work too
Query (for username)-
{
user(login: "username") {
avatarUrl
}
}
Response -
{
"data": {
"user": {
"avatarUrl": "https://avatars1.githubusercontent.com/u/..."
}
}
}
GitHub avatar can be accessed through https://avatars.githubusercontent.com/u/YOUR_USER_ID
Optionally, you can modify the size at the end like so https://avatars.githubusercontent.com/u/YOUR_USER_ID?s=460

Couchdb and Sofa Help

I'm new to Couchdb just a few week back I git clone the couchdb app called sofa [what and app] . Over the week It was going great but suddenly today I stumble upon something.
Here what I meant
when I browse the Sofa app and try to create a Post without the title
it prompt with and alert box "The document could not be saved: The database could not be created, the file already exists." which was weird as looking at the source I found that the require (in validate_doc_update.js return its custom json error) something like in this format {"forbidden" : message }) with forbidden as key
v.forbidden = function(message) {
throw({forbidden : message})
};
v.require = function() {
for (var i=0; i < arguments.length; i++) {
var field = arguments[i];
message = "The '"+field+"' field is required.";
if (typeof newDoc[field] == "undefined") v.forbidden(message);
};
};
in validate_doc_update.js
if (newDoc.type == 'post') {
if (!v.isAuthor()) {
v.unauthorized("Only authors may edit posts.");
}
v.require("created_at", "author", "body", "format", "title");
inspecting the response state that the json returned was found to be different from the json had it would have been return by the above require function in validate_doc_update.js
here is the json
{"error":"file_exists","reason":"The database could not be created, the file already exists."}
This make be believe that the validation in validation_doc_update.js only execute during updating of document
to Prove this point I try to update a document without the title, expecting that it would return the error but surprisingly the document just got saved
so Here are my Question regarding all the Point I mention above
Does validate_doc_update.js "validate" work only during updation of document
if YES
then
how can I manage to succeed in updating a post without the error [Weird bypassing the Validation Completely] . + How can execute validation on create of a document
if NO
then
What is the Error {"error":"file_exists","reason":"The database could not be created, the file already exists."} that is prevent a document to be saved
Can anyone please share light on all the questions listed here
Yes, the validate_doc_update functions are run only when updating documents (include creation and deletion).
The function you show here will allow a document without a title as long as its type is not "post". If you could include the actual request you attempted, I could confirm it.
Finally, the ""The database could not be created" is because you are attempting to create the database (by doing PUT /dbname/ instead of PUT /dbname/docid, I would guess) when it already exists. Again, if you would include the actual request, I could confirm that too.

Resources