Skip to content

Instantly share code, notes, and snippets.

View rajnandan1's full-sized avatar
:bowtie:
Building

Raj Nandan Sharma rajnandan1

:bowtie:
Building
View GitHub Profile
@rajnandan1
rajnandan1 / your_view_controller.swift
Created March 29, 2022 10:21
Cashfree PG Integration in iOS
import Foundation
import UIKit
import CashfreePGCoreSDK
import CashfreePG
class YourViewController: UIViewController, CFCardPaymentDelegate, CFNetbankingPaymentDelegate, CFWalletPaymentDelegate, CFUPIPaymentDelegate, CFPaylaterPaymentDelegate {
private let cfPaymentGatewayService = CFPaymentGatewayService.getInstance()
override func viewDidLoad() {
self.cfPaymentGatewayService.setCallback(self)
@rajnandan1
rajnandan1 / valid_upi.js
Created October 11, 2021 08:31
Check if upi id or vpa is valid or not
function valid_upi(upiID){
const upiRegex = /^[a-zA-Z0-9_\-\.]+@[a-zA-Z]{3,}$/;
return upiRegex.test(upiID)
}
@rajnandan1
rajnandan1 / valid_card.js
Last active October 11, 2021 08:28
check if a card number is valid
function valid_card(value) {
// Accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
let nCheck = 0,
bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@rajnandan1
rajnandan1 / card-network.js
Last active October 11, 2021 08:24
Get card network and cvv length given a card number or bin
function getCardType(number) {
var res = {
id: null,
name: null
};
if (number.length <= 2) return res;
var re = new RegExp("^4");
if (number.match(re) != null) {
res.id = "visa";