bc-apple-pay-sdk
Advanced tools
| import { IPayment } from "../base/contracts/IPayment"; | ||
| /** | ||
| * Class {Payment} interacts with Apple Pay API. | ||
| * | ||
| * @implements {IPayment} | ||
| */ | ||
| export declare class Payment implements IPayment { | ||
@@ -3,0 +8,0 @@ /** |
@@ -13,2 +13,7 @@ "use strict"; | ||
| const RequestMethod_1 = require("../constants/enums/RequestMethod"); | ||
| /** | ||
| * Class {Payment} interacts with Apple Pay API. | ||
| * | ||
| * @implements {IPayment} | ||
| */ | ||
| class Payment { | ||
@@ -24,9 +29,2 @@ /** | ||
| async validateSession(data) { | ||
| /*console.log({ | ||
| merchantIdentifier: ApplePayEnvironment.getMerchantId(), | ||
| //domainName: ApplePayEnvironment.getDomainName(), | ||
| displayName: ApplePayEnvironment.getDisplayName(), | ||
| initiative: "web", | ||
| initiativeContext: ApplePayEnvironment.getDomainName(), | ||
| })*/ | ||
| const { validationUrl } = data; | ||
@@ -39,3 +37,3 @@ try { | ||
| }); | ||
| const { data: validateSessionResult } = await (0, api_1.default)({ | ||
| const config = { | ||
| url: validationUrl, | ||
@@ -54,31 +52,5 @@ method: RequestMethod_1.RequestMethod.POST, | ||
| }, | ||
| }); | ||
| }; | ||
| const { data: validateSessionResult } = await (0, api_1.default)(config); | ||
| return validateSessionResult; | ||
| /*const options: CoreOptions = { | ||
| cert: ApplePayEnvironment.getPEMCert(), | ||
| key: ApplePayEnvironment.getKeyCert(), | ||
| method: RequestMethod.POST, | ||
| body: { | ||
| merchantIdentifier: ApplePayEnvironment.getMerchantId(), | ||
| displayName: ApplePayEnvironment.getDisplayName(), | ||
| initiative: "web", | ||
| initiativeContext: ApplePayEnvironment.getDomainName(), | ||
| }, | ||
| json: true, | ||
| } | ||
| const promise = new Promise<any>((resolve: any, reject: any) => { | ||
| request.post(validationUrl, options, (error: any, response: any, body: any) => { | ||
| resolve({ error, response, body }) | ||
| }) | ||
| }) | ||
| return await promise.then(({ error, response, body }: any) => { | ||
| if (error) { | ||
| return { hasError: true, error: { name: error.name, message: error.message, stack: error.stack } } | ||
| } | ||
| return body | ||
| }).catch((error: any) => { | ||
| return { hasError: true, error: error } | ||
| })*/ | ||
| } | ||
@@ -85,0 +57,0 @@ catch (error) { |
| /// <reference types="node" /> | ||
| /** | ||
| * Class {ApplePayEnvironment} | ||
| * Class {ApplePayEnvironment} is used to initialize the ApplePay environment. | ||
| * The class should be initialized before using any other class in the SDK. | ||
| */ | ||
@@ -39,26 +40,55 @@ export declare class ApplePayEnvironment { | ||
| static baseUrl: string; | ||
| /** | ||
| * Initializes the ApplePayEnvironment with the given parameters. | ||
| * @param {string} merchantId - The apple pay merchant id. | ||
| * @param {string} domainName - The domain name of the merchant. | ||
| * @param {string} displayName - The display name of the merchant. | ||
| * @param {Buffer} pemCert - The pem formatted certificate. | ||
| * @param {Buffer} keyCert - The pem formatted key. | ||
| * @param {boolean} [useSandBox=true] - If true, uses sandbox, otherwise uses production. | ||
| * @returns {ApplePayEnvironment} The ApplePayEnvironment instance. | ||
| */ | ||
| static init(merchantId: string, domainName: string, displayName: string, pemCert: Buffer, keyCert: Buffer, useSandBox?: boolean): typeof ApplePayEnvironment; | ||
| /** | ||
| * Returns the merchant Id. | ||
| * @return {string} | ||
| * Retrieves the merchant ID for the Apple Pay environment. | ||
| * | ||
| * @returns {string} The merchant ID. | ||
| */ | ||
| static getMerchantId(): string; | ||
| /** | ||
| * Returns the domain name. | ||
| * @return {string} | ||
| * Retrieves the domain name of the merchant for the Apple Pay environment. | ||
| * | ||
| * @returns {string} The domain name of the merchant. | ||
| */ | ||
| static getDomainName(): string; | ||
| /** | ||
| * Returns the display name. | ||
| * @return {string} | ||
| * Retrieves the display name of the merchant for the Apple Pay environment. | ||
| * | ||
| * @returns {string} The display name of the merchant. | ||
| */ | ||
| static getDisplayName(): string; | ||
| /** | ||
| * Retrieves the PEM formatted certificate for the Apple Pay environment. | ||
| * | ||
| * @returns {Buffer} The PEM formatted certificate. | ||
| */ | ||
| static getPEMCert(): Buffer; | ||
| /** | ||
| * Retrieves the PEM formatted key certificate for the Apple Pay environment. | ||
| * | ||
| * @returns {Buffer} The key certificate. | ||
| */ | ||
| static getKeyCert(): Buffer; | ||
| /** | ||
| * Retrieves the Apple Pay environment name, which is either "sandbox" or "production", depending on whether the sandbox or production environment is used. | ||
| * | ||
| * @returns {string} The environment name. | ||
| */ | ||
| static getEnvironment(): string; | ||
| /** | ||
| * Returns the base url. | ||
| * @return {string} | ||
| * Retrieves the base URL for the Apple Pay environment. | ||
| * | ||
| * @returns {string} The base URL, which varies based on whether the sandbox or production environment is used. | ||
| */ | ||
| static getBaseUrl(): string; | ||
| } |
@@ -6,5 +6,16 @@ "use strict"; | ||
| /** | ||
| * Class {ApplePayEnvironment} | ||
| * Class {ApplePayEnvironment} is used to initialize the ApplePay environment. | ||
| * The class should be initialized before using any other class in the SDK. | ||
| */ | ||
| class ApplePayEnvironment { | ||
| /** | ||
| * Initializes the ApplePayEnvironment with the given parameters. | ||
| * @param {string} merchantId - The apple pay merchant id. | ||
| * @param {string} domainName - The domain name of the merchant. | ||
| * @param {string} displayName - The display name of the merchant. | ||
| * @param {Buffer} pemCert - The pem formatted certificate. | ||
| * @param {Buffer} keyCert - The pem formatted key. | ||
| * @param {boolean} [useSandBox=true] - If true, uses sandbox, otherwise uses production. | ||
| * @returns {ApplePayEnvironment} The ApplePayEnvironment instance. | ||
| */ | ||
| static init(merchantId, domainName, displayName, pemCert, keyCert, useSandBox = true) { | ||
@@ -27,4 +38,5 @@ ApplePayEnvironment.merchantId = merchantId; | ||
| /** | ||
| * Returns the merchant Id. | ||
| * @return {string} | ||
| * Retrieves the merchant ID for the Apple Pay environment. | ||
| * | ||
| * @returns {string} The merchant ID. | ||
| */ | ||
@@ -35,4 +47,5 @@ static getMerchantId() { | ||
| /** | ||
| * Returns the domain name. | ||
| * @return {string} | ||
| * Retrieves the domain name of the merchant for the Apple Pay environment. | ||
| * | ||
| * @returns {string} The domain name of the merchant. | ||
| */ | ||
@@ -43,4 +56,5 @@ static getDomainName() { | ||
| /** | ||
| * Returns the display name. | ||
| * @return {string} | ||
| * Retrieves the display name of the merchant for the Apple Pay environment. | ||
| * | ||
| * @returns {string} The display name of the merchant. | ||
| */ | ||
@@ -50,8 +64,23 @@ static getDisplayName() { | ||
| } | ||
| /** | ||
| * Retrieves the PEM formatted certificate for the Apple Pay environment. | ||
| * | ||
| * @returns {Buffer} The PEM formatted certificate. | ||
| */ | ||
| static getPEMCert() { | ||
| return ApplePayEnvironment.pemCert; | ||
| } | ||
| /** | ||
| * Retrieves the PEM formatted key certificate for the Apple Pay environment. | ||
| * | ||
| * @returns {Buffer} The key certificate. | ||
| */ | ||
| static getKeyCert() { | ||
| return ApplePayEnvironment.keyCert; | ||
| } | ||
| /** | ||
| * Retrieves the Apple Pay environment name, which is either "sandbox" or "production", depending on whether the sandbox or production environment is used. | ||
| * | ||
| * @returns {string} The environment name. | ||
| */ | ||
| static getEnvironment() { | ||
@@ -61,4 +90,5 @@ return ApplePayEnvironment.environment; | ||
| /** | ||
| * Returns the base url. | ||
| * @return {string} | ||
| * Retrieves the base URL for the Apple Pay environment. | ||
| * | ||
| * @returns {string} The base URL, which varies based on whether the sandbox or production environment is used. | ||
| */ | ||
@@ -65,0 +95,0 @@ static getBaseUrl() { |
@@ -0,1 +1,9 @@ | ||
| /** | ||
| * Enum {OrderIntent} represents the intent of the order. | ||
| * @ordinal {string} CAPTURE - The merchant intends to capture payment immediately after the customer makes a payment. | ||
| * @ordinal {string} AUTHORIZE - The merchant intends to authorize a payment and place funds on hold after the customer makes a payment. | ||
| * Authorised payments are best captured within three days of authorization but are available to capture for up to 29 days. | ||
| * After the three-day honor period, the original authorized payment expires and you must re-authorize the payment. | ||
| * You must capture authorized payments within 29 days of authorization. | ||
| */ | ||
| export declare enum OrderIntent { | ||
@@ -2,0 +10,0 @@ CAPTURE = "CAPTURE", |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.OrderIntent = void 0; | ||
| /** | ||
| * Enum {OrderIntent} represents the intent of the order. | ||
| * @ordinal {string} CAPTURE - The merchant intends to capture payment immediately after the customer makes a payment. | ||
| * @ordinal {string} AUTHORIZE - The merchant intends to authorize a payment and place funds on hold after the customer makes a payment. | ||
| * Authorised payments are best captured within three days of authorization but are available to capture for up to 29 days. | ||
| * After the three-day honor period, the original authorized payment expires and you must re-authorize the payment. | ||
| * You must capture authorized payments within 29 days of authorization. | ||
| */ | ||
| var OrderIntent; | ||
@@ -5,0 +13,0 @@ (function (OrderIntent) { |
@@ -0,1 +1,14 @@ | ||
| /** | ||
| * Enum {PaymentSourceType} provides the possible payment source types that can be used in requests. | ||
| * | ||
| * @ordinal {string} TOKEN - The source of the payment is a token. | ||
| * @ordinal {string} ID - The source of the payment is an ID. | ||
| * @ordinal {string} CARD - The source of the payment is a card. | ||
| * @ordinal {string} CUSTOMER - The source of the payment is a customer. | ||
| * @ordinal {string} NETWORK_TOKEN - The source of the payment is a network token. | ||
| * @ordinal {string} PROVIDER_TOKEN - The source of the payment is a provider token. | ||
| * @ordinal {string} BANK_ACCOUNT - The source of the payment is a bank account. | ||
| * @ordinal {string} WE_CHAT_PAY - The source of the payment is WeChat Pay. | ||
| * @ordinal {string} EPS - The source of the payment is EPS. | ||
| */ | ||
| export declare enum PaymentSourceType { | ||
@@ -2,0 +15,0 @@ TOKEN = "token", |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.PaymentSourceType = void 0; | ||
| /** | ||
| * Enum {PaymentSourceType} provides the possible payment source types that can be used in requests. | ||
| * | ||
| * @ordinal {string} TOKEN - The source of the payment is a token. | ||
| * @ordinal {string} ID - The source of the payment is an ID. | ||
| * @ordinal {string} CARD - The source of the payment is a card. | ||
| * @ordinal {string} CUSTOMER - The source of the payment is a customer. | ||
| * @ordinal {string} NETWORK_TOKEN - The source of the payment is a network token. | ||
| * @ordinal {string} PROVIDER_TOKEN - The source of the payment is a provider token. | ||
| * @ordinal {string} BANK_ACCOUNT - The source of the payment is a bank account. | ||
| * @ordinal {string} WE_CHAT_PAY - The source of the payment is WeChat Pay. | ||
| * @ordinal {string} EPS - The source of the payment is EPS. | ||
| */ | ||
| var PaymentSourceType; | ||
@@ -5,0 +18,0 @@ (function (PaymentSourceType) { |
@@ -0,1 +1,10 @@ | ||
| /** | ||
| * Enum {PaymentType} represents the type of payment. | ||
| * | ||
| * @ordinal {string} Regular - The merchant intends to capture payment immediately after the customer makes a payment. | ||
| * @ordinal {string} Recurring - The merchant intends to authorize a payment and place funds on hold after the customer makes a payment. Authorized payments are best captured within three days of authorization but are available to capture for up to 29 days. After the three-day honor period, the original authorized payment expires and you must re-authorize the payment. You must capture authorized payments within 29 days of authorization. | ||
| * @ordinal {string} MOTO - Merchant-Initiated Transaction Online (MOTO) payment. The merchant initiates the payment on behalf of the customer. | ||
| * @ordinal {string} Installment - Installment payment. Installment payments are a type of recurring payment that is used to pay for a purchase in multiple installments. | ||
| * @ordinal {string} Unscheduled - Unscheduled payment. Unscheduled payments are payments that are not part of a recurring payment schedule. | ||
| */ | ||
| export declare enum PaymentType { | ||
@@ -2,0 +11,0 @@ Regular = "Regular", |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.PaymentType = void 0; | ||
| /** | ||
| * Enum {PaymentType} represents the type of payment. | ||
| * | ||
| * @ordinal {string} Regular - The merchant intends to capture payment immediately after the customer makes a payment. | ||
| * @ordinal {string} Recurring - The merchant intends to authorize a payment and place funds on hold after the customer makes a payment. Authorized payments are best captured within three days of authorization but are available to capture for up to 29 days. After the three-day honor period, the original authorized payment expires and you must re-authorize the payment. You must capture authorized payments within 29 days of authorization. | ||
| * @ordinal {string} MOTO - Merchant-Initiated Transaction Online (MOTO) payment. The merchant initiates the payment on behalf of the customer. | ||
| * @ordinal {string} Installment - Installment payment. Installment payments are a type of recurring payment that is used to pay for a purchase in multiple installments. | ||
| * @ordinal {string} Unscheduled - Unscheduled payment. Unscheduled payments are payments that are not part of a recurring payment schedule. | ||
| */ | ||
| var PaymentType; | ||
@@ -5,0 +14,0 @@ (function (PaymentType) { |
@@ -0,1 +1,11 @@ | ||
| /** | ||
| * Enum {RequestMethod} contains the possible HTTP request methods. | ||
| * | ||
| * @ordinal {string} POST - The POST method requests that the server accept the entity enclosed in the request as a new subordinate of the web resource identified by the Request-URI. | ||
| * @ordinal {string} GET - The GET method requests a representation of the specified resource. Requests using GET should only retrieve data and should have no other effect on the server. | ||
| * @ordinal {string} HEAD - The HEAD method asks for the response identical to the one that would correspond to a GET request, but without the response body. | ||
| * @ordinal {string} PUT - The PUT method requests that the enclosed entity be stored at the supplied Request-URI. | ||
| * @ordinal {string} PATCH - The PATCH method applies partial modifications to a resource. | ||
| * @ordinal {string} DELETE - The DELETE method deletes the specified resource. | ||
| */ | ||
| export declare enum RequestMethod { | ||
@@ -2,0 +12,0 @@ POST = "POST", |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.RequestMethod = void 0; | ||
| /** | ||
| * Enum {RequestMethod} contains the possible HTTP request methods. | ||
| * | ||
| * @ordinal {string} POST - The POST method requests that the server accept the entity enclosed in the request as a new subordinate of the web resource identified by the Request-URI. | ||
| * @ordinal {string} GET - The GET method requests a representation of the specified resource. Requests using GET should only retrieve data and should have no other effect on the server. | ||
| * @ordinal {string} HEAD - The HEAD method asks for the response identical to the one that would correspond to a GET request, but without the response body. | ||
| * @ordinal {string} PUT - The PUT method requests that the enclosed entity be stored at the supplied Request-URI. | ||
| * @ordinal {string} PATCH - The PATCH method applies partial modifications to a resource. | ||
| * @ordinal {string} DELETE - The DELETE method deletes the specified resource. | ||
| */ | ||
| var RequestMethod; | ||
@@ -5,0 +15,0 @@ (function (RequestMethod) { |
+1
-1
| { | ||
| "name": "bc-apple-pay-sdk", | ||
| "version": "0.0.2", | ||
| "version": "0.0.3", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
60983
15.77%706
20.68%