> ## Documentation Index
> Fetch the complete documentation index at: https://docs.caibo.digital/llms.txt
> Use this file to discover all available pages before exploring further.

# Alternative Payment Example

> Simple payment request without card details for alternative payment methods

# Overview

This example demonstrates a simplified payment request for alternative payment methods that don't require card details or browser information.

## Payment Request

```json theme={null}
{
  "name": "Test User",
  "email": "test.user@email.com",
  "phoneNumber": "1234567890",
  "address": "10 Unknown Street",
  "city": "Far Town",
  "state": "NA",
  "postalCode": "123456",
  "country": "US",
  "amount": 10.50,
  "unit": "USD",
  "originDomain": "example.com",
  "referenceId": "123-GA-456",
  "notifyUrl": "https://notify.me",
  "successUrl": "https://success.payment.com",
  "failureUrl": "http://fail.payment.com"
}
```

## Key Features

### Simplified Structure

* **No Card Data**: No card number, expiration, or CVV required
* **No Browser Info**: No browserInfo object needed
* **Customer Focus**: Emphasis on customer identification and contact

### Customer Information

* **Name**: Customer full name for identification
* **Email**: Primary contact for notifications
* **Phone**: Secondary contact method
* **Address**: Complete billing/shipping address

### Transaction Details

* **Amount**: \$10.50 USD transaction
* **Reference**: Merchant tracking ID (123-GA-456)
* **Callback URLs**: Success, failure, and notification endpoints

## Use Cases

### Bank Transfers

* Direct bank account debits
* ACH transfers
* Wire transfers
* SEPA payments (Europe)

### Digital Wallets

* PayPal
* Skrill
* Neteller
* Regional wallet services

### Buy Now, Pay Later

* Klarna
* Afterpay
* Affirm
* Sezzle

### Cryptocurrency

* Bitcoin payments
* Ethereum payments
* Stablecoin transactions
* Other crypto assets

## Implementation

### JavaScript Example

```javascript theme={null}
const alternativePayment = {
  name: "Test User",
  email: "test.user@email.com",
  phoneNumber: "1234567890",
  address: "10 Unknown Street",
  city: "Far Town",
  state: "NA",
  postalCode: "123456",
  country: "US",
  amount: 10.50,
  unit: "USD",
  originDomain: "example.com",
  referenceId: "123-GA-456",
  notifyUrl: "https://notify.me",
  successUrl: "https://success.payment.com",
  failureUrl: "http://fail.payment.com"
};

// Send payment request
const response = await fetch('https://your-h2h-endpoint.com', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your-api-key'
  },
  body: JSON.stringify(alternativePayment)
});

const result = await response.json();
console.log('Payment created:', result.paymentRequestId);
console.log('Redirect URL:', result.redirectUrl);
```

### PHP Example

```php theme={null}
<?php
$alternativePayment = [
    'name' => 'Test User',
    'email' => 'test.user@email.com',
    'phoneNumber' => '1234567890',
    'address' => '10 Unknown Street',
    'city' => 'Far Town',
    'state' => 'NA',
    'postalCode' => '123456',
    'country' => 'US',
    'amount' => 10.50,
    'unit' => 'USD',
    'originDomain' => 'example.com',
    'referenceId' => '123-GA-456',
    'notifyUrl' => 'https://notify.me',
    'successUrl' => 'https://success.payment.com',
    'failureUrl' => 'http://fail.payment.com'
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://your-h2h-endpoint.com');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($alternativePayment));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'X-API-Key: your-api-key'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$result = json_decode($response, true);

echo "Payment ID: " . $result['paymentRequestId'];
echo "Redirect URL: " . $result['redirectUrl'];
?>
```

## Payment Flow

### 1. Payment Creation

* Submit payment request with customer details
* Receive payment ID and redirect URL
* Store payment ID for status tracking

### 2. Customer Redirect

* Redirect customer to provided URL
* Customer completes payment on provider's page
* Customer returns via success/failure URL

### 3. Payment Completion

* Receive webhook notification
* Verify payment status
* Update order/account status
* Send confirmation to customer

## Advantages

### Simplicity

* **Minimal Data**: Only essential customer information required
* **No PCI Compliance**: No card data handling needed
* **Easy Integration**: Simple request structure

### Security

* **Reduced Risk**: No sensitive payment data stored
* **Provider Security**: Payment handled by specialized providers
* **Compliance**: Automatic regulatory compliance

### Customer Experience

* **Familiar Interface**: Customers use known payment methods
* **Trust**: Established payment provider brands
* **Convenience**: Saved payment methods and preferences

## Testing

### Test Data

```json theme={null}
{
  "name": "John Doe",
  "email": "john.doe@example.com",
  "phoneNumber": "+1234567890",
  "address": "123 Test Street",
  "city": "Test City",
  "state": "TS",
  "postalCode": "12345",
  "country": "US",
  "amount": 25.00,
  "unit": "USD",
  "referenceId": "TEST-ORDER-001"
}
```

### Test Scenarios

1. **Successful Payment**: Complete payment flow
2. **Cancelled Payment**: Customer cancels during payment
3. **Failed Payment**: Insufficient funds or other errors
4. **Invalid Data**: Test validation error handling

## Best Practices

### Data Validation

* Validate email format and deliverability
* Verify phone number format
* Check address completeness
* Validate country and currency combinations

### Error Handling

* Handle network timeouts gracefully
* Provide clear error messages to customers
* Log errors for debugging
* Implement retry mechanisms

### Security

* Use HTTPS for all communications
* Validate webhook signatures
* Implement rate limiting
* Monitor for suspicious activity

## Next Steps

1. Choose appropriate alternative payment methods for your market
2. Implement webhook handling for payment notifications
3. Set up proper error handling and logging
4. Test with real payment providers
5. Monitor payment success rates and optimize
