Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions examples/javascript/create_passkey_charge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

const omise = require('./index');
const { Authentication } = require('../..');

const card = {
name: 'Omise',
number: '5453011910000148',
expiration_month: 2,
expiration_year: '2030',
security_code: '123',
// Passkey requires either email or phone number
email: 'dev@omise.co',
phone_number: '+66000000000',
};

(async () => {
try {
const token = await omise.tokens.create({ card })
const charge = await omise.charges.create({
amount: 100000,
currency: 'thb',
return_uri: 'http://example.com',
card: token.id,
authentication: Authentication.Passkey, // or just 'PASSKEY'
})

console.log(charge.id, 'created with authentication', charge.authenticated_by);
} catch (err) {
console.log('error', err);
}
})();
28 changes: 28 additions & 0 deletions examples/typescript/src/create_passkey_charge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import omiseClient from './index';
import { Authentication } from 'omise';

const card = {
name: 'Omise',
number: '5453011910000148',
expiration_month: 2,
expiration_year: '2030',
security_code: '123',
// Passkey requires either email or phone number
email: 'dev@omise.co',
phone_number: '+66000000000',
};

try {
const token = await omiseClient.tokens.create({ card })
const charge = await omiseClient.charges.create({
amount: 100000,
currency: 'thb',
return_uri: 'http://example.com',
card: token.id,
authentication: Authentication.Passkey,
})

console.log(charge.id, 'created with authentication', charge.authenticated_by);
} catch (err) {
console.log('error', err);
}
Comment thread
rosle marked this conversation as resolved.
24 changes: 23 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
'use strict';
// Omise.co
const resource = require('./lib/apiResources');
module.exports = function(config) {

const Omise = function(config) {
return resource.omiseResources(config);
};

// Enums
const Scheme = {
Http: 'http',
Https: 'https',
};

const AuthType = {
PreAuth: 'pre_auth',
FinalAuth: 'final_auth',
};

const Authentication = {
Passkey: 'PASSKEY',
ThreeDS: '3DS',
};

module.exports = Omise;
module.exports.Authentication = Authentication;
module.exports.Scheme = Scheme;
module.exports.AuthType = AuthType;
47 changes: 42 additions & 5 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

declare function Omise(options: Omise.IOptions): Omise.IOmise;

export = Omise;

declare namespace Omise {
export interface IOptions {
host?: string;
Expand All @@ -28,6 +26,11 @@ declare namespace Omise {
FinalAuth = "final_auth",
}

export enum Authentication {
Passkey = "PASSKEY",
ThreeDS = "3DS",
}

export interface IOmise {
account: Account.IAccountAPI;
balance: Balance.IBalanceAPI;
Expand Down Expand Up @@ -202,6 +205,7 @@ declare namespace Omise {
description?: string;
amount: number;
currency: string;
authentication?: Authentication;
authorization_type?: AuthType;
capture?: boolean;
card?: string;
Expand Down Expand Up @@ -231,8 +235,11 @@ declare namespace Omise {
interface ICharge extends IBaseResponse {
amount: number;
currency: string;
acquirer_reference_number: string | null;
approval_code: string | null;
authorization_type: AuthType;
authorized_amount: number;
authenticated_by: Authentication | null;
captured_amount: number;
description: string;
device: any;
Expand All @@ -246,9 +253,12 @@ declare namespace Omise {
paid: boolean;
paid_at: string;
transaction: string | Transactions.ITransaction;
transaction_fees: { [key: string]: string };
refunds: IListRefundResponse;
failure_code: string;
failure_message: string;
funding_amount: number;
funding_currency: string;
merchant_advice: string | null;
merchant_advice_code: string | null;
missing_3ds_fields: string[];
Expand All @@ -257,26 +267,28 @@ declare namespace Omise {
ip: string;
dispute: string | Disputes.IResponse;
expired: boolean;
expired_at: string;
expired_at: string | null;
expires_at: string;
interest: number;
interest_vat: number;
link: string | Links.ILink;
net: number;
platform_fee: IPlatformFee;
partially_refundable: boolean;
refundable: boolean;
refunded_amount: number;
return_uri: string;
reversed_at: string;
reversed_at: string | null;
reversible: boolean;
schedule: string | Schedules.ISchedule;
terminal: any;
can_perform_void: boolean;
voided: boolean;
zero_interest_installments: boolean;
metadata: { [key: string]: any };
source?: Sources.ISource;
status: ChargeStatus;
linked_account?: string;
linked_account?: string | null;
}

interface IListRefundResponse extends IOccurrences {
Expand Down Expand Up @@ -931,3 +943,28 @@ declare namespace Omise {

type ResponseCallback<R> = (err: any, resp: R) => void;
}

declare namespace OmiseExports {
export { Omise as default };
export import Scheme = Omise.Scheme;
export import AuthType = Omise.AuthType;
export import Authentication = Omise.Authentication;
export import Account = Omise.Account;
export import Balance = Omise.Balance;
export import Capability = Omise.Capability;
export import Cards = Omise.Cards;
export import Charges = Omise.Charges;
export import Customers = Omise.Customers;
export import Disputes = Omise.Disputes;
export import Events = Omise.Events;
export import Links = Omise.Links;
export import Pagination = Omise.Pagination;
export import Recipients = Omise.Recipients;
export import Schedules = Omise.Schedules;
export import Sources = Omise.Sources;
export import Tokens = Omise.Tokens;
export import Transactions = Omise.Transactions;
export import Transfers = Omise.Transfers;
}

export = OmiseExports;
Loading