Jan
Jan

Reputation: 33

PHP: PayPal Integration with Credits

I have this:

<form method="post" action="paypal.php">
            <label for="type">How?</label><br />
            <select name="type">
                <option value="pp">PayPal</option>
            </select><br />

            <label for="amount">How much?</label>
            <input type="number" step="any" id="amount" name="amount" placeholder="50.00" />
            <br />
            <input type="submit" value="Buy credits" name="charge" />
 </form>

I want users to be able to buy credits with PayPal.

$50 = 50 Credits.

But I don't know how to do this. Can you help me with this? If the payment is confirmed, the user should receive the exact number of credits that he has paid for.

When I open a page ("confirmed.php"), I don't know if the user has really paid $50 and not just $5. To add credits to a user account just do

addCredits($amount);

Can you maybe send me a link or the PHP code?

Upvotes: 1

Views: 658

Answers (1)

Insomniac
Insomniac

Reputation: 446

Take a look at the PayPal API. Specifially this: https://github.com/paypal/codesamples-php/blob/master/Merchant/sample/code/DoDirectPayment.php#L80. That way you'll be notified about the payment. That's also the place to add credits.

Upvotes: 1

Related Questions