跳到主要内容

Card via Stripe

Accept credit and debit card payments through Stripe's secure payment processing platform. This integration supports all major card networks with advanced fraud protection and 3D Secure authentication.

Setup

Please follow the common Stripe instructions to get set up with Stripe.

Integration

API Request

curl --request POST \
--url https://api.efundpay.com/v4/transactions \
--header 'Authorization: Bearer <token>' \
--header 'x-merchant-account-id: <x-merchant-account-id>' \
--header 'Content-Type: application/json' \
--data '{
"amount": 2500,
"currency": "USD",
"payment_method": {
"method": "stripe",
"payment_method_data": {
"type": "card",
"card": {
"number": "4242424242424242",
"exp_month": 12,
"exp_year": 2024,
"cvc": "123"
}
}
},
"external_identifier": "order-12345"
}'

Payment Flow

  1. Initialize Payment - Create payment request with EFundPay
  2. Client-Side Integration - Use Stripe.js for secure card data collection
  3. Payment Processing - Stripe processes the payment
  4. 3D Secure - Handle 3D Secure authentication if required
  5. Webhook Notification - Receive payment status via webhook
  6. Final Result - Handle success/failure response

Configuration

Required Parameters

  • amount - Payment amount in smallest currency unit (cents for USD)
  • currency - Three-letter ISO currency code
  • payment_method_data.type - Set to "card" for card payments
  • card.number - Card number
  • card.exp_month - Expiry month (1-12)
  • card.exp_year - Expiry year (4 digits)
  • card.cvc - Security code (CVV)

Optional Parameters

  • billing_address - Customer billing address
  • shipping_address - Customer shipping address
  • description - Payment description
  • metadata - Additional metadata

Client-Side Integration

Stripe.js Integration

// Load Stripe.js
const stripe = Stripe('pk_test_your_publishable_key');

// Create payment method
const {paymentMethod, error} = await stripe.createPaymentMethod({
type: 'card',
card: cardElement,
billing_details: {
name: 'John Doe',
email: 'john@example.com',
},
});

if (error) {
console.error('Error:', error);
} else {
// Send payment method ID to your server
makePayment(paymentMethod.id);
}

Payment Confirmation

async function makePayment(paymentMethodId) {
try {
const response = await fetch('/api/payments', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
payment_method_id: paymentMethodId,
amount: 2500,
currency: 'usd',
}),
});

const result = await response.json();
handlePaymentResult(result);
} catch (error) {
console.error('Payment failed:', error);
}
}

Response Handling

Success Response

{
"type": "transaction",
"id": "txn_123456789",
"status": "processing",
"stripe_payment_intent_id": "pi_1234567890",
"external_identifier": "order-12345"
}

Webhook Notification

{
"ll_transaction_id": "2022012601122644",
"merchant_transaction_id": "order-12345",
"payment_data": {
"payment_status": "PS",
"payment_amount": "25.00",
"payment_currency_code": "USD",
"payment_time": "20220126141430",
"stripe_payment_intent_id": "pi_1234567890",
"status": "succeeded"
}
}

Testing

Test Cards

Stripe provides various test card numbers:

  • Success: 4242424242424242
  • Decline: 4000000000000002
  • 3D Secure: 4000002500003155
  • Insufficient Funds: 4000000000009995

Test Environment

  • Use test API keys for development
  • Test with Stripe's test merchant account
  • Verify webhook notifications in test mode
  • Test 3D Secure flows

Security Considerations

PCI Compliance

  • Stripe handles PCI compliance for card data
  • Use Stripe.js for secure card data collection
  • Never store raw card data
  • Implement proper webhook signature verification

Fraud Prevention

  • Enable Stripe's risk management tools
  • Implement 3D Secure authentication
  • Monitor for suspicious activity
  • Use Stripe's fraud detection features

Common Issues

Payment Failures

  • Card Declined - Check card details and funds
  • 3D Secure Required - Implement 3D Secure flow
  • Invalid Amount - Ensure amount is in correct format
  • Currency Mismatch - Verify currency settings

Integration Issues

  • Webhook Not Received - Check webhook endpoint and signature
  • Payment Method Error - Verify payment method creation
  • Invalid API Key - Check API key configuration

Best Practices

User Experience

  • Implement proper loading states
  • Show clear error messages
  • Provide multiple payment options
  • Optimize for mobile devices

Technical Implementation

  • Use webhooks for real-time updates
  • Implement proper error handling
  • Store payment references
  • Handle network failures gracefully

Security

  • Always use HTTPS
  • Verify webhook signatures
  • Implement proper session management
  • Regular security audits

Support

For technical support with Card via Stripe integration:

  • EFundPay Support - Contact our technical team
  • Stripe Support - Use Stripe's support resources
  • Stripe Documentation - Comprehensive API documentation
Powered by Docusaurus