# PaymentConductor ledger (v1.6.0)
psql "$DATABASE_URL" -f data/migrations/004_payment_transactions.sqlSee also data/migrations/README.md and PaymentConductor docs.
Add to .env.local (development) or Vercel/K8s secrets (production):
# WayForPay Credentials (from wayforpay.com/en/account/api)
WAYFORPAY_MERCHANT_ACCOUNT=test_merch_n1 # Production: your_merchant_account
WAYFORPAY_SECRET_KEY=flk3409refn54t54t*FNJRET # Your actual secret key
WAYFORPAY_DOMAIN=ring-platform.org # Your registered domain
# Application URL (for webhooks)
NEXTAUTH_URL=https://ring-platform.org # Must be HTTPS for production- Login to wayforpay.com
- Go to Settings → API
- Configure webhook URL:
https://your-domain.com/api/payments/wayforpay/webhook(routed via PaymentConductor inlib/payments/conductor/) - CRITICAL: Must be HTTPS
- CRITICAL: Must be publicly accessible (not localhost)
- Save and test webhook connectivity
WAYFORPAY_MERCHANT_ACCOUNT=test_merch_n1
WAYFORPAY_SECRET_KEY=flk3409refn54t54t*FNJRET
WAYFORPAY_DOMAIN=localhost # OK for testingTest Cards:
- Success:
4111111111111111(Visa) - Decline: Check WayForPay docs for specific test scenarios
# 1. Install dependencies
npm install
# 2. Set up environment
cp env.local.template .env.local
# Edit .env.local with WayForPay test credentials
# 3. Run database migration
psql -U ring_user -d ring_platform -f scripts/create-payments-table.sql
# 4. Start dev server
npm run dev
# 5. Test locally with ngrok (for webhook testing)
ngrok http 3000
# Configure ngrok URL in WayForPay dashboard webhook# 1. Configure Vercel environment variables
vercel env add WAYFORPAY_MERCHANT_ACCOUNT production
vercel env add WAYFORPAY_SECRET_KEY production
vercel env add WAYFORPAY_DOMAIN production
# 2. Ensure database has payments table
# Run migration on production PostgreSQL
# 3. Deploy
vercel --prod
# 4. Configure webhook in WayForPay dashboard
# URL: https://your-domain.com/api/payments/wayforpay/webhook# 1. Create secret for WayForPay credentials
kubectl create secret generic wayforpay-credentials \
--from-literal=WAYFORPAY_MERCHANT_ACCOUNT=your_account \
--from-literal=WAYFORPAY_SECRET_KEY=your_secret \
--from-literal=WAYFORPAY_DOMAIN=your_domain.com \
-n ring-platform-org
# 2. Run database migration
kubectl exec -it postgres-0 -n ring-platform-org -- \
psql -U ring_user -d ring_platform -f /scripts/create-payments-table.sql
# 3. Update deployment to use secret
# Edit k8s/deployment.yaml to reference wayforpay-credentials
# 4. Apply changes
kubectl apply -f k8s/deployment.yaml
# 5. Verify webhook endpoint
curl https://your-domain.com/api/payments/wayforpay/webhook
# Should return: {"status":"ok","service":"wayforpay-webhook"}- Login as SUBSCRIBER
- Navigate to Profile → Membership
- Click "Upgrade to MEMBER"
- Payment modal should show ₴299 UAH
- Click "Proceed to Card Payment"
- Should redirect to secure.wayforpay.com
- Complete test payment
- Should return to success page
- Verify role upgraded to MEMBER
# Check webhook health
curl https://your-domain.com/api/payments/wayforpay/webhook
# Expected: {"status":"ok","service":"wayforpay-webhook"}
# Check logs for webhook receipt
# Should see: "WayForPay webhook: Received notification"-- Check payments table exists
SELECT * FROM payments LIMIT 1;
-- Check payment records
SELECT "orderId", "userId", "targetRole", amount, status, "createdAt"
FROM payments
ORDER BY "createdAt" DESC
LIMIT 10;
-- Verify role upgrade
SELECT id, data->>'email', data->>'role', updated_at
FROM users
WHERE data->>'role' = 'MEMBER'
ORDER BY updated_at DESC
LIMIT 10;# Payment initiation
grep "WayForPay: Initiating payment request" logs/
# Webhook receipt
grep "WayForPay webhook: Received notification" logs/
# Signature validation
grep "Invalid signature" logs/ # Should be ZERO
# Role upgrades
grep "Role upgrade: User role upgraded successfully" logs/
# Failures
grep "WayForPay.*error\|failed" logs/ -i- Payment success rate < 90%
- Webhook signature validation failures
- Role upgrade failures
- Database connection errors
- WayForPay API timeouts
Fix: Add missing WAYFORPAY_* variables to .env.local
Cause: Wrong WAYFORPAY_SECRET_KEY Fix: Verify secret key matches WayForPay dashboard exactly
Cause: URL not publicly accessible or not HTTPS Fix:
- Development: Use ngrok for local testing
- Production: Verify HTTPS certificate and DNS
Cause: Database error or upgrade service failure Fix: Check logs for upgrade-user-role errors
Cause: Missing UI component or action import Fix: Verify payment-modal.tsx exists and membership-payment action imported
- 10+ test payments processed successfully
- Zero signature validation failures
- 100% role upgrade success rate
- Webhook latency <2 seconds
- 50+ SUBSCRIBER→MEMBER conversions
- >95% payment success rate
- >80% payment completion rate
- <5% support tickets per transaction
- ₴15,000+ revenue from membership upgrades
- 15%+ SUBSCRIBER→MEMBER conversion rate
- Zero security incidents
- Zero fraudulent transactions
WayForPay Integration: Ready for Launch ✅
Revenue Engine: Armed and Operational 💰
Security: PCI-DSS Compliant 🔐
🔥 DEPLOY AND CONQUER 🔥