Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Dependency List
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
136
Issues
136
List
Boards
Labels
Service Desk
Milestones
Merge Requests
44
Merge Requests
44
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Packages
Packages
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
34ddb380
Commit
34ddb380
authored
1 hour ago
by
Mark Harding
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(fix): all wires had the same subscription_id. introduce urns to solve
front#298
parent
4c28ed54
master
No related merge requests found
Pipeline
#69555251
passed with stages
in 9 minutes and 17 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
3 deletions
+61
-3
Subscriptions.php
Controllers/Cli/Payments/Subscriptions.php
+51
-0
Repository.php
Core/Payments/Subscriptions/Repository.php
+2
-1
Manager.php
Core/Wire/Subscriptions/Manager.php
+8
-2
No files found.
Controllers/Cli/Payments/Subscriptions.php
View file @
34ddb380
...
...
@@ -54,4 +54,55 @@ class Subscriptions extends Cli\Controller implements Interfaces\CliControllerIn
$this
->
out
(
"Done"
);
}
public
function
repair
()
{
error_reporting
(
E_ALL
);
ini_set
(
'display_errors'
,
1
);
/** @var Manager $manager */
$manager
=
Di
::
_
()
->
get
(
'Payments\Subscriptions\Manager'
);
/** @var Queue $queue */
$subscriptions
=
Di
::
_
()
->
get
(
'Payments\Subscriptions\Iterator'
);
$subscriptions
->
setFrom
(
0
)
->
setPaymentMethod
(
'tokens'
)
->
setPlanId
(
'wire'
);
foreach
(
$subscriptions
as
$subscription
)
{
$this
->
out
(
"Subscription:`
{
$subscription
->
getId
()
}
`"
);
if
(
$subscription
->
getId
()
===
'offchain'
)
{
$this
->
out
(
"Subscription:`
{
$subscription
->
getId
()
}
` needs repairing"
);
$urn
=
"urn:subscription:"
.
implode
(
'-'
,
[
$subscription
->
getId
(),
$subscription
->
getUser
()
->
getGuid
(),
$subscription
->
getEntity
()
->
getGuid
(),
]);
$this
->
out
(
"Subscription:`
{
$subscription
->
getId
()
}
` needs repairing to
$urn
"
);
$manager
->
setSubscription
(
$subscription
);
$manager
->
cancel
();
$subscription
->
setId
(
$urn
);
$manager
->
setSubscription
(
$subscription
);
$manager
->
create
();
}
if
(
strpos
(
$subscription
->
getId
(),
'0x'
,
0
)
===
0
)
{
$this
->
out
(
"Subscription:`
{
$subscription
->
getId
()
}
` needs repairing"
);
$urn
=
"urn:subscription:"
.
implode
(
'-'
,
[
$subscription
->
getId
(),
$subscription
->
getUser
()
->
getGuid
(),
$subscription
->
getEntity
()
->
getGuid
(),
]);
$this
->
out
(
"Subscription:`
{
$subscription
->
getId
()
}
` needs repairing to
$urn
"
);
$manager
->
setSubscription
(
$subscription
);
$manager
->
cancel
();
$subscription
->
setId
(
$urn
);
$manager
->
setSubscription
(
$subscription
);
$manager
->
create
();
}
}
$this
->
out
(
"Done"
);
}
}
This diff is collapsed.
Click to expand it.
Core/Payments/Subscriptions/Repository.php
View file @
34ddb380
...
...
@@ -14,6 +14,7 @@ use Cassandra\Varint;
use
Minds\Core\Data\Cassandra\Client
;
use
Minds\Core\Data\Cassandra\Prepared\Custom
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Util\BigNumber
;
class
Repository
{
...
...
@@ -124,7 +125,7 @@ class Repository
->
setPaymentMethod
(
$row
[
'payment_method'
])
->
setEntity
((
string
)
$row
[
'entity_guid'
])
->
setUser
((
string
)
$row
[
'user_guid'
])
->
setAmount
(
$row
[
'amount'
]
->
toDouble
(
))
->
setAmount
(
(
string
)
BigNumber
::
_
(
$row
[
'amount'
]
))
->
setInterval
(
$row
[
'interval'
])
->
setLastBilling
(
$row
[
'last_billing'
]
->
time
())
->
setNextBilling
(
$row
[
'next_billing'
]
->
time
())
...
...
This diff is collapsed.
Click to expand it.
Core/Wire/Subscriptions/Manager.php
View file @
34ddb380
...
...
@@ -76,8 +76,14 @@ class Manager
{
$this
->
cancelSubscription
();
$urn
=
"urn:subscription:"
.
implode
(
'-'
,
[
$this
->
address
,
//offchain or onchain wallet
$this
->
sender
->
getGuid
(),
$this
->
receiver
->
getGuid
(),
]);
$subscription
=
(
new
Core\Payments\Subscriptions\Subscription
())
->
setId
(
$
this
->
address
)
->
setId
(
$
urn
)
->
setPlanId
(
'wire'
)
->
setPaymentMethod
(
'tokens'
)
->
setAmount
(
$this
->
amount
)
...
...
@@ -110,4 +116,4 @@ class Manager
// Cancel old subscription first
$this
->
subscriptionsManager
->
cancel
();
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
Mark Harding
@markeharding
mentioned in issue
front#298 (closed)
·
1 hour ago
mentioned in issue
front#298 (closed)
mentioned in issue front#298
Toggle commit list
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