Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: CryptoBot payments #940

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

gru2007
Copy link

@gru2007 gru2007 commented Apr 11, 2024

I’m just adding new optional payment method

what is it? - https://help.crypt.bot/crypto-pay-api

@MrWeez
Copy link
Sponsor Collaborator

MrWeez commented Apr 11, 2024

Hi! It looks very cool, but could you change the Russian localization to English?
Thank you for helping to improve cpgg ❤️

@gru2007
Copy link
Author

gru2007 commented Apr 11, 2024

Only one thing, for some reason money doesn’t add after sending event with payment. So I added this construction:

try {
            $user->increment('credits', $payment->amount);
        } catch (Exception $exception) {
            throw $exception;
        }

I’m sure, that it is not right way to do that. I don’t know what happens in your code.

@gru2007
Copy link
Author

gru2007 commented Apr 11, 2024

Hi! It looks very cool, but could you change the Russian localization to English? Thank you for helping to improve cpgg ❤️

Oh sorry, I have missed that. Couple minutes.

@1day2die
Copy link
Collaborator

awesome!

@1day2die
Copy link
Collaborator

Only one thing, for some reason money doesn’t add after sending event with payment. So I added this construction:

try {
            $user->increment('credits', $payment->amount);
        } catch (Exception $exception) {
            throw $exception;
        }

I’m sure, that it is not right way to do that. I don’t know what happens in your code.

@IceToast mind checking this?

@IceToast
Copy link
Collaborator

So i see you've created a extension with all the necessary information. I will sketch out the payment workflow:

User payment request -> URL fetching from extension -> Redirecting to payment URL -> ... -> Success redirection to success route of extension -> done

Gateway Webhook -> request to extension webhook route -> sets a payment as "paid" -> emits a user payment event -> payment listener updates user credits and possibly any new limits -> done

The first thing i noticed is that you might want to validate that the webhook request actually wants to update a payment to the PAID status. In your PR it will set it to PAID under any circumstances? Maybe im missing something about the gateway.

For your problem: You should debug into CryptoBotExtension.php:110 to see whether the event really gets triggered and what da parameters are. If everything is processed correctly the event will be listened to in here: Listeners/UserPayment.php

@gru2007
Copy link
Author

gru2007 commented Apr 11, 2024

@IceToast Thanks, I will come back with result soon.

{

public bool $enabled = false;
public ?string $api_key;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you set the api_key as encrypted in the migration it needs to be markes as encrypted in here too:
https://github.com/spatie/laravel-settings?tab=readme-ov-file#encrypting-properties

@S0ly S0ly changed the title FEATURE: CryptoBot payments [Feature] CryptoBot payments May 14, 2024
@S0ly S0ly added Feature Adding a new feature, or substantial improvements on existing functionality Low Priority Can wait, not urgent. Handle when possible labels May 14, 2024
@S0ly S0ly changed the title [Feature] CryptoBot payments CryptoBot payments May 15, 2024
@MrWeez
Copy link
Sponsor Collaborator

MrWeez commented May 22, 2024

@gru2007 Is there any news about fixes?

@gru2007
Copy link
Author

gru2007 commented May 22, 2024

@gru2007 Is there any news about fixes?

Excuse me for afk, I just haven’t enough time to solve that right now. I’ll do it in near future.

@MrWeez
Copy link
Sponsor Collaborator

MrWeez commented May 22, 2024

@gru2007 Is there any news about fixes?

Excuse me for afk, I just haven’t enough time to solve that right now. I’ll do it in near future.

Ok, no problem

@S0ly S0ly changed the title CryptoBot payments feat: CryptoBot payments Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Adding a new feature, or substantial improvements on existing functionality Low Priority Can wait, not urgent. Handle when possible Payment Gateway
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants