简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM