Overview
Using the Oceanpayment SDK, merchants can embed the payment form directly into their checkout page. Customers can complete payments without redirection, improving conversion rates while maintaining full brand consistency. Only credit cards, GooglePay, and ApplePay integrations are supported.
How It Works
- Credit Card
- GooglePay
- ApplePay
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Oceanpayment Debit/Credit Card|One-Page Checkout</title>
</head>
<body>
<!--Form submission -->
<form id="payForm">
<label>Account number: </label>
<input class="form-control" type="text" id="account" name="account" value='provided by Oceanpayment technical support'/>
<label>Terminal number:</label>
<input class="form-control" type="text" id="terminal" name="terminal" value='provided by Oceanpayment technical support'/>
<label>signValue</label>
<input class="form-control" type="text" id="signValue" name="signValue" value=""/>
<label>Key-public key</label>
<input class="form-control" type="text" id="key" name="key" value='provided by Oceanpayment technical support'/>
<label>Website order number: </label>
<input class="form-control" type="text" id="order_number" name="order_number" value=""/>
<label>Trading currency:</label>
<input class="form-control" type="text" id="order_currency" name="order_currency" value="USD"/>
<label>Transaction amount:</label>
<input class="form-control" type="text" id="order_amount" name="order_amount"value="0.01"/>
<label>Return address:</label>
<input class="form-control" type="text" id="backUrl" name="backUrl" value="">
<label>Payment method:</label>
<input class="form-control" type="text" id="methods" name="methods" value="Credit Card"/>
<label>Cardholder name:</label>
<input class="form-control" type="text" id="billing_lastName" name="billing_lastName" value="test"/>
<label>Cardholder Last Name:</label>
<input class="form-control" type="text" id="billing_firstName" name="billing_firstName" value="test"/>
<label>Cardholder Email:</label>
<input class="form-control" type="text" id="billing_email" name="billing_email" value="20200312@ebanx.com"/>
<label>Cardholder Country::</label>
<input class="form-control" type="text" id="billing_country" name="billing_country" value="CN"/>
<label>Cardholder State/Province:</label>
<input class="form-control" type="text" id="billing_state" name="billing_state" value="GD"/>
<label>Cardholder City:</label>
<input class="form-control" type="text" id="billing_city" name="billing_city" value="sz"/>
<label>Cardholder address:</label>
<input class="form-control" type="text" id="billing_address" name="billing_address" value="test"/>
<label>Cardholder Zip Code:</label>
<input class="form-control" type="text" id="billing_zip" name="billing_zip" value="100000"/>
<label>Cardholder IP:</label>
<input class="form-control" type="text" id="billing_ip" name="billing_ip" value="127.0.0.1"/>
<label>Product name:</label>
<input class="form-control" type="text" id="productName" name="productName" value="NOKIA N78"/>
<label>Quantity:</label>
<input class="form-control" type="text" id="productNum" name="productNum" value="2"/>
<label>SKU:</label>
<input class="form-control" type="text" id="productSku" name="productSku" value="SKU026123"/>
<!--Load Oceanpayment payment page Div-->
<div id="oceanpayment-element"></div>
<div class="row">
<div class="col-md-7">
<div class="form-group">
<button id="payNow" type="button" class="btn btn-success footable-show" onclick="pay();">Pay Now</button>
</div>
</div>
</div>
</form>
</body>
</html>
<!-- sha256 Js encryption reference, it is recommended to use back-end sha256 encryption, the encryption structure can not be exposed to the front-end -->
<script src="https://developers.oceanpayment.com/assets/img/payment/sha256.js"></script>
<script src="https://secure.oceanpayment.com/pub/js/jquery/jq.js"></script>
<!-- Loading oceanpayment JS -->
<script src="https://secure.oceanpayment.com/pages/js/oceanpayment.js"></script>
<script>
//Initialization
$(function() {
//Pass true to submit to the sandbox environment, and pass empty to submit to the production environment.
Oceanpayment.init('','','');
});
//Signature example, for encryption security, it must be encrypted on the backend! ! !
var signValue = sha256_digest($('#account').val()+$('#terminal').val()+$('#order_number').val()
+$('#order_currency').val()+$('#order_amount').val()+$('#billing_firstName').val()
+$('#billing_lastName').val()+$('#billing_email').val()+'SecureCode->provided by Oceanpayment technical support');
$("#signValue").val(signValue);
//Get the backUrl of the current page
var url = window.parent.location.href;
$("#backUrl").val(url);
//Callback processing
var oceanpaymentCallBack = function(data){
if(data.msg){
//Processing card information error
console.log(data.msg);
}else{
//Handle the order and return
console.log(data);
}
}
//Call payment
function pay() {
var register = $("#payForm");
//Jquery serialize() method
var formData = register.serializeArray();
Oceanpayment.checkout(transformToJson(formData));
}
//Collate the json of the submitted data
function transformToJson(formData){
var obj={}
for (var i in formData) {
obj[formData[i].name]=formData[i]['value'];
}
return obj;
}
//An example of randomly generating an order number
var order_number ='JSCSE-'+Math.floor(Math.random()*Math.pow(10,10));
$("#order_number").val(order_number);
</script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Oceanpayment GooglePay|One-Page Checkout</title>
</head>
<body>
<!--Form submission -->
<form id="payForm">
<label>Account number: </label>
<input class="form-control" type="text" id="account" name="account" value='provided by Oceanpayment technical support'/>
<label>Terminal number:</label>
<input class="form-control" type="text" id="terminal" name="terminal" value='provided by Oceanpayment technical support'/>
<label>signValue</label>
<input class="form-control" type="text" id="signValue" name="signValue" value=""/>
<label>Key-public key</label>
<input class="form-control" type="text" id="key" name="key" value='provided by Oceanpayment technical support'/>
<label>Website order number: </label>
<input class="form-control" type="text" id="order_number" name="order_number" value=""/>
<label>Trading currency:</label>
<input class="form-control" type="text" id="order_currency" name="order_currency" value="USD"/>
<label>Transaction amount:</label>
<input class="form-control" type="text" id="order_amount" name="order_amount"value="0.01"/>
<label>Return address:</label>
<input class="form-control" type="text" id="backUrl" name="backUrl" value=""/>
<label>Payment method:</label>
<input class="form-control" type="text" id="methods" name="methods" value="GooglePay"/>
<label>Cardholder name:</label>
<input class="form-control" type="text" id="billing_lastName" name="billing_lastName" value="test"/>
<label>Cardholder Last Name:</label>
<input class="form-control" type="text" id="billing_firstName" name="billing_firstName" value="test"/>
<label>Cardholder Email:</label>
<input class="form-control" type="text" id="billing_email" name="billing_email" value="20200312@ebanx.com"/>
<label>Cardholder Country::</label>
<input class="form-control" type="text" id="billing_country" name="billing_country" value="CN"/>
<label>Cardholder State/Province:</label>
<input class="form-control" type="text" id="billing_state" name="billing_state" value="GD"/>
<label>Cardholder City:</label>
<input class="form-control" type="text" id="billing_city" name="billing_city" value="sz"/>
<label>Cardholder address:</label>
<input class="form-control" type="text" id="billing_address" name="billing_address" value="test"/>
<label>Cardholder Zip Code:</label>
<input class="form-control" type="text" id="billing_zip" name="billing_zip" value="100000"/>
<label>Cardholder IP:</label>
<input class="form-control" type="text" id="billing_ip" name="billing_ip" value="127.0.0.1"/>
<label>Product name:</label>
<input class="form-control" type="text" id="productName" name="productName" value="NOKIA N78"/>
<label>Quantity:</label>
<input class="form-control" type="text" id="productNum" name="productNum" value="2"/>
<label>SKU:</label>
<input class="form-control" type="text" id="productSku" name="productSku" value="SKU026123"/>
<!--Load Oceanpayment payment page Div-->
<div id="oceanpayment-googlepayelement"></div>
</form>
</body>
</html>
<!-- sha256 Js encryption reference, it is recommended to use back-end sha256 encryption, the encryption structure can not be exposed to the front-end -->
<script src="https://developers.oceanpayment.com/assets/img/payment/sha256.js"></script>
<script src="https://secure.oceanpayment.com/pub/js/jquery/jq.js"></script>
<!-- Loading oceanpayment JS -->
<script src="https://secure.oceanpayment.com/pages/js/oceanpayment-googlepay.js"></script>
<script>
//Initialization
$(function() {
//Pass true to submit to the sandbox environment, and pass empty to submit to the production environment.
onePageGooglePay.init(true, {
cssUrl: '',/*Pass the address of online css stye file to control the size of the Button.*/
//Pass the order amount, currency and country of the order
transactionInfo: {
orderCurrency:$('#order_currency').val(), /*Transaction Currency*/
orderAmount:$('#order_amount').val(), /*Transaction Amount*/
billCountry:$('#billing_country').val() /*Billiing country*/
},
buttonStyle: {
buttonColor:'',/*Colors of Button*/
buttonType:'',/*Types of Button*/
buttonRadius:'',/*Radius*/
buttonSizeMode:'',/*Button Style*/
buttonLocale:''/*Button Langauge*/
}
});
});
//Signature example, for encryption security, it must be encrypted on the backend! ! !
var signValue = sha256_digest($('#account').val()+$('#terminal').val()+$('#order_number').val()
+$('#order_currency').val()+$('#order_amount').val()+$('#billing_firstName').val()
+$('#billing_lastName').val()+$('#billing_email').val()+'SecureCode->provided by Oceanpayment technical support');
$("#signValue").val(signValue);
//Get the backUrl of the current page
var url = window.parent.location.href;
$("#backUrl").val(url);
//Callback processing
ar oceanpaymentGooglePayCallBack= function(data){
if (data.code == 2) {
opGooglepay();
}else{
//Handle the order and return
console.log(data);
}
}
//Call payment
function opGooglepay() {
var register = $("#payForm");
//Jquery serialize() method
var formData = register.serializeArray();
onePageGooglePay.checkout(transformToJson(formData));
}
//Collate the json of the submitted data
function transformToJson(formData){
var obj={}
for (var i in formData) {
obj[formData[i].name]=formData[i]['value'];
}
return obj;
}
//An example of randomly generating an order number
var order_number ='JSCSE-'+Math.floor(Math.random()*Math.pow(10,10));
$("#order_number").val(order_number);
</script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Oceanpayment ApplePay|One-Page Checkout</title>
</head>
<body>
<!--Form submission -->
<form id="payForm">
<label>Account number: </label>
<input class="form-control" type="text" id="account" name="account" value='provided by Oceanpayment technical support'/>
<label>Terminal number:</label>
<input class="form-control" type="text" id="terminal" name="terminal" value='provided by Oceanpayment technical support'/>
<label>signValue</label>
<input class="form-control" type="text" id="signValue" name="signValue" value=""/>
<label>Website order number: </label>
<input class="form-control" type="text" id="order_number" name="order_number" value=""/>
<label>Trading currency:</label>
<input class="form-control" type="text" id="order_currency" name="order_currency" value="USD"/>
<label>Transaction amount:</label>
<input class="form-control" type="text" id="order_amount" name="order_amount"value="0.01"/>
<label>Return address:</label>
<input class="form-control" type="text" id="backUrl" name="backUrl" value=""/>
<label>Payment method:</label>
<input class="form-control" type="text" id="methods" name="methods" value="ApplePay"/>
<label>Customer name:</label>
<input class="form-control" type="text" id="billing_lastName" name="billing_lastName" value="test"/>
<label>Customer Last Name:</label>
<input class="form-control" type="text" id="billing_firstName" name="billing_firstName" value="test"/>
<label>Customer Email:</label>
<input class="form-control" type="text" id="billing_email" name="billing_email" value="20200312@ebanx.com"/>
<label>Customer Country::</label>
<input class="form-control" type="text" id="billing_country" name="billing_country" value="CN"/>
<label>Customer State/Province:</label>
<input class="form-control" type="text" id="billing_state" name="billing_state" value="GD"/>
<label>Customer City:</label>
<input class="form-control" type="text" id="billing_city" name="billing_city" value="sz"/>
<label>Customer address:</label>
<input class="form-control" type="text" id="billing_address" name="billing_address" value="test"/>
<label>Customer Zip Code:</label>
<input class="form-control" type="text" id="billing_zip" name="billing_zip" value="100000"/>
<label>Customer IP:</label>
<input class="form-control" type="text" id="billing_ip" name="billing_ip" value="127.0.0.1"/>
<label>Product name:</label>
<input class="form-control" type="text" id="productName" name="productName" value="NOKIA N78"/>
<label>Quantity:</label>
<input class="form-control" type="text" id="productNum" name="productNum" value="2"/>
<label>SKU:</label>
<input class="form-control" type="text" id="productSku" name="productSku" value="SKU026123"/>
<label>Unit Price:</label>
<input class="form-control" type="text" id="productPrice" name="productPrice" value="500"/>
<!--Load Apple Pay Button Div-->
<div id="oceanpayment-Applepayelement"></div>
</form>
</body>
</html>
<!-- sha256 Js encryption reference, it is recommended to use back-end sha256 encryption, the encryption structure can not be exposed to the front-end -->
<script src="https://developers.oceanpayment.com/assets/img/payment/sha256.js"></script>
<script src="https://secure.oceanpayment.com/pub/js/jquery/jq.js"></script>
<!-- Loading oceanpayment JS -->
<script src="https://secure.oceanpayment.com/pages/js/oceanpayment-applepay.js"></script>
<script>
//Initialization
$(function() {
//Pass true to submit to the sandbox environment, and pass empty to submit to the production environment.
onePageApplePay.init(true, {
terminal: "99514901",
cssUrl: '',/*Pass address of online css style file to control the size of the button*/
transactionInfo: {
orderCurrency:$('#order_currency').val(),/*Order Currency*/
orderAmount:$('#order_amount').val(),/*Order Amount*/
billCountry:$('#billing_country').val(),/*Billing Country*/
orderNumber:$('#order_number').val(),/*Order Number*/
billAddress:$('#billing_address').val() /*Billing Address*/
},
buttonStyle: {
buttonstyle:'', /*Colors of Button*/
type:'' /*Types of Button*/
}
});
});
//Signature example, for encryption security, it must be encrypted on the backend! ! !
var signValue = sha256_digest($('#account').val()+$('#terminal').val()+$('#order_number').val()
+$('#order_currency').val()+$('#order_amount').val()+$('#billing_firstName').val()
+$('#billing_lastName').val()+$('#billing_email').val()+'SecureCode->provided by Oceanpayment technical support');
$("#signValue").val(signValue);
//Get the backUrl of the current page
var url = window.parent.location.href;
$("#backUrl").val(url);
//Callback processing
var oceanpaymentCallBack = function(data){
if(data.msg){
//Processing card information error
console.log(data.msg);
}else{
//Handle the order and return
console.log(data);
}
}
//Return of payment,the address of backUrl has to be the ##Homologous address##,so that to call oceanpaymentApplePayCallBack method。
var oceanpaymentApplePayCallBack = function(data){
if (data.code == 2) {
//Evoke the button to call payment method
opApplepay();
}else{
/*Process returns of order*/
//console.log(data);
//Receiving backUrl,Parsing xml
//Estimate the following two circumstance:
//if xml->pay_url is empty,the return xml is payment result, so that evoke the noticeUrl information.
//if xml->pay_url is No empty,redirect to pay_url to finish 3D Authriozation. At this time the result of payment is sent to backUrl,
//Using $_POST to receive return by default, The noticeUrl asynchronous notification is also triggered.
}
}
//Call payment
function opApplepay() {
var register = $("#payForm");
//Jquery serialize() method
var formData = register.serializeArray();
onePageApplePay.checkout(transformToJson(formData));
}
//Collate the json of the submitted data
function transformToJson(formData){
var obj={}
for (var i in formData) {
obj[formData[i].name]=formData[i]['value'];
}
return obj;
}
//An example of randomly generating an order number
var order_number ='JSCSE-'+Math.floor(Math.random()*Math.pow(10,10));
$("#order_number").val(order_number);
</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.
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.
- Credit Card
- GooglePay
- ApplePay
var oceanpaymentCallBack = function(data){}
- 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."}
- 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);
}
}
var oceanpaymentGooglePayCallBack = function(data){}
2.If data.code == 2, it means the Google Pay button loaded successfully. In the else block, receive the payment response and determine the following two scenarios:
- If the
xml->pay_urlfield is empty, then thexmlfile contains the returned payment result. In this case, an asynchronousnoticeUrlnotification will also be triggered. - If the
xml->pay_urlfield is not empty, a redirect is needed to open thepay_urlto complete 3D validation. The payment result will then be sent back tobackUrl, which by default uses $_POST to receive the return. This will also trigger an asynchronous notification vianoticeUrl.
var oceanpaymentGooglePayCallBack = function(data){
if (data.code == 2) {
opGooglepay();
}else{
//Handle order return.
//console.log(data)
}
- When
data.code== 3, it means the user has closed the Google Pay payment pop-up. The data returned format is:
{"code":3,"msg":"","method":"GooglePay"}
var oceanpaymentApplePayCallBack = function(data){}
- If
data.code== 2, it means the Apple Pay button loaded successfully. In theelseblock, receive the payment response and determine the following two scenarios:
- If the
xml->pay_urlfield is empty, then thexmlfile contains the returned payment result. In this case, an asynchronousnoticeUrlnotification will also be triggered. - If the
xml->pay_urlfield is not empty, a redirect is needed to open thepay_urlto complete 3D validation. The payment result will then be sent back tobackUrl, which by default uses $_POST to receive the return. This will also trigger an asynchronous notification vianoticeUrl.
var oceanpaymentApplePayCallBack = function(data){
if (data.code == 2) {
//The button is activated to initiate the payment process.
opApplepay();
}else{
//Handle order return.
//console.log(data);
}
}
- When
data.code== 3, it means the user has closed the Apple Pay payment pop-up. The data returned format is:
{"code":3,"msg":"","method":"GooglePay"}
- Payment Response Example:
- 3D scene
- Non-3D scenes
<?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}
<?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>6E48108837603DF6758BD6CE81C9F8AEE6FDC40D14D056C41EBCC1B28B1F2A0D</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>250903102114589130422</payment_id>
<payment_authType>0</payment_authType>
<payment_status>1</payment_status>
<payment_details>80000:Transaction Approved</payment_details>
<payment_solutions>None required.</payment_solutions>
<payment_risk></payment_risk>
<payment_amount></payment_amount>
<payment_exchangeRate></payment_exchangeRate>
<auth_code></auth_code>
<pay_userId></pay_userId>
</response>
- 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.