Skip to content
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project overview
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
284
Merge Requests
39
CI / CD
Security & Compliance
Packages
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
50321c92
Commit
50321c92
authored
1 hour ago
by
Mark Harding
Committed by
Mark Harding
1 hour ago
Browse files
Options
Download
(fix): additional stripe steps and ability to add phone number
parent
000d4b1a
fix/stripe-requirements
1 merge request
!420
Additional stripe steps and ability to add phone number
Pipeline
#102329390
passed with stages
in 7 minutes and 19 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
155 additions
and
47 deletions
+155
-47
Controllers/Cli/Stripe.php
View file @
50321c92
...
...
@@ -67,4 +67,55 @@ class Stripe extends Cli\Controller implements Interfaces\CliControllerInterface
$intent
=
$intentManager
->
get
(
$id
);
var_dump
(
$intent
);
}
public
function
fix_connect
()
{
$connectManager
=
new
Core\Payments\Stripe\Connect\Manager
();
$i
=
0
;
foreach
(
$connectManager
->
getList
()
as
$account
)
{
++
$i
;
echo
"
\n
$i
$account->id
"
;
var_dump
(
$account
->
requirements
->
currently_due
);
}
}
public
function
remove_business_type
()
{
$connectManager
=
new
Core\Payments\Stripe\Connect\Manager
();
$account
=
$connectManager
->
getByAccountId
(
$this
->
getOpt
(
'id'
));
$connectManager
->
update
(
$account
);
}
public
function
create_stripe_lookups
()
{
$connectManager
=
new
Core\Payments\Stripe\Connect\Manager
();
$iterator
=
new
Core\Analytics\Iterators\SignupsOffsetIterator
();
$iterator
->
token
=
$this
->
getOpt
(
'token'
);
$i
=
0
;
$s
=
0
;
foreach
(
$iterator
as
$user
)
{
if
(
!
$user
instanceof
Entities\User
)
{
continue
;
}
++
$i
;
var_dump
(
$user
->
getMerchant
());
if
(
$stripeId
=
$user
->
getMerchant
()[
'id'
])
{
++
$s
;
}
echo
"
\n
$s
/
$i
$user->guid
{
$stripeId
}
(
$iterator->token
)"
;
if
(
!
$stripeId
)
{
continue
;
}
try
{
$account
=
$connectManager
->
getByAccountId
(
$stripeId
);
$account
->
setEmail
(
$user
->
getEmail
());
$account
->
setUrl
(
'https://www.minds.com/'
.
$user
->
username
);
$account
->
setMetadata
([
'guid'
=>
(
string
)
$user
->
guid
,
]);
$connectManager
->
update
(
$account
);
}
catch
(
\Exception
$e
)
{
}
}
}
}
This diff is collapsed.
Controllers/api/v2/payments/stripe/connect/
photoid
.php
→
Controllers/api/v2/payments/stripe/connect/
document
.php
View file @
50321c92
...
...
@@ -12,7 +12,7 @@ use Minds\Core\Session;
use
Minds\Interfaces
;
use
Minds\Core\Payments\Stripe
;
class
photoid
implements
Interfaces\Api
class
document
implements
Interfaces\Api
{
public
function
get
(
$pages
)
{
...
...
@@ -21,11 +21,20 @@ class photoid implements Interfaces\Api
public
function
post
(
$pages
)
{
$documentType
=
$pages
[
0
]
??
null
;
if
(
!
$documentType
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'/:documentType must be provided'
,
]);
}
$user
=
Session
::
getLoggedInUser
();
$connectManager
=
new
Stripe\Connect\Manager
();
$account
=
$connectManager
->
getByUser
(
$user
);
$fp
=
fopen
(
$_FILES
[
'file'
][
'tmp_name'
],
'r'
);
$connectManager
->
add
PhotoId
(
$account
,
$fp
);
$connectManager
->
add
Document
(
$account
,
$fp
,
$documentType
);
return
Factory
::
response
([
'account_id'
=>
$account
->
getId
()
]);
}
...
...
This diff is collapsed.
Core/Payments/Stripe/Connect/Manager.php
View file @
50321c92
...
...
@@ -82,14 +82,14 @@ class Manager
}
if
(
$account
->
getPhoneNumber
())
{
$data
[
'individual'
][
'phone'
]
=
$account
->
getPhoneNumber
();
$data
[
'individual'
][
'phone'
]
=
"+"
.
$account
->
getPhoneNumber
();
}
// US 1099 requires SSN
if
(
$account
->
getSSN
())
{
$data
[
'individual'
][
'ssn_last_4'
]
=
$account
->
getSSN
();
$data
[
'requested_capabilities'
]
=
[
'card_payments'
,
'transfers'
];
$data
[
'requested_capabilities'
]
=
[
'
legacy_payments'
,
'
card_payments'
,
'transfers'
];
}
if
(
$account
->
getPersonalIdNumber
())
{
...
...
@@ -132,46 +132,59 @@ class Manager
{
try
{
$stripeAccount
=
$this
->
accountInstance
->
retrieve
(
$account
->
getId
());
if
(
$stripeAccount
->
individual
->
verification
->
status
!==
'verified'
)
{
$stripeAccount
->
individual
->
first_name
=
$account
->
getFirstName
();
$stripeAccount
->
individual
->
last_name
=
$account
->
getLastName
();
if
(
$stripeAccount
->
legal_entity
->
verification
->
status
!==
'verified'
)
{
$stripeAccount
->
legal_entity
->
first_name
=
$account
->
getFirstName
();
$stripeAccount
->
legal_entity
->
last_name
=
$account
->
getLastName
();
$stripeAccount
->
legal_entity
->
address
->
city
=
$account
->
getCity
();
$stripeAccount
->
legal_entity
->
address
->
line1
=
$account
->
getStreet
();
$stripeAccount
->
legal_entity
->
address
->
postal_code
=
$account
->
getPostCode
();
$stripeAccount
->
legal_entity
->
address
->
state
=
$account
->
getState
();
$stripeAccount
->
individual
->
address
->
city
=
$account
->
getCity
();
$stripeAccount
->
individual
->
address
->
line1
=
$account
->
getStreet
();
$stripeAccount
->
individual
->
address
->
postal_code
=
$account
->
getPostCode
();
$stripeAccount
->
individual
->
address
->
state
=
$account
->
getState
();
$dob
=
explode
(
'-'
,
$account
->
getDateOfBirth
());
$stripeAccount
->
legal_entity
->
dob
->
day
=
$dob
[
2
];
$stripeAccount
->
legal_entity
->
dob
->
month
=
$dob
[
1
];
$stripeAccount
->
legal_entity
->
dob
->
year
=
$dob
[
0
];
$stripeAccount
->
individual
->
dob
->
day
=
$dob
[
2
];
$stripeAccount
->
individual
->
dob
->
month
=
$dob
[
1
];
$stripeAccount
->
individual
->
dob
->
year
=
$dob
[
0
];
if
(
$account
->
getGender
())
{
$stripeAccount
->
legal_entity
->
gender
=
$account
->
getGender
();
$stripeAccount
->
individual
->
gender
=
$account
->
getGender
();
}
if
(
$account
->
getPhoneNumber
())
{
$stripeAccount
->
legal_entity
->
phone_number
=
$account
->
getPhoneNumber
();
$stripeAccount
->
individual
->
phone
=
$account
->
getPhoneNumber
();
}
}
else
{
if
(
!
$stripeAccount
->
legal_entity
->
ssn_last_4_provided
&&
$account
->
getSSN
())
{
$stripeAccount
->
legal_entity
->
ssn_last_4
=
$account
->
getSSN
();
if
(
!
(
$stripeAccount
->
individual
->
ssn_last_4i
??
null
)
&&
$account
->
getSSN
())
{
$stripeAccount
->
individual
->
ssn_last_4
=
$account
->
getSSN
();
}
if
(
!
$account
->
legal_entity
->
personal_
id_number_provided
&&
$account
->
getPersonalIdNumber
())
{
$account
->
legal_entity
->
personal_
id_number
=
$account
->
getPersonalIdNumber
();
if
(
!
$account
->
individual
->
id_number_provided
&&
$account
->
getPersonalIdNumber
())
{
$account
->
individual
->
id_number
=
$account
->
getPersonalIdNumber
();
}
}
if
(
$account
->
getAccountNumber
())
{
/*
if ($account->getAccountNumber()) {
$stripeAccount->external_account->account_number = $account->getAccountNumber();
}
if ($account->getRoutingNumber()) {
$stripeAccount->external_account->routing_number = $account->getRoutingNumber();
}*/
if
(
$account
->
getEmail
())
{
$stripeAccount
->
individual
->
email
=
$account
->
getEmail
();
}
if
(
$account
->
getUrl
())
{
$stripeAccount
->
business_profile
->
url
=
$account
->
getUrl
();
}
if
(
$account
->
getPhoneNumber
())
{
$stripeAccount
->
individual
->
phone
=
$account
->
getPhoneNumber
();
}
$stripeAccount
->
metadata
=
$account
->
getMetadata
();
$stripeAccount
->
save
();
}
catch
(
\Exception
$e
)
{
throw
new
\Exception
(
$e
->
getMessage
());
...
...
@@ -230,17 +243,28 @@ class Manager
}
/**
* Add
photo Id
* Add
document
* @param Account $account
* @param resource $file
* @param string $documentType
* @return bool
*/
public
function
add
PhotoId
(
Account
$account
,
$fil
e
)
:
bool
public
function
add
Document
(
Account
$account
,
$file
,
string
$documentTyp
e
)
:
bool
{
return
(
bool
)
$this
->
fileInstance
->
create
([
$fileId
=
$this
->
fileInstance
->
create
([
'purpose'
=>
'identity_document'
,
'file'
=>
$file
,
],
[
'stripe_account'
=>
$account
->
getId
()
]);
return
(
bool
)
$this
->
accountInstance
->
update
(
$account
->
getId
(),
[
'individual'
=>
[
'verification'
=>
[
$documentType
=>
[
'front'
=>
$fileId
,
],
],
]
]);
}
/**
...
...
@@ -252,41 +276,37 @@ class Manager
{
try
{
$result
=
$this
->
accountInstance
->
retrieve
(
$id
);
$account
=
(
new
Account
())
->
setId
(
$result
->
id
)
->
setStatus
(
'active'
)
->
setCountry
(
$result
->
country
)
->
setFirstName
(
$result
->
legal_entity
->
first_name
)
->
setLastName
(
$result
->
legal_entity
->
last_name
)
->
setGender
(
$result
->
legal_entity
->
gender
)
->
setDateOfBirth
(
$result
->
legal_entity
->
dob
->
year
.
'-'
.
str_pad
(
$result
->
legal_entity
->
dob
->
month
,
2
,
'0'
,
STR_PAD_LEFT
)
.
'-'
.
str_pad
(
$result
->
legal_entity
->
dob
->
day
,
2
,
'0'
,
STR_PAD_LEFT
))
->
setStreet
(
$result
->
legal_entity
->
address
->
line1
)
->
setCity
(
$result
->
legal_entity
->
address
->
city
)
->
setPostCode
(
$result
->
legal_entity
->
address
->
postal_code
)
->
setState
(
$result
->
legal_entity
->
address
->
state
)
->
setPhoneNumber
(
$result
->
legal_entity
->
phone_number
)
->
setSSN
(
$result
->
legal_entity
->
ssn_last_4
)
->
setPersonalIdNumber
(
$result
->
legal_entity
->
personal_id_number
)
->
setFirstName
(
$result
->
individual
->
first_name
)
->
setLastName
(
$result
->
individual
->
last_name
)
->
setGender
(
$result
->
individual
->
gender
??
null
)
->
setDateOfBirth
(
$result
->
individual
->
dob
->
year
.
'-'
.
str_pad
(
$result
->
individual
->
dob
->
month
,
2
,
'0'
,
STR_PAD_LEFT
)
.
'-'
.
str_pad
(
$result
->
individual
->
dob
->
day
,
2
,
'0'
,
STR_PAD_LEFT
))
->
setStreet
(
$result
->
individual
->
address
->
line1
)
->
setCity
(
$result
->
individual
->
address
->
city
)
->
setPostCode
(
$result
->
individual
->
address
->
postal_code
)
->
setState
(
$result
->
individual
->
address
->
state
)
->
setPhoneNumber
(
$result
->
individual
->
phone
??
null
)
->
setSSN
(
$result
->
individual
->
ssn_last_4
??
null
)
->
setPersonalIdNumber
(
$result
->
individual
->
id_number
??
null
)
->
setBankAccount
(
$result
->
external_accounts
->
data
[
0
])
->
setAccountNumber
(
$result
->
external_accounts
->
data
[
0
][
'last4'
])
->
setRoutingNumber
(
$result
->
external_accounts
->
data
[
0
][
'routing_number'
])
->
setDestination
(
'bank'
)
->
setPayoutInterval
(
$result
->
settings
->
payouts
->
schedule
->
interval
)
->
setPayoutDelay
(
$result
->
settings
->
payouts
->
schedule
->
delay_days
)
->
setPayoutAnchor
(
$result
->
settings
->
payouts
->
schedule
->
monthly_anchor
);
->
setPayoutAnchor
(
$result
->
settings
->
payouts
->
schedule
->
monthly_anchor
??
null
)
->
setMetadata
(
$result
->
metadata
);
//verifiction check
if
(
$result
->
legal_entity
->
verification
->
status
===
'verified'
)
{
if
(
$result
->
individual
->
verification
->
status
===
'verified'
)
{
$account
->
setVerified
(
true
);
}
if
(
!
$account
->
getVerified
())
{
switch
(
$result
->
requirements
->
disabled_reason
)
{
case
'requirements.past_due'
:
$account
->
setRequirement
(
$result
->
requirements
->
currently_due
[
0
]);
break
;
}
$account
->
setRequirement
(
$result
->
requirements
->
currently_due
[
0
]);
}
$account
->
setTotalBalance
(
$this
->
getBalanceById
(
$result
->
id
,
'available'
));
...
...
@@ -351,4 +371,30 @@ class Manager
return
true
;
}
/**
* Return an iterator of accounts
* @return iterable
*/
public
function
getList
()
:
iterable
{
$startingAfter
=
null
;
while
(
true
)
{
$opts
=
[
'limit'
=>
10
,
];
if
(
$startingAfter
)
{
$opts
[
'starting_after'
]
=
$startingAfter
;
}
$accounts
=
$this
->
accountInstance
->
all
(
$opts
);
if
(
!
$accounts
)
{
return
null
;
}
foreach
(
$accounts
as
$account
)
{
yield
$account
;
$startingAfter
=
$account
->
id
;
}
}
}
}
This diff is collapsed.
Spec/Core/Payments/Stripe/Connect/ManagerSpec.php
View file @
50321c92
...
...
@@ -99,7 +99,7 @@ class ManagerSpec extends ObjectBehavior
->
willReturn
((
object
)
[
'id'
=>
'acc_123'
,
'country'
=>
'GB'
,
'
legal_entity
'
=>
(
object
)
[
'
individual
'
=>
(
object
)
[
'first_name'
=>
'George'
,
'last_name'
=>
'Harrison'
,
'gender'
=>
null
,
...
...
@@ -141,6 +141,7 @@ class ManagerSpec extends ObjectBehavior
],
],
],
'metadata'
=>
[],
]);
$this
->
balanceInstance
->
retrieve
([
'stripe_account'
=>
'acc_123'
])
...
...
@@ -179,7 +180,7 @@ class ManagerSpec extends ObjectBehavior
->
willReturn
((
object
)
[
'id'
=>
'acc_123'
,
'country'
=>
'GB'
,
'
legal_entity
'
=>
(
object
)
[
'
individual
'
=>
(
object
)
[
'first_name'
=>
'George'
,
'last_name'
=>
'Harrison'
,
'gender'
=>
null
,
...
...
@@ -220,7 +221,8 @@ class ManagerSpec extends ObjectBehavior
'monthly_anchor'
=>
31
,
]
]
]
],
'metadata'
=>
[],
]);
$this
->
balanceInstance
->
retrieve
([
'stripe_account'
=>
'acc_123'
])
...
...
This diff is collapsed.
Please
register
or
sign in
to comment