Commit 2a5d64fe authored by Mark Harding's avatar Mark Harding

(fix): code review fixes

parent 33f55e71
No related merge requests found
Pipeline #78967963 failed with stages
in 4 minutes and 7 seconds
......@@ -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([]);
}
......
<?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([]);
}
}
......@@ -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)
......
<?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([]);
}
}
......@@ -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([]);
......
<?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([]);
}
}
<?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([]);
}
}
<?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([]);
}
}
......@@ -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') {
......
......@@ -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') {
......
......@@ -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,
......
......@@ -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,
......
......@@ -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 = [];
......
......@@ -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();
......
......@@ -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,
......
......@@ -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,
......
......@@ -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 [
];
......
......@@ -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);
}
......
......@@ -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,
......
<?php
/**
* Stripe Repository
*/
namespace Minds\Core\Payments\Stripe;
class Repository
{
}
......@@ -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) {
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment