Integration Workflow

1

Generate Payment Key

The seller generates a payment key using key_generate.php

2

Payment Page

The buyer visits the payment page using the generated key

vypay.xyz/pay.php?key=YOUR_GENERATED_KEY
3

Process & Redirect

The payment is processed, and the buyer is redirected to the sellers site

4

Verify Payment

The seller verifies the payment was successful using check_payment.php

check_payment.php?email=YOUR_EMAIL

Integration Example

<a href="https://vypay.xyz/pay.php?key=YOUR_GENERATED_KEY">Buy Now</a>

Payment Verification

After a customer completes a payment, you should verify the transaction was successful before providing access to your products or services. VYPay provides a simple API endpoint for payment verification.

Verification Endpoint

GET check_payment.php

This endpoint checks if a payment was made to your email address within the last 10 seconds.

Parameters

Parameter Type Required Description
email string Yes (if no key) Email address of the payment recipient
key string Yes (if no email) The payment key used for the transaction
Note: The verification endpoint supports two methods:
  • Email verification: Use check_payment.php?email=your@email.com to verify if a payment was sent to this email address in the last 10 seconds.
  • Key verification: Use check_payment.php?key=YOUR_KEY to verify if a payment was processed using this specific payment key in the last 10 seconds.

Responses

Successful verification:

{ "success": true, "transaction_id": "123456", "amount": "50.00", "timestamp": "2023-05-19 15:30:45" }

Failed verification:

{ "success": false }

Implementation Examples

Here's how to implement payment verification in different programming languages:

<?php
// After the user is redirected back to your site
$merchantEmail = 'your-email@example.com';

// Make the API request
$response = file_get_contents("https://vypay.xyz/check_payment.php?email=$merchantEmail");
$result = json_decode($response, true);

if ($result && $result['success'] === true) {
    // Payment verified successfully
    $transactionId = $result['transaction_id'];
    $amount = $result['amount'];
    $timestamp = $result['timestamp'];
    
    // Grant access to your product or service
    echo "Payment successful! Transaction ID: $transactionId";
} else {
    // Payment not verified
    echo "Payment could not be verified. Please contact support.";
}
?>
// Node.js with Fetch API
const fetch = require('node-fetch');

async function verifyPaymentByEmail() {
  const merchantEmail = 'your-email@example.com';
  
  try {
    const response = await fetch(`https://vypay.xyz/check_payment.php?email=${merchantEmail}`);
    const result = await response.json();
    
    if (result.success === true) {
      // Payment verified successfully
      const transactionId = result.transaction_id;
      const amount = result.amount;
      const timestamp = result.timestamp;
      
      console.log(`Payment successful! Transaction ID: ${transactionId}`);
      // Grant access to your product or service
      return true;
    } else {
      // Payment not verified
      console.log('Payment could not be verified');
      return false;
    }
  } catch (error) {
    console.error('Verification error:', error);
    return false;
  }
}

// Alternative: verify by key
async function verifyPaymentByKey(paymentKey) {
  try {
    const response = await fetch(`https://vypay.xyz/check_payment.php?key=${paymentKey}`);
    const result = await response.json();
    return result.success === true;
  } catch (error) {
    console.error('Key verification error:', error);
    return false;
  }
}

// In your Express.js route handler
app.get('/payment-success', async (req, res) => {
  // You can get the key from the query parameters if you included it in the redirect URL
  const paymentKey = req.query.key;
  
  // Choose verification method based on your needs
  const verified = paymentKey 
    ? await verifyPaymentByKey(paymentKey)
    : await verifyPaymentByEmail();
  
  if (verified) {
    res.send('Payment successful! Thank you for your purchase.');
  } else {
    res.send('Payment verification failed. Please contact support.');
  }
});
# Python with requests
import requests

def verify_payment():
    merchant_email = 'your-email@example.com'
    
    try:
        response = requests.get(f'https://vypay.xyz/check_payment.php?email={merchant_email}')
        result = response.json()
        
        if result.get('success') is True:
            # Payment verified successfully
            transaction_id = result['transaction_id']
            amount = result['amount']
            timestamp = result['timestamp']
            
            print(f'Payment successful! Transaction ID: {transaction_id}')
            # Grant access to your product or service
            return True
        else:
            # Payment not verified
            print('Payment could not be verified')
            return False
    except Exception as e:
        print(f'Verification error: {e}')
        return False

# In your Flask route handler
@app.route('/payment-success')
def payment_success():
    verified = verify_payment()
    
    if verified:
        return 'Payment successful! Thank you for your purchase.'
    else:
        return 'Payment verification failed. Please contact support.'