0
votes

I'm at the very beginning of using stripe in my project (with Laravel Framework), and I want to ask a question. How can I add some points after a payment in Stripe?

I even found I package for the points system, but I don't know how to link or trigger the event, after payment.

My idea is to follow this workflow to implement Stripe, but what can I do for the points after? http://felicianoprochera.com/simple-payments-with-stripe-and-laravel/

So... what I have to build is a rechargeable points system, so after a certain charge -> corresponds a certain amount of points to spend for products. What "road" should I take in able to do this?

EDIT. For doing this, I decided that the simpler way is to insert something in my OrderController, after the charge, so I can add the points. For doing this I can create an integrer in the user table and store the points, and add points based of the product. Or I can use laravel-pointable package to add points.

This is my OrderController, this is the part of charging.

public function createStripeCharge($product_id, $product_price, $product_name, $customer)
{
    try {
        $charge = \Stripe\Charge::create(array(
            "amount" => $product_price,
            "currency" => "brl",
            "customer" => $customer->id,
            "description" => $product_name
        ));
    } catch(\Stripe\Error\Card $e) {
        return redirect()
            ->route('index')
            ->with('error', 'Your credit card was been declined. Please try again or contact us.');
    }

    return $this->postStoreOrder($product_name);
}

Which is the best and easiest way to do it?

1
For the points nothing because i don't know exactly how to do it :)LukeCage

1 Answers

0
votes

If you're using something like laravel-pointable, I guess you would just add points after a successful charge - i.e., as long as there was no error.