Skip to content

Instantly share code, notes, and snippets.

@freddyb2
Last active December 22, 2019 17:17
Show Gist options
  • Save freddyb2/a57a26663f0439bf5855f9ccb0ad49ad to your computer and use it in GitHub Desktop.
Save freddyb2/a57a26663f0439bf5855f9ccb0ad49ad to your computer and use it in GitHub Desktop.
Transfert des pièces d'identité des stooters de Ubble vers Stripe
###########################################################################################
# POC KYC Ubble -> Stripe
# Principe : un message SNS part du service identity-check vers le service payment
# lorsque la vérification d'identité a fonctionné.
###########################################################################################
### SERVICE IDENTITY-CHECK
def documents_attributes(ubble_ident_id)
Ubble::FetchIdentification.perform(ubble_ident_id)['included'].select { |i| i['type'] == 'documents' }.map { |documents| documents['attributes'] }.first
end
ubble_ident_id = '********-****-****-****-************'
documents_attributes = documents_attributes(ubble_ident_id)
first_name = documents_attributes['first-name']
last_name = documents_attributes['last-name']
birth_date = documents_attributes['birth-date'] # format 1990-04-30
id_back_url = documents_attributes['signed-image-back-url']
id_front_url = documents_attributes['signed-image-front-url']
### SERVICE PAYMENT
def upload_file_to_stripe(acct, uri)
path = Tempfile.new.path
IO.copy_stream(open(uri), path)
Stripe::File.create(
{
purpose: 'identity_document',
file: File.new(path),
},
{ stripe_account: acct }
)
end
acct = 'acct_****************'
Stripe::Account.list_persons(acct).map { |person| person.id }.each do |person_id|
birth_date_split = birth_date.split('-')
Stripe::Account.update_person(
acct,
person_id,
{
first_name: first_name,
last_name: last_name,
dob: {
year: birth_date_split[0],
month: birth_date_split[1],
day: birth_date_split[2],
},
verification: {
document: {
back: upload_file_to_stripe(acct, id_back_url).id,
front: upload_file_to_stripe(acct, id_front_url).id,
}
}
},
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment