Skip to content

Commit

Permalink
Merge pull request #222 from paypay/feature/PP-68940
Browse files Browse the repository at this point in the history
Feature/pp 68940
  • Loading branch information
Shreyansh Pandey authored Apr 19, 2021
2 parents e1d2176 + d4b3d9b commit 5daea31
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 7 deletions.
141 changes: 141 additions & 0 deletions src/lib/conf.perf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"HOST_NAME": "perf-api.paypay.ne.jp",
"API_PAYMENT": {
"CREATE_PAYMENT": {
"METHOD": "POST",
"PATH": "/v2/payments",
"API_NAME": "v2_createPayment"
},
"QRCODE_CREATE": {
"METHOD": "POST",
"PATH": "/v2/codes",
"API_NAME": "v2_createDynamicQRCode"
},
"QRCODE_DELETE": {
"METHOD": "DELETE",
"PATH": "/v2/codes/{codeId}",
"API_NAME": "v2_deleteDynamicQRCode"
},
"GET_CODE_PAYMENT_DETAILS": {
"METHOD": "GET",
"PATH": "/v2/codes/payments/{merchantPaymentId}",
"API_NAME": "v2_getQRPaymentDetails"
},
"GET_PAYMENT_DETAILS": {
"METHOD": "GET",
"PATH": "/v2/payments/{merchantPaymentId}",
"API_NAME": "v2_getPaymentDetail"
},
"CANCEL_PAYMENT": {
"METHOD": "DELETE",
"PATH": "/v2/payments/{merchantPaymentId}",
"API_NAME": "v2_cancelPayment"
},
"PAYMENT_AUTH_CAPTURE": {
"METHOD": "POST",
"PATH": "/v2/payments/capture",
"API_NAME": "v2_captureAuthorizedOrder"
},
"PAYMENT_AUTH_REVERT": {
"METHOD": "POST",
"PATH": "/v2/payments/preauthorize/revert",
"API_NAME": "v2_revertAuthorizedOrder"
},
"PREAUTHORIZE": {
"METHOD": "POST",
"PATH": "/v2/payments/preauthorize",
"API_NAME": "v2_createOrderAndAuthorize"
},
"REFUND_PAYMENT": {
"METHOD": "POST",
"PATH": "/v2/refunds",
"API_NAME": "v2_createRefundPayment"
},
"GET_REFUND_DETAILS": {
"METHOD": "GET",
"PATH": "/v2/refunds/{merchantRefundId}",
"API_NAME": "v2_getRefundDetails"
},
"GIVE_CASH_BACK": {
"METHOD": "POST",
"PATH": "/v2/cashback",
"API_NAME": "v2_createCashBackRequest"
},
"CHECK_CASHBACK_DETAILS": {
"METHOD": "GET",
"PATH": "/v2/cashback/{merchantCashbackId}",
"API_NAME": "v2_getCashbackDetails"
},
"REVERSAL_CASHBACK": {
"METHOD": "POST",
"PATH": "/v2/cashback_reversal",
"API_NAME": "v2_createReverseCashBackRequest"
},
"CHECK_CASHBACK_REVERSE_DETAILS": {
"METHOD": "GET",
"PATH": "/v2/cashback_reversal/{merchantCashbackReversalId}/{merchantCashbackId}",
"API_NAME": "v2_getReversedCashBackDetails"
}
},
"API_WALLET": {
"CHECK_BALANCE": {
"METHOD": "GET",
"PATH": "/v2/wallet/check_balance?userAuthorizationId={userAuthorizationId}&amount={amount}&currency={currency}"
}
},
"API_DIRECT_DEBIT": {
"AUTHORIZATION": {
"METHOD": "GET",
"PATH": "/v2/user_authorization?apiKey={apiKey}&requestToken={jwtToken}"
},
"AUTHORIZATION_RESULT": {
"METHOD": "GET",
"PATH": "/v2/user_authorization?apiKey={apiKey}&responseToken={jwtToken}"
}
},
"API_APP_INVOKE": {},
"API_WEB_CASHIER": {},
"API_ACCOUNT_LINK": {
"QRCODE_CREATE": {
"METHOD": "POST",
"PATH": "/v1/qr/sessions",
"API_NAME": "v1_qrSession"
}
},
"API_SUBSCRIPTION": {
"PAYMENTS": {
"METHOD": "POST",
"PATH": "/v1/subscription/payments",
"API_NAME": "v1_createSubscriptionPayment"
}
},
"API_REQUEST_ORDER": {
"PENDING_PAYMENT_CREATE": {
"METHOD": "POST",
"PATH": "/v1/requestOrder",
"API_NAME": "v1_createRequestOrder"
},
"GET_ORDER_DETAILS": {
"METHOD": "GET",
"PATH": "/v1/requestOrder/{merchantPaymentId}",
"API_NAME": "v1_getRequestOrder"
},
"PENDING_ORDER_CANCEL": {
"METHOD": "DELETE",
"PATH": "/v1/requestOrder/{merchantPaymentId}",
"API_NAME": "v1_cancelRequestOrder"
}
},
"USER_AUTHORIZATION": {
"GET_USER_AUTHORIZATION_STATUS": {
"METHOD": "GET",
"PATH": "/v2/user/authorizations?userAuthorizationId={userAuthorizationId}",
"API_NAME": "v2_userAuthStatus"
},
"UNLINK_USER": {
"METHOD": "DELETE",
"PATH": "/v2/user/authorizations/{userAuthorizationId}",
"API_NAME": "v2_unlinkUser"
}
}
}
7 changes: 6 additions & 1 deletion src/lib/conf.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as stagingConfig from "./conf.stage.json";
import * as prodConfig from "./conf.prod.json";
import * as perfConfig from "./conf.perf.json";

export interface Config {
HOST_NAME: string;
Expand All @@ -18,15 +19,19 @@ export class Conf {

private readonly stagingConfig: Config = stagingConfig;
private readonly prodConfig: Config = prodConfig;
private readonly perfConfig: Config = perfConfig;

private readonly configLookup: any;

constructor(productionMode: boolean = false) {
constructor(productionMode: boolean = false, perfMode: boolean = false) {
if (productionMode) {
this.configLookup = JSON.parse(JSON.stringify(this.prodConfig));
} else {
this.configLookup = JSON.parse(JSON.stringify(this.stagingConfig));
}
if (perfMode) {
this.configLookup = JSON.parse(JSON.stringify(this.perfConfig));
}
}

setHttpsOptions(options: any) {
Expand Down
14 changes: 8 additions & 6 deletions src/lib/paypay-rest-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,30 @@ export interface HttpsClientMessage {
class PayPayRestSDK {
private options: any = "";
private productionMode: boolean = false;
private perfMode: boolean = false;
private auth: Auth;
private config: Conf;

constructor() {
this.config = new Conf(this.productionMode);
this.config = new Conf(this.productionMode, this.perfMode);
this.auth = new Auth();
}

/**
* Set authentication passed by end-user
* @param {string} clientId API_KEY provided by end-user
* @param {string} clientSecret API_SECRET provided by end-user
* @param {string} merchantId MERCHANT_ID provided by end-user
* @param clientConfig
*/
public configure = (clientConfig: { clientId: string; clientSecret: string; merchantId?: string; productionMode: boolean; }) => {
public configure = (clientConfig: { clientId: string; clientSecret: string; merchantId?: string; productionMode?: boolean; perfMode?: boolean; }) => {
this.auth.setAuth(clientConfig.clientId, clientConfig.clientSecret, clientConfig.merchantId);
if (clientConfig.productionMode) {
this.productionMode = clientConfig.productionMode
} else {
this.productionMode = false;
}
this.config = new Conf(this.productionMode);
if (clientConfig.perfMode) {
this.perfMode = clientConfig.perfMode
}
this.config = new Conf(this.productionMode, this.perfMode);
}

private createAuthHeader = (method: string, resourceUrl: string, body: any, auth: any) => {
Expand Down

0 comments on commit 5daea31

Please sign in to comment.