Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
241
Issues
241
List
Boards
Labels
Service Desk
Milestones
Merge Requests
31
Merge Requests
31
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
2a5d64fe
Commit
2a5d64fe
authored
48 minutes ago
by
Mark Harding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(fix): code review fixes
parent
33f55e71
No related merge requests found
Pipeline
#78967963
failed with stages
in 4 minutes and 7 seconds
Changes
22
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
515 additions
and
249 deletions
+515
-249
paymentmethods.php
Controllers/api/v2/payments/stripe/paymentmethods.php
+0
-30
apply.php
Controllers/api/v2/payments/stripe/paymentmethods/apply.php
+63
-0
btc.php
Controllers/api/v2/wallet/btc.php
+5
-30
address.php
Controllers/api/v2/wallet/btc/address.php
+68
-0
usd.php
Controllers/api/v2/wallet/usd.php
+11
-127
account.php
Controllers/api/v2/wallet/usd/account.php
+140
-0
status.php
Controllers/api/v2/wallet/usd/status.php
+61
-0
verification.php
Controllers/api/v2/wallet/usd/verification.php
+61
-0
WireReceived.php
Core/Email/Campaigns/WireReceived.php
+5
-3
WireSent.php
Core/Email/Campaigns/WireSent.php
+5
-3
CheckoutSession.php
Core/Payments/Stripe/Checkout/CheckoutSession.php
+4
-1
Order.php
Core/Payments/Stripe/Checkout/Order.php
+10
-1
Account.php
Core/Payments/Stripe/Connect/Account.php
+2
-2
Manager.php
Core/Payments/Stripe/Connect/Manager.php
+4
-4
Customer.php
Core/Payments/Stripe/Customers/Customer.php
+7
-1
Intent.php
Core/Payments/Stripe/Intents/Intent.php
+8
-1
PaymentIntent.php
Core/Payments/Stripe/Intents/PaymentIntent.php
+9
-1
SetupIntent.php
Core/Payments/Stripe/Intents/SetupIntent.php
+1
-1
PaymentMethod.php
Core/Payments/Stripe/PaymentMethods/PaymentMethod.php
+10
-1
Repository.php
Core/Payments/Stripe/Repository.php
+0
-9
Stripe.php
Core/Payments/Stripe/Stripe.php
+39
-32
User.php
Entities/User.php
+2
-2
No files found.
Controllers/api/v2/payments/stripe/paymentmethods.php
View file @
2a5d64fe
...
...
@@ -31,36 +31,6 @@ class paymentmethods implements Interfaces\Api
public
function
post
(
$pages
)
{
$user
=
Session
::
getLoggedInUser
();
switch
(
$pages
[
0
])
{
case
'apply'
:
$intent
=
new
Stripe\Intents\SetupIntent
();
$intent
->
setId
(
$_POST
[
'intent_id'
]);
$intentManager
=
new
Stripe\Intents\Manager
();
$paymentMethodsManager
=
new
Stripe\PaymentMethods\Manager
();
$customersManager
=
new
Stripe\Customers\Manager
();
// Get the intent
$intent
=
$intentManager
->
get
(
$_POST
[
'intent_id'
]);
// Grab our customerId
$customer
=
$customersManager
->
getFromUserGuid
(
$user
->
getGuid
());
// Build a payment method
$paymentMethod
=
new
Stripe\PaymentMethods\PaymentMethod
();
$paymentMethod
->
setId
(
$intent
->
getPaymentMethod
())
->
setUserGuid
(
$user
->
getGuid
());
if
(
$customer
)
{
$paymentMethod
->
setCustomerId
(
$customer
->
getId
());
}
// Save the payment method
$paymentMethodsManager
->
add
(
$paymentMethod
);
break
;
}
return
Factory
::
response
([]);
}
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/payments/stripe/paymentmethods/apply.php
0 → 100644
View file @
2a5d64fe
<?php
/**
*
*/
namespace
Minds\Controllers\api\v2\payments\stripe\paymentmethods
;
use
Minds\Api\Factory
;
use
Minds\Common\Cookie
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Config
;
use
Minds\Core\Session
;
use
Minds\Interfaces
;
use
Minds\Core\Payments\Stripe
;
class
apply
implements
Interfaces\Api
{
public
function
get
(
$pages
)
{
return
Factory
::
response
([]);
}
public
function
post
(
$pages
)
{
$user
=
Session
::
getLoggedInUser
();
$intent
=
new
Stripe\Intents\SetupIntent
();
$intent
->
setId
(
$_POST
[
'intent_id'
]);
$intentManager
=
new
Stripe\Intents\Manager
();
$paymentMethodsManager
=
new
Stripe\PaymentMethods\Manager
();
$customersManager
=
new
Stripe\Customers\Manager
();
// Get the intent
$intent
=
$intentManager
->
get
(
$_POST
[
'intent_id'
]);
// Grab our customerId
$customer
=
$customersManager
->
getFromUserGuid
(
$user
->
getGuid
());
// Build a payment method
$paymentMethod
=
new
Stripe\PaymentMethods\PaymentMethod
();
$paymentMethod
->
setId
(
$intent
->
getPaymentMethod
())
->
setUserGuid
(
$user
->
getGuid
());
if
(
$customer
)
{
$paymentMethod
->
setCustomerId
(
$customer
->
getId
());
}
// Save the payment method
$paymentMethodsManager
->
add
(
$paymentMethod
);
return
Factory
::
response
([]);
}
public
function
put
(
$pages
)
{
return
Factory
::
response
([]);
}
public
function
delete
(
$pages
)
{
return
Factory
::
response
([]);
}
}
This diff is collapsed.
Click to expand it.
Controllers/api/v2/wallet/btc.php
View file @
2a5d64fe
...
...
@@ -18,44 +18,19 @@ use Minds\Entities;
class
btc
implements
Interfaces\Api
{
/**
* Returns merchant information
* @param array $pages
*
* API:: /v1/merchant/:slug
*/
public
function
get
(
$pages
)
{
Factory
::
isLoggedIn
();
$response
=
[];
switch
(
$pages
[
0
])
{
case
"address"
:
$response
[
'address'
]
=
Core\Session
::
getLoggedInUser
()
->
getBtcAddress
();
break
;
}
return
Factory
::
response
(
$response
);
return
Factory
::
response
([]);
}
/**
* @param array $pages
*/
public
function
post
(
$pages
)
{
Factory
::
isLoggedIn
();
$response
=
[];
$user
=
Core\Session
::
getLoggedInUser
();
$save
=
new
Actions\Save
();
switch
(
$pages
[
0
])
{
case
"address"
:
$user
->
setBtcAddress
(
$_POST
[
'address'
]);
$save
->
setEntity
(
$user
)
->
save
();
break
;
}
return
Factory
::
response
(
$response
);
return
Factory
::
response
([]);
}
public
function
put
(
$pages
)
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/wallet/btc/address.php
0 → 100644
View file @
2a5d64fe
<?php
/**
* BTC Wallet Controller
*
* @version 1
* @author Mark Harding
*/
namespace
Minds\Controllers\api\v2\wallet\btc
;
use
Minds\Core
;
use
Minds\Core\Entities\Actions
;
use
Minds\Helpers
;
use
Minds\Interfaces
;
use
Minds\Api\Factory
;
use
Minds\Core\Payments
;
use
Minds\Entities
;
class
address
implements
Interfaces\Api
{
/**
* @param array $pages
*/
public
function
get
(
$pages
)
{
Factory
::
isLoggedIn
();
$response
=
[
'address'
=>
Core\Session
::
getLoggedInUser
()
->
getBtcAddress
(),
];
return
Factory
::
response
(
$response
);
}
/**
* @param array $pages
*/
public
function
post
(
$pages
)
{
Factory
::
isLoggedIn
();
$response
=
[];
$user
=
Core\Session
::
getLoggedInUser
();
$save
=
new
Actions\Save
();
$user
->
setBtcAddress
(
$_POST
[
'address'
]);
$save
->
setEntity
(
$user
)
->
save
();
return
Factory
::
response
(
$response
);
}
/**
* @param array $pages
*/
public
function
put
(
$pages
)
{
return
Factory
::
response
([]);
}
/**
* @param array $pages
*/
public
function
delete
(
$pages
)
{
return
Factory
::
response
([]);
}
}
This diff is collapsed.
Click to expand it.
Controllers/api/v2/wallet/usd.php
View file @
2a5d64fe
...
...
@@ -17,148 +17,32 @@ use Minds\Entities;
class
usd
implements
Interfaces\Api
{
/**
* Returns merchant information
* @param array $pages
*
* API:: /v1/merchant/:slug
*/
public
function
get
(
$pages
)
{
Factory
::
isLoggedIn
();
$response
=
[];
switch
(
$pages
[
0
])
{
case
"status"
:
$merchants
=
Core\Di\Di
::
_
()
->
get
(
'Monetization\Merchants'
);
$merchants
->
setUser
(
Core\Sandbox
::
user
(
Core\Session
::
getLoggedInUser
(),
'merchant'
));
$isMerchant
=
(
bool
)
$merchants
->
getId
();
$canBecomeMerchant
=
!
$merchants
->
isBanned
();
return
Factory
::
response
([
'isMerchant'
=>
$isMerchant
,
'canBecomeMerchant'
=>
$canBecomeMerchant
,
]);
break
;
case
"settings"
:
$stripeConnectManager
=
Core\Di\Di
::
_
()
->
get
(
'Stripe\Connect\Manager'
);
try
{
$account
=
$stripeConnectManager
->
getByUser
(
Core\Session
::
getLoggedInUser
());
}
catch
(
\Exception
$e
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
$e
->
getMessage
()
]);
}
if
(
!
$account
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'Not a merchant account'
]);
}
$response
[
'account'
]
=
$account
->
export
();
break
;
}
return
Factory
::
response
(
$response
);
return
Factory
::
response
([]);
}
/**
* @param array $pages
*/
public
function
post
(
$pages
)
{
Factory
::
isLoggedIn
();
$response
=
[];
switch
(
$pages
[
0
])
{
case
"onboarding"
:
$account
=
(
new
Payments\Stripe\Connect\Account
())
->
setUserGuid
(
Core\Session
::
getLoggedInUser
()
->
guid
)
->
setUser
(
Core\Session
::
getLoggedInUser
())
->
setDestination
(
'bank'
)
->
setCountry
(
$_POST
[
'country'
])
->
setSSN
(
$_POST
[
'ssn'
]
?
str_pad
((
string
)
$_POST
[
'ssn'
],
4
,
'0'
,
STR_PAD_LEFT
)
:
''
)
->
setPersonalIdNumber
(
$_POST
[
'personalIdNumber'
])
->
setFirstName
(
$_POST
[
'firstName'
])
->
setLastName
(
$_POST
[
'lastName'
])
->
setGender
(
$_POST
[
'gender'
])
->
setDateOfBirth
(
$_POST
[
'dob'
])
->
setStreet
(
$_POST
[
'street'
])
->
setCity
(
$_POST
[
'city'
])
->
setState
(
$_POST
[
'state'
])
->
setPostCode
(
$_POST
[
'postCode'
])
->
setPhoneNumber
(
$_POST
[
'phoneNumber'
])
->
setIp
(
$_SERVER
[
'HTTP_X_FORWARDED_FOR'
]);
try
{
$stripeConnectManager
=
Core\Di\Di
::
_
()
->
get
(
'Stripe\Connect\Manager'
);
$account
=
$stripeConnectManager
->
add
(
$account
);
$response
[
'account'
]
=
$account
->
export
();
}
catch
(
\Exception
$e
)
{
$response
[
'status'
]
=
"error"
;
$response
[
'message'
]
=
$e
->
getMessage
();
}
break
;
case
"verification"
:
try
{
$stripe
=
Core\Di\Di
::
_
()
->
get
(
'StripePayments'
);
$stripe
->
verifyMerchant
(
Core\Session
::
getLoggedInUser
()
->
getMerchant
()[
'id'
],
$_FILES
[
'file'
]);
}
catch
(
\Exception
$e
)
{
$response
[
'status'
]
=
"error"
;
$response
[
'message'
]
=
$e
->
getMessage
();
}
break
;
case
"update"
:
$account
=
(
new
Payments\Stripe\Connect\Account
())
->
setId
(
Core\Session
::
getLoggedInUser
()
->
getMerchant
()[
'id'
])
->
setFirstName
(
$_POST
[
'firstName'
])
->
setLastName
(
$_POST
[
'lastName'
])
->
setGender
(
$_POST
[
'gender'
])
->
setDateOfBirth
(
$_POST
[
'dob'
])
->
setStreet
(
$_POST
[
'street'
])
->
setCity
(
$_POST
[
'city'
])
->
setState
(
$_POST
[
'state'
])
->
setPostCode
(
$_POST
[
'postCode'
])
->
setPhoneNumber
(
$_POST
[
'phoneNumber'
]);
if
(
$_POST
[
'ssn'
])
{
$account
->
setSSN
(
$_POST
[
'ssn'
]
?
str_pad
((
string
)
$_POST
[
'ssn'
],
4
,
'0'
,
STR_PAD_LEFT
)
:
''
);
}
if
(
$_POST
[
'personalIdNumber'
])
{
$account
->
setPersonalIdNumber
(
$_POST
[
'personalIdNumber'
]);
}
if
(
$_POST
[
'accountNumber'
])
{
$account
->
setAccountNumber
(
$_POST
[
'accountNumber'
]);
}
if
(
$_POST
[
'routingNumber'
])
{
$account
->
setRoutingNumber
(
$_POST
[
'routingNumber'
]);
}
try
{
$stripeConnectManager
=
Core\Di\Di
::
_
()
->
get
(
'Stripe\Connect\Manager'
);
$result
=
$stripeConnectManager
->
update
(
$account
);
}
catch
(
\Exception
$e
)
{
$response
[
'status'
]
=
"error"
;
$response
[
'message'
]
=
$e
->
getMessage
();
}
break
;
}
return
Factory
::
response
(
$response
);
return
Factory
::
response
([]);
}
/**
* @param array $pages
*/
public
function
put
(
$pages
)
{
return
Factory
::
response
([]);
}
/**
* @param array $pages
*/
public
function
delete
(
$pages
)
{
return
Factory
::
response
([]);
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/wallet/usd/account.php
0 → 100644
View file @
2a5d64fe
<?php
/**
* USD Wallet Controller
*
* @version 1
* @author Mark Harding
*/
namespace
Minds\Controllers\api\v2\wallet\usd
;
use
Minds\Core
;
use
Minds\Helpers
;
use
Minds\Interfaces
;
use
Minds\Api\Factory
;
use
Minds\Core\Payments
;
use
Minds\Entities
;
class
account
implements
Interfaces\Api
{
/**
* @param array $pages
*/
public
function
get
(
$pages
)
{
Factory
::
isLoggedIn
();
$response
=
[];
$stripeConnectManager
=
Core\Di\Di
::
_
()
->
get
(
'Stripe\Connect\Manager'
);
try
{
$account
=
$stripeConnectManager
->
getByUser
(
Core\Session
::
getLoggedInUser
());
}
catch
(
\Exception
$e
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
$e
->
getMessage
()
]);
}
if
(
!
$account
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'Not a merchant account'
]);
}
$response
[
'account'
]
=
$account
->
export
();
return
Factory
::
response
(
$response
);
}
/**
* @param array $pages
*/
public
function
post
(
$pages
)
{
Factory
::
isLoggedIn
();
$response
=
[];
$account
=
(
new
Payments\Stripe\Connect\Account
())
->
setId
(
Core\Session
::
getLoggedInUser
()
->
getMerchant
()[
'id'
])
->
setFirstName
(
$_POST
[
'firstName'
])
->
setLastName
(
$_POST
[
'lastName'
])
->
setGender
(
$_POST
[
'gender'
])
->
setDateOfBirth
(
$_POST
[
'dob'
])
->
setStreet
(
$_POST
[
'street'
])
->
setCity
(
$_POST
[
'city'
])
->
setState
(
$_POST
[
'state'
])
->
setPostCode
(
$_POST
[
'postCode'
])
->
setPhoneNumber
(
$_POST
[
'phoneNumber'
]);
if
(
$_POST
[
'ssn'
])
{
$account
->
setSSN
(
$_POST
[
'ssn'
]
?
str_pad
((
string
)
$_POST
[
'ssn'
],
4
,
'0'
,
STR_PAD_LEFT
)
:
''
);
}
if
(
$_POST
[
'personalIdNumber'
])
{
$account
->
setPersonalIdNumber
(
$_POST
[
'personalIdNumber'
]);
}
if
(
$_POST
[
'accountNumber'
])
{
$account
->
setAccountNumber
(
$_POST
[
'accountNumber'
]);
}
if
(
$_POST
[
'routingNumber'
])
{
$account
->
setRoutingNumber
(
$_POST
[
'routingNumber'
]);
}
try
{
$stripeConnectManager
=
Core\Di\Di
::
_
()
->
get
(
'Stripe\Connect\Manager'
);
$result
=
$stripeConnectManager
->
update
(
$account
);
}
catch
(
\Exception
$e
)
{
$response
[
'status'
]
=
"error"
;
$response
[
'message'
]
=
$e
->
getMessage
();
}
return
Factory
::
response
(
$response
);
}
/**
* @param array $pages
*/
public
function
put
(
$pages
)
{
Factory
::
isLoggedIn
();
$response
=
[];
$account
=
(
new
Payments\Stripe\Connect\Account
())
->
setUserGuid
(
Core\Session
::
getLoggedInUser
()
->
guid
)
->
setUser
(
Core\Session
::
getLoggedInUser
())
->
setDestination
(
'bank'
)
->
setCountry
(
$_POST
[
'country'
])
->
setSSN
(
$_POST
[
'ssn'
]
?
str_pad
((
string
)
$_POST
[
'ssn'
],
4
,
'0'
,
STR_PAD_LEFT
)
:
''
)
->
setPersonalIdNumber
(
$_POST
[
'personalIdNumber'
])
->
setFirstName
(
$_POST
[
'firstName'
])
->
setLastName
(
$_POST
[
'lastName'
])
->
setGender
(
$_POST
[
'gender'
])
->
setDateOfBirth
(
$_POST
[
'dob'
])
->
setStreet
(
$_POST
[
'street'
])
->
setCity
(
$_POST
[
'city'
])
->
setState
(
$_POST
[
'state'
])
->
setPostCode
(
$_POST
[
'postCode'
])
->
setPhoneNumber
(
$_POST
[
'phoneNumber'
])
->
setIp
(
$_SERVER
[
'HTTP_X_FORWARDED_FOR'
]);
try
{
$stripeConnectManager
=
Core\Di\Di
::
_
()
->
get
(
'Stripe\Connect\Manager'
);
$account
=
$stripeConnectManager
->
add
(
$account
);
$response
[
'account'
]
=
$account
->
export
();
}
catch
(
\Exception
$e
)
{
$response
[
'status'
]
=
"error"
;
$response
[
'message'
]
=
$e
->
getMessage
();
}
return
Factory
::
response
([]);
}
public
function
delete
(
$pages
)
{
return
Factory
::
response
([]);
}
}
This diff is collapsed.
Click to expand it.
Controllers/api/v2/wallet/usd/status.php
0 → 100644
View file @
2a5d64fe
<?php
/**
* USD Wallet Controller
*
* @version 1
* @author Mark Harding
*/
namespace
Minds\Controllers\api\v2\wallet\usd
;
use
Minds\Core
;
use
Minds\Helpers
;
use
Minds\Interfaces
;
use
Minds\Api\Factory
;
use
Minds\Core\Payments
;
use
Minds\Entities
;
class
status
implements
Interfaces\Api
{
/**
* @param array $pages
*/
public
function
get
(
$pages
)
{
Factory
::
isLoggedIn
();
$merchants
=
Core\Di\Di
::
_
()
->
get
(
'Monetization\Merchants'
);
$merchants
->
setUser
(
Core\Sandbox
::
user
(
Core\Session
::
getLoggedInUser
(),
'merchant'
));
$isMerchant
=
(
bool
)
$merchants
->
getId
();
$canBecomeMerchant
=
!
$merchants
->
isBanned
();
return
Factory
::
response
([
'isMerchant'
=>
$isMerchant
,
'canBecomeMerchant'
=>
$canBecomeMerchant
,
]);
}
/**
* @param array $pages
*/
public
function
post
(
$pages
)
{
return
Factory
::
response
([]);
}
/**
* @param array $pages
*/
public
function
put
(
$pages
)
{
return
Factory
::
response
([]);
}
/**
* @param array $pages
*/
public
function
delete
(
$pages
)
{
return
Factory
::
response
([]);
}
}
This diff is collapsed.
Click to expand it.
Controllers/api/v2/wallet/usd/verification.php
0 → 100644
View file @
2a5d64fe
<?php
/**
* USD Wallet Controller
*
* @version 1
* @author Mark Harding
*/
namespace
Minds\Controllers\api\v2\wallet\usd
;
use
Minds\Core
;
use
Minds\Helpers
;
use
Minds\Interfaces
;
use
Minds\Api\Factory
;
use
Minds\Core\Payments
;
use
Minds\Entities
;
class
verification
implements
Interfaces\Api
{
/**
* @param array $pages
*/
public
function
get
(
$pages
)
{
return
Factory
::
response
([]);
}
/**
* @param array $pages
*/
public
function
post
(
$pages
)
{
Factory
::
isLoggedIn
();
$response
=
[];
try
{
$stripe
=
Core\Di\Di
::
_
()
->
get
(
'StripePayments'
);
$stripe
->
verifyMerchant
(
Core\Session
::
getLoggedInUser
()
->
getMerchant
()[
'id'
],
$_FILES
[
'file'
]);
}
catch
(
\Exception
$e
)
{
$response
[
'status'
]
=
"error"
;
$response
[
'message'
]
=
$e
->
getMessage
();
}
return
Factory
::
response
(
$response
);
}
/**
* @param array $pages
*/
public
function
put
(
$pages
)
{
return
Factory
::
response
([]);
}
/**
* @param array $pages
*/
public
function
delete
(
$pages
)
{
return
Factory
::
response
([]);
}
}
This diff is collapsed.
Click to expand it.
Core/Email/Campaigns/WireReceived.php
View file @
2a5d64fe
...
...
@@ -58,8 +58,10 @@ class WireReceived extends EmailCampaign
$message
=
new
Message
();
$message
->
setTo
(
$this
->
user
)
->
setMessageId
(
implode
(
'-'
,
[
$this
->
user
->
guid
,
sha1
(
$this
->
user
->
getEmail
()),
sha1
(
$this
->
campaign
.
$this
->
topic
.
time
())]))
->
setMessageId
(
implode
(
'-'
,
[
$this
->
user
->
guid
,
sha1
(
$this
->
user
->
getEmail
()),
sha1
(
$this
->
campaign
.
$this
->
topic
.
time
())]
))
->
setSubject
(
$this
->
subject
)
->
setHtml
(
$this
->
template
);
...
...
@@ -73,7 +75,7 @@ class WireReceived extends EmailCampaign
}
}
private
function
getAmountString
(
$wire
)
private
function
getAmountString
(
Wire
$wire
)
:
string
{
$amount
=
$wire
->
getAmount
();
if
(
$wire
->
getMethod
()
===
'tokens'
)
{
...
...
This diff is collapsed.
Click to expand it.
Core/Email/Campaigns/WireSent.php
View file @
2a5d64fe
...
...
@@ -60,8 +60,10 @@ class WireSent extends EmailCampaign
$message
=
new
Message
();
$message
->
setTo
(
$this
->
user
)
->
setMessageId
(
implode
(
'-'
,
[
$this
->
user
->
guid
,
sha1
(
$this
->
user
->
getEmail
()),
sha1
(
$this
->
campaign
.
$this
->
topic
.
time
())]))
->
setMessageId
(
implode
(
'-'
,
[
$this
->
user
->
guid
,
sha1
(
$this
->
user
->
getEmail
()),
sha1
(
$this
->
campaign
.
$this
->
topic
.
time
())]
))
->
setSubject
(
$this
->
subject
)
->
setHtml
(
$this
->
template
);
...
...
@@ -75,7 +77,7 @@ class WireSent extends EmailCampaign
}
}
private
function
getAmountString
(
$wire
)
private
function
getAmountString
(
Wire
$wire
)
:
string
{
$amount
=
$wire
->
getAmount
();
if
(
$wire
->
getMethod
()
===
'tokens'
)
{
...
...
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Checkout/CheckoutSession.php
View file @
2a5d64fe
...
...
@@ -6,6 +6,9 @@ namespace Minds\Core\Payments\Stripe\Checkout;
use
Minds\Traits\MagicAttributes
;
/**
* @method CheckoutSession getSessionId(): string
*/
class
CheckoutSession
{
use
MagicAttributes
;
...
...
@@ -18,7 +21,7 @@ class CheckoutSession
* @param array $extend
* @return array
*/
public
function
export
(
$extend
=
[])
public
function
export
(
array
$extend
=
[])
:
array
{
return
[
'sessionId'
=>
(
string
)
$this
->
sessionId
,
...
...
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Checkout/Order.php
View file @
2a5d64fe
...
...
@@ -6,6 +6,15 @@ namespace Minds\Core\Payments\Stripe\Checkout;
use
Minds\Traits\MagicAttributes
;
/**
* @method Order getName(): string
* @method Order getAmount(): int
* @method Order getQuantity(): int
* @method Order getCurrency(): string
* @method Order getServiceFeePct(): int
* @method Order getCustomerId(): string
* @method Order getStripeAccountId(): string
*/
class
Order
{
use
MagicAttributes
;
...
...
@@ -45,7 +54,7 @@ class Order
* @param array $extend
* @return array
*/
public
function
export
(
$extend
=
[])
public
function
export
(
array
$extend
=
[])
:
array
{
return
[
'name'
=>
(
string
)
$this
->
name
,
...
...
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Connect/Account.php
View file @
2a5d64fe
...
...
@@ -125,7 +125,7 @@ class Account
* @param string $destination
* @return $this
*/
public
function
setDestination
(
$destination
)
public
function
setDestination
(
string
$destination
)
:
Account
{
if
(
!
in_array
(
$destination
,
[
'bank'
,
'email'
],
true
))
{
throw
new
\Exception
(
"
$destination
is not a valid payout method"
);
...
...
@@ -138,7 +138,7 @@ class Account
* Expose to public API
* @return array
*/
public
function
export
(
)
public
function
export
(
array
$extend
=
[])
:
array
{
$export
=
[];
...
...
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Connect/Manager.php
View file @
2a5d64fe
...
...
@@ -114,7 +114,7 @@ class Manager
* @return string Account id
* @throws \Exception
*/
public
function
update
(
Account
$account
)
public
function
update
(
Account
$account
)
:
string
{
try
{
$stripeAccount
=
$this
->
accountInstance
->
retrieve
(
$account
->
getId
());
...
...
@@ -171,7 +171,7 @@ class Manager
* @param Account $account
* @return boolean
*/
public
function
addBankAccount
(
Account
$account
)
public
function
addBankAccount
(
Account
$account
)
:
bool
{
$stripeAccount
=
$this
->
accountInstance
->
retrieve
(
$account
->
getId
());
$stripeAccount
->
external_account
=
[
...
...
@@ -195,7 +195,7 @@ class Manager
* @param string $id
* @return Account
*/
public
function
getByAccountId
(
$id
)
public
function
getByAccountId
(
string
$id
)
:
Account
{
try
{
$result
=
$this
->
accountInstance
->
retrieve
(
$id
);
...
...
@@ -256,7 +256,7 @@ class Manager
* @param Account $account
* @return boolean
*/
public
function
delete
(
Account
$account
)
public
function
delete
(
Account
$account
)
:
bool
{
$stripeAccount
=
$this
->
accountInstance
->
retrieve
(
$account
->
getId
());
$result
=
$stripeAccount
->
delete
();
...
...
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Customers/Customer.php
View file @
2a5d64fe
...
...
@@ -6,6 +6,12 @@ namespace Minds\Core\Payments\Stripe\Customers;
use
Minds\Traits\MagicAttributes
;
/**
* @method Customer getId(): string
* @method Customer getUserGuid(): string
* @method Customer getUser(): User
* @method Customer getPaymentSource(): string
*/
class
Customer
{
use
MagicAttributes
;
...
...
@@ -27,7 +33,7 @@ class Customer
* @param array $extend
* @return array
*/
public
function
export
(
$extend
=
[])
public
function
export
(
array
$extend
=
[])
:
array
{
return
[
'user_guid'
=>
(
string
)
$this
->
userGuid
,
...
...
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Intents/Intent.php
View file @
2a5d64fe
...
...
@@ -6,6 +6,13 @@ namespace Minds\Core\Payments\Stripe\Intents;
use
Minds\Traits\MagicAttributes
;
/**
* @method Intent getId(): string
* @method Intent getCustomerId(): string
* @method Intent getPaymentMethod(): string
* @method Intent getStripeAccountId(): string
* @method Intent getClientSecret(): string
*/
class
Intent
{
use
MagicAttributes
;
...
...
@@ -30,7 +37,7 @@ class Intent
* @param array $extend
* @return array
*/
public
function
export
(
$extend
=
[])
public
function
export
(
array
$extend
=
[])
:
array
{
return
[
'id'
=>
$this
->
id
,
...
...
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Intents/PaymentIntent.php
View file @
2a5d64fe
...
...
@@ -6,6 +6,14 @@ namespace Minds\Core\Payments\Stripe\Intents;
use
Minds\Traits\MagicAttributes
;
/**
* @method PaymentIntent getAmount(): int
* @method PaymentIntent getQuantity(): int
* @method PaymentIntent getCurrency(): string
* @method PaymentIntent getConfirm(): bool
* @method PaymentIntent getOffSession(): bool
* @method PaymentIntent getServiceFeePct(): int
*/
class
PaymentIntent
extends
Intent
{
use
MagicAttributes
;
...
...
@@ -42,7 +50,7 @@ class PaymentIntent extends Intent
* @param array $extend
* @return array
*/
public
function
export
(
$extend
=
[])
public
function
export
(
array
$extend
=
[])
:
array
{
return
[
];
...
...
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Intents/SetupIntent.php
View file @
2a5d64fe
...
...
@@ -15,7 +15,7 @@ class SetupIntent extends Intent
* @param array $extend
* @return array
*/
public
function
export
(
$extend
=
[])
public
function
export
(
array
$extend
=
[])
:
array
{
return
parent
::
export
(
$extend
);
}
...
...
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/PaymentMethods/PaymentMethod.php
View file @
2a5d64fe
...
...
@@ -6,6 +6,15 @@ namespace Minds\Core\Payments\Stripe\PaymentMethods;
use
Minds\Traits\MagicAttributes
;
/**
* @method PaymentMethod getId(): string
* @method PaymentMethod getCustomerId(): string
* @method PaymentMethod getUserGuid(): string
* @method PaymentMethod getCardBrand(): string
* @method PaymentMethod getCardExpires(): string
* @method PaymentMethod getCardCountry(): string
* @method PaymentMethod getCardLast4(): string
*/
class
PaymentMethod
{
use
MagicAttributes
;
...
...
@@ -36,7 +45,7 @@ class PaymentMethod
* @param array $extend
* @return array
*/
public
function
export
(
$extend
=
[])
public
function
export
(
array
$extend
=
[])
:
array
{
return
[
'id'
=>
$this
->
id
,
...
...
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Repository.php
deleted
100644 → 0
View file @
33f55e71
<?php
/**
* Stripe Repository
*/
namespace
Minds\Core\Payments\Stripe
;
class
Repository
{
}
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Stripe.php
View file @
2a5d64fe
...
...
@@ -25,10 +25,7 @@ class Stripe implements SubscriptionPaymentServiceInterface
public
function
__construct
(
Config
$config
=
null
)
{
if
(
!
$config
)
{
$config
=
new
Config
;
}
$this
->
config
=
$config
;
$this
->
config
=
$config
??
new
Config
;
if
(
$config
->
payments
&&
isset
(
$config
->
payments
[
'stripe'
]))
{
$this
->
setConfig
(
$config
->
payments
[
'stripe'
]);
}
...
...
@@ -99,12 +96,13 @@ class Stripe implements SubscriptionPaymentServiceInterface
if
(
$opts
[
'customer'
])
{
//we need to clone the customer
$token
=
StripeSDK\Token
::
create
(
[
[
'customer'
=>
$opts
[
'customer'
]
],
[
[
'stripe_account'
=>
$user
->
getMerchant
()[
'id'
]
]);
]
);
$opts
[
'customer'
]
=
null
;
$opts
[
'card'
]
=
null
;
$opts
[
'source'
]
=
$token
->
id
;
...
...
@@ -213,7 +211,8 @@ class Stripe implements SubscriptionPaymentServiceInterface
],
[
'stripe_account'
=>
$merchant
->
getId
()
]);
]
);
$sales
=
[];
foreach
(
$results
->
data
as
$transaction
)
{
...
...
@@ -233,12 +232,13 @@ class Stripe implements SubscriptionPaymentServiceInterface
public
function
getGrossVolume
(
$merchant
)
{
$results
=
StripeSDK\BalanceTransaction
::
all
(
[
[
//'type' => 'payment'
],
[
[
'stripe_account'
=>
$merchant
->
getId
()
]);
]
);
$total
=
[
'net'
=>
0
,
...
...
@@ -259,12 +259,13 @@ class Stripe implements SubscriptionPaymentServiceInterface
public
function
getTotalPayouts
(
$merchant
)
{
$results
=
StripeSDK\BalanceTransaction
::
all
(
[
[
'type'
=>
'payout'
],
[
[
'stripe_account'
=>
$merchant
->
getId
()
]);
]
);
$total
=
0
;
...
...
@@ -287,10 +288,11 @@ class Stripe implements SubscriptionPaymentServiceInterface
}
$transactions
=
StripeSDK\Payout
::
all
(
$options
,
[
$options
,
[
'stripe_account'
=>
$merchant
->
getId
()
]);
]
);
$results
=
[];
...
...
@@ -479,7 +481,8 @@ class Stripe implements SubscriptionPaymentServiceInterface
],
[
'stripe_account'
=>
$merchant
->
getId
()
]);
]
);
return
$results
;
}
...
...
@@ -511,11 +514,13 @@ class Stripe implements SubscriptionPaymentServiceInterface
public
function
verifyMerchant
(
$id
,
$file
)
{
$result
=
StripeSDK\FileUpload
::
create
([
$result
=
StripeSDK\FileUpload
::
create
(
[
'purpose'
=>
"identity_document"
,
'file'
=>
fopen
(
$file
[
'tmp_name'
],
'r'
)
],
[
'stripe_account'
=>
$id
]);
[
'stripe_account'
=>
$id
]
);
$account
=
StripeSDK\Account
::
retrieve
(
$id
);
$account
->
legal_entity
->
verification
->
document
=
$result
->
id
;
...
...
@@ -650,22 +655,22 @@ class Stripe implements SubscriptionPaymentServiceInterface
$merchant
=
$subscription
->
getMerchant
();
//@todo clean this up
//subscriptions need to clone customers
$token
=
StripeSDK\Token
::
create
(
[
[
'customer'
=>
$customer
->
getId
()
],
[
[
'stripe_account'
=>
$merchant
[
'id'
]
]
);
$customer
=
StripeSDK\Customer
::
create
(
[
[
'source'
=>
$token
->
id
,
'metadata'
=>
[
'user_guid'
=>
$subscription
->
getUser
()
->
getGuid
()
]
],
[
[
'stripe_account'
=>
$merchant
[
'id'
]
]
);
...
...
@@ -677,8 +682,8 @@ class Stripe implements SubscriptionPaymentServiceInterface
}
$result
=
StripeSDK\Subscription
::
create
(
$params
,
$extras
$params
,
$extras
);
}
catch
(
\Exception
$e
)
{
throw
new
\Exception
(
$e
->
getMessage
());
...
...
@@ -691,10 +696,11 @@ class Stripe implements SubscriptionPaymentServiceInterface
{
try
{
$result
=
StripeSDK\Subscription
::
retrieve
(
$subscription
->
getId
(),
[
$subscription
->
getId
(),
[
'stripe_account'
=>
$subscription
->
getMerchant
()[
'id'
]
]);
]
);
$subscription
->
setAmount
((
$result
->
quantity
*
$result
->
plan
->
amount
)
/
100
);
$subscription
->
setNextBillingDate
(
$result
->
current_period_end
);
...
...
@@ -710,10 +716,11 @@ class Stripe implements SubscriptionPaymentServiceInterface
{
try
{
return
StripeSDK\Subscription
::
retrieve
(
$subscription
->
getId
(),
[
$subscription
->
getId
(),
[
'stripe_account'
=>
$subscription
->
getMerchant
()[
'id'
]
])
->
cancel
();
]
)
->
cancel
();
}
catch
(
StripeSDK\Error\InvalidRequest
$e
)
{
return
false
;
}
catch
(
\Exception
$e
)
{
...
...
This diff is collapsed.
Click to expand it.
Entities/User.php
View file @
2a5d64fe
...
...
@@ -1106,7 +1106,7 @@ class User extends \ElggUser
* Returns btc_address
* @return string
*/
public
function
getBtcAddress
()
public
function
getBtcAddress
()
:
string
{
return
(
string
)
$this
->
btc_address
;
}
...
...
@@ -1115,7 +1115,7 @@ class User extends \ElggUser
* Set btc_address
* @param string $btc_address
*/
public
function
setBtcAddress
(
$btc_address
)
public
function
setBtcAddress
(
string
$btc_address
)
:
User
{
$this
->
btc_address
=
(
string
)
$btc_address
;
return
$this
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment