Skip to content

Instantly share code, notes, and snippets.

View apih's full-sized avatar
👻

Mohd Hafizuddin M Marzuki apih

👻
View GitHub Profile
@apih
apih / code.html
Last active May 29, 2017 16:12
JS code for selecting first shipping region if no shipping region is selected yet in OnPay form
<script type="text/javascript">
// Select first shipping region if no shipping region is selected yet
if ($("[name='shipping_region']:checked").length === 0) {
$("[name='shipping_region']:first").prop("checked", true);
}
</script>
@apih
apih / code.html
Created June 1, 2017 06:46
JS code for removing banks logo in payment method options in OnPay form
<script type="text/javascript">
// Remove banks logo in payment method options
$(".payment_method_label .logo.banks").remove();
</script>
@apih
apih / code.html
Created August 11, 2017 12:54
CSS code for setting custom image to a payment method in OnPay form
<style>
.payment_method_label .logo.billplz {
background-image: url(//s28.postimg.org/lr4960ft9/billplz-demo.jpg);
background-size: auto;
background-position: 0;
width: 318px;
height: 158px;
}
</style>
@apih
apih / code.html
Created August 23, 2017 05:50
Code for adding client email confirmation in OnPay form
<script type="text/html" id="client_email_confirmation_template">
<div class="form-group ">
<label for="client_email_confirmation" class="control-label col-md-3">Sahkan Emel<span class="glyphicon glyphicon-asterisk red-asterisk"></span></label>
<div class="col-md-7">
<input type="email" class="form-control" id="client_email_confirmation" name="client_email_confirmation" placeholder="Sahkan emel anda..." maxlength="100" value="">
</div>
</div>
</script>
<script type="text/javascript">
@apih
apih / onpay-form-input-type-number.html
Last active October 16, 2018 08:49
JS code for using input type number element for quantity in OnPay form
<script type="text/javascript">
// Use input type number element for quantity
$("[name^='product_quantities']").each(function() {
var element = $(this);
element.replaceWith('<input type="number" class="form-control quantity" min="0" name="' + element.prop("name") + '" value="' + element.prop("value") + '">');
});
</script>
@apih
apih / code.html
Created December 25, 2017 13:20
Code for reverting (partially) OnPay's order form to classic look
<script type="text/javascript">
$(document).ready(function() {
$("#submit-order").hide();
$("#payment_form").show();
$("#payment_form").submit(function(event) {
event.preventDefault();
return false;
});
$("#total_amount").change(function() {
@apih
apih / billplz-xsignature.php
Last active November 6, 2022 16:33
X Signature verification sample
<?php
function buildSourceString($data, $prefix = '')
{
uksort($data, function($a, $b) {
$a_len = strlen($a);
$b_len = strlen($b);
$result = strncasecmp($a, $b, min($a_len, $b_len));
if ($result === 0) {
@apih
apih / remove-login-and-get-client-data-buttons.html
Last active December 4, 2018 11:45
OnPay: Remove login and get client data buttons in order form
<script type="text/javascript">
$("#get_client_data").parent().remove();
</script>
@apih
apih / replace-payment-method.html
Created December 18, 2018 07:28
OnPay: Replace all payment methods with invisible Billplz payment method
<script type="text/javascript">
$("#payment-section").html('<input type="radio" class="payment_method" name="payment_method" value="billplz" data-button_text="Teruskan ke Pembayaran" style="display: none" checked>');
</script>
@apih
apih / fb-pixel.html
Created July 19, 2019 09:11
Generate custom data for Facebook Pixel Conversion Tracking - Purchase event
{#status_disahkan}
<!-- Facebook Pixel Code -->
<script type="text/javascript">
function convertToFloat(value) {
return parseFloat(value.replace(",", ""));
}
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};