Skip to content

Commit

Permalink
Faeries/echopay readme cleanup (#206)
Browse files Browse the repository at this point in the history
* Mostly ok, there's a bug in core

* added code to handle payments less than fee

* fixed the bug that led to 2 payment responses

* finished draft plus images

* Removed uninterpolated f-string

* undid the fix to Core for a separate PR
  • Loading branch information
transfaeries authored Apr 19, 2022
1 parent 61662af commit 848b9f5
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 121 deletions.
213 changes: 98 additions & 115 deletions echopay/README.md

Large diffs are not rendered by default.

27 changes: 22 additions & 5 deletions echopay/echopay.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ async def set_payment_address(self) -> None:

# This will set the bot's Signal profile, replace avatar.png to give your bot a custom avatar
await self.set_profile_auxin(
given_name="PaymeBot",
given_name="Echopay",
family_name="",
payment_address=signal_address,
profile_path="avatar.png",
# profile_path="avatar.png",
)

async def do_payme(self, message: Message) -> Response:
Expand All @@ -55,6 +55,12 @@ async def do_payme(self, message: Message) -> Response:
# and msg.arg1 is the next word after that. In "payme please" please is msg.arg1

if message.arg1 == password:
payment_status = await self.send_payment(
message.source,
amount_picomob,
confirm_tx_timeout=10,
receipt_message="",
)
# This check verifies that the payment succeeded.
if getattr(payment_status, "status", "") == "tx_status_succeeded":
return f"Sent you a payment for {str(amount_mob)} MOB"
Expand Down Expand Up @@ -103,10 +109,21 @@ async def payment_response(self, msg: Message, amount_pmob: int) -> Response:
# amounts are received in picoMob, convert to Mob for readability
amount_mob = self.to_mob(amount_pmob)

if amount_mob > 0.002:
return f"Wow! Thank you for your payment of {str(amount_mob)} MOB"
amount_to_return = amount_pmob - FEE_PMOB

if amount_to_return < 0:
return f"Thank you for your payment of {str(amount_mob)} MOB. This payment is for less than the Network Fee (0.0004 MOB), so I can't return it to you."

payment_status = await self.send_payment(
msg.source,
amount_to_return,
confirm_tx_timeout=10,
receipt_message="",
)
if getattr(payment_status, "status", "") == "tx_status_succeeded":
return f"Thank you for your payment of {str(amount_mob)} MOB. Here's your money back, minus the network fee, {str(self.to_mob(amount_to_return))} MOB."

return "Thanks I guess"
return "Couldn't return your payment for some reason. Please contact administrator for assistance."


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion echopay/echopay_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def set_payment_address(self) -> None:
given_name="PaymeBot",
family_name="",
payment_address=signal_address,
profile_path="avatar.png",
# profile_path="avatar.png",
)

async def do_payme(self, message: Message) -> Response:
Expand Down
Binary file added echopay/images/payme.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added echopay/images/payme2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added echopay/images/payment_response.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added echopay/images/payment_response2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added echopay/images/payuser.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 848b9f5

Please sign in to comment.