Hello there,
I have an question regarding integration with cybersource payment gateway.
Basically I have a store with the checkout and I would like to redirect customer to the cybersource payment gateway and there process a payment.
It is very important to me to not pass any customer card details from my website/ checkout or storing the customer card details on the server.
I checked the documentation and seems to me that I need apply checkout from cybersource in order to process payment? so is there no possibility to just hit some endpoint by submit button with all required data and process payment and then set up some webhook with payment status update and redirection?
I also ask you to be understanding, I am a beginner in this.
Thanks!
Hi @jukowal123, Thank you for your question. One of our agents will get back to you soon. Until then, if any community member has information you feel may help, please reply to this thread.
Hey @jukowal123,
Please contact CyberSource directly for assistance. Here's the phone number (800) 709-7779.
To integrate with the CyberSource payment gateway and achieve your goal of redirecting customers to the CyberSource payment gateway for processing payments without handling or storing customer card details, you can utilize the CyberSource Secure Acceptance Hosted Checkout solution. This solution allows you to redirect customers to a secure payment page hosted by CyberSource, ensuring that you do not have to handle sensitive card data.
Steps to Implement CyberSource Secure Acceptance Hosted Checkout:
1. Create an Account on CyberSource:
- Sign up for a CyberSource account if you do not already have one.
2. Set Up Secure Acceptance Hosted Checkout:
- Configure the Secure Acceptance Hosted Checkout profile in the CyberSource Business Center. This involves setting up the payment page, specifying return URLs, and configuring security settings.
3. Generate Secure Acceptance Form:
- Generate a secure form that includes the necessary data fields and security signature. This form will be submitted to CyberSource to initiate the payment process.
4. Redirect to CyberSource:
- On your checkout page, upon clicking the submit button, redirect the customer to the CyberSource payment page with the generated form data.
5. Handle Payment Status Updates:
- Set up webhooks (also known as Payment Notification Services) to receive real-time updates on the payment status. CyberSource will send notifications to your specified endpoint about the payment status.
6. Redirect After Payment:
- After the payment is processed, CyberSource will redirect the customer back to your specified return URL with the payment status.
Here is an example of how you might implement this:
Step-by-Step Implementation
1. Generate Secure Acceptance Form Data:
- You will need to generate a form with the required fields and security signature. This typically includes fields like `access_key`, `profile_id`, `transaction_uuid`, `signed_field_names`, `signature`, etc.
2. Secure Acceptance Form Example:
```html
<form id="payment_form" action="https://secureacceptance.cybersource.com/pay" method="post">
<input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" />
<input type="hidden" name="profile_id" value="YOUR_PROFILE_ID" />
<input type="hidden" name="transaction_uuid" value="UNIQUE_TRANSACTION_UUID" />
<input type="hidden" name="signed_field_names" value="access_key,profile_id,transaction_uuid,signed_field_names,signed_date_time,amount,currency" />
<input type="hidden" name="signed_date_time" value="CURRENT_DATE_TIME" />
<input type="hidden" name="amount" value="TRANSACTION_AMOUNT" />
<input type="hidden" name="currency" value="TRANSACTION_CURRENCY" />
<input type="hidden" name="signature" value="GENERATED_SIGNATURE" />
<input type="submit" value="Pay Now" />
</form>
```
3. Configure Webhooks:
- In the CyberSource Business Center, configure the Payment Notification Services (webhooks) to send payment status updates to your server.
4. Handle Webhook Notifications:
- Implement an endpoint on your server to handle the webhook notifications from CyberSource. This endpoint will receive updates about the payment status and can update your system accordingly.
Example Webhook Endpoint (in Node.js/Express):
```javascript
// START
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const crypto = require('crypto');
app.use(bodyParser.json());
app.post('/cybersource-webhook', (req, res) => {
const payload = req.body;
// Verify the signature
const signature = payload.signature;
const signedFields = payload.signed_fields.split(',');
const signedData = signedFields.map(field => `${field}=${payload[field]}`).join(',');
const hash = crypto.createHmac('sha256', 'YOUR_SECRET_KEY').update(signedData).digest('base64');
if (hash === signature) {
// Process the payment notification
console.log('Payment status:', payload.payment_status);
// Update your order status in the database
} else {
console.log('Invalid signature');
}
res.sendStatus(200);
});
app.listen(3000, () => {
console.log('Server is running on port 3000');
});
// END
```
Resources:
- CyberSource Secure Acceptance Hosted Checkout Documentation
For detailed guidance and support, you can refer to the CyberSource documentation and contact CyberSource support directly.