I would like to know how to build the code or if there is script I can use to be able to credit peoples accounts with credits if they purchase the credits.

Like if you pay $1, then you get one credit that can be used to buy things.
If you pay $5 then you get 6 credits.

Then with the credits I would like the people to be able to buy items with them.

The main reasons for credits is to make my site look better / professional, and for where people can get additional credits like if they buy certian ammounts.

Thanks in advance! :)

Dani AI

Generated

Short practical plan for automatically crediting accounts (answers and expands on 's suggestion). Use a payment provider for collecting money, but treat the provider's client-side redirect as purely cosmetic. The server must verify each payment (webhook/IPN or signed callback), match it to a pricing rule (for example $1 → 1 credit, $5 → 6 credits), and then record a single, auditable transaction that updates the user's credit balance.

A minimal data model and webhook flow (pseudocode):

-- tables
users(id, email, credits INT DEFAULT 0)
credit_packages(id, amount_cents INT, credits INT)  -- define $5 -> 600 cents -> 6 credits
payments(id, user_id, provider_txn_id, amount_cents INT, credits_awarded INT, status, created_at)

-- webhook handler (simplified)
onWebhook(payload):
  if not verifySignature(payload): return 400
  if payments.exists(provider_txn_id = payload.txn_id): return 200  -- idempotent
  pkg = findPackageByAmount(payload.amount_cents) or computeCredits(payload.amount_cents)
  create payments record with status = pending
  users.incrementCredits(user_id, pkg.credits)
  update payments status = completed
  send receipt email

Implementation notes and pitfalls: store money as integer cents to avoid floating-point errors. Always verify webhook signatures and use the provider transaction ID to prevent double-crediting. Log every step (who, when, why) so you can reconcile and handle refunds or chargebacks — when a refund happens, mark the original payment and deduct credits only after a verified refund notification; keep an audit trail rather than silently mutating history. For bonus credits, store them separately (e.g., bonus_credits, with optional expiry) so tracking and display are clear.

UX tips: show current balance and a clear breakdown (paid vs bonus), display the credits-to-currency rate at purchase time, show transaction history and receipts, and make the purchase flow obvious and reassuring. Test thoroughly in the payment provider's sandbox before going live.

Recommended Answers

All 2 Replies

Can paypal help me credit peoples accounts and then they can use the credits for other purchases? (not just buying credits)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.