Skip to main content

Overview

With Oceanpayment's JS SDK, you can embed the payment form directly into your checkout page. Customers can complete payments without leaving your site, ensuring a seamless brand experience.

Embedded Payments

Embedded payments allow your customers to pay directly on your website, without redirection to a third-party page. This reduces checkout friction and increases conversion rates.

📈
Higher Conversion
Reduce user drop-off caused by page redirects; increase payment success rates by up to 30%.
🎨
Brand Consistency
Fully customizable payment form that matches your site design.
🚀
Smooth Experience
Seamless, app-like payment flow.
Our Most Popular Payment Solution

Before You Start

Note

Embedded payments currently support Credit Card, GooglePay, and ApplePay only.

Flowchart

How It Works

  1. Load the Oceanpayment JS SDK on your checkout page:
//Load Oceanpayment
<script src="https://secure.oceanpayment.com/pages/js/oceanpayment.js"></script>

<script src="https://secure.oceanpayment.com/pub/js/jquery/jq.js"></script>
  1. Add a container element for the payment UI:
//Load Oceanpayment payment page
<div id="oceanpayment-element"></div>
  1. Initialize the payment UI in the container:
  • Pass true for sandbox environment
  • leave empty for production
<script>
$(function() {
//Passing `true` commits to the sandbox environment; passing '' commits to the production environment.
Oceanpayment.init(true,'','');
});
</script>
  1. Submit payment:
  • Call the payment method, ensure duplicate submissions are prevented when initiating payment.
  • Required form parameters must be converted to JSON using transformToJson() before calling checkout().
  • Then call checkout() to submit the required parameters to the Oceanpayment payment gateway.
//Submit parameters
<script>
//Payment
function pay() {
//Get form elements
var register = $("#payForm");
//Serialize()
var formData = register.serializeArray();
//Submit parameter information to Oceanpayment
Oceanpayment.checkout(transformToJson(formData));
}

//JSON data
function transformToJson(formData){
var obj={}
for (var i in formData) {
obj[formData[i].name]=formData[i]['value'];
}
return obj;
}
</script>

Handling Payment Results

  • Frontend: Listen for payment result events to get immediate feedback.
  • Backend: Use noticeUrl to receive asynchronous notifications and confirm the final payment status.
Note

Oceanpayment sends the payment result to your backUrl page. The backUrl must exactly match the current page URL, including the full path, to allow the CallBack() method to receive the payment response.

var oceanpaymentCallBack = function(data){}
  1. If card information fails validation, data.msg will contain an error message, for example:
//Incorrect card number
{"code":-1, "msg":"Your credit card number is incorrect."}
  1. If data.msg is empty, the card information is valid. In this case, handle the payment response and check the following scenarios:
  • If xml->pay_url is empty, no 3D verification is required; he XML contains the payment result directly. An asynchronous notification will also be sent to noticeUrl.
  • If xml->pay_url is present, redirect the customer to complete 3D verification. After verification, the payment result will be sent again to backUrl (default received via $_POST). An asynchronous notification will also be triggered via noticeUrl.
var oceanpaymentCallBack = function(data){	
if(data.msg){
//Card information error processing
console.log(data.msg);
}else{
//Processing order return
//Receive the backUrl response and parse the returned XML.
console.log(data);
}
}
  1. Payment Response Example:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<notice_type>transaction</notice_type>
<push_dateTime>2025-09-03 10:21:14</push_dateTime>
<account>995149</account>
<terminal>99514901</terminal>
<signValue>924347D8E9C9BAC2EC91449C70540FF49E0DD5711F03E8A871DCA34CED023AB6</signValue>
<methods>Credit Card</methods>
<order_number>JSCSE-3128790866</order_number>
<card_country>PL</card_country>
<order_currency>USD</order_currency>
<order_amount>0.01</order_amount>
<order_notes></order_notes>
<card_number>411111***1111</card_number>
<card_type>Visa</card_type>
<payment_country></payment_country>
<payment_id>250902111334242179639</payment_id>
<payment_authType>2</payment_authType>
<payment_status>-1</payment_status>
<payment_details>80093:3D Authorized Service not completed</payment_details>
<payment_solutions></payment_solutions>
<payment_risk></payment_risk>
<payment_amount></payment_amount>
<payment_exchangeRate></payment_exchangeRate>
<auth_reason></auth_reason>
<auth_code></auth_code>
<pay_userId></pay_userId>
<pay_url>https://secure.oceanpayment.com:443/gateway/direct/redirect?pay_id=af5e28ee57061f4fd1dd307a7bc56c7289d9041d0b5494195d91b7c5166b6e30</pay_url>
</response>
  • Merchants redirect users to pay_url:
HTTP/1.2 301 Moved Permanently
Location: {pay_url}
  1. Check payment status, and verify the final transaction status using asynchronous notifications sent to noticeUrl.

Signature

The signature (signValue) format differs depending on the Hosted Checkout redirect mode you choose. Refer the Signature and Verification section for detailed instructions.

API Reference

👉Explore our to get started immediately.