Skip to content

Commit

Permalink
add check masterpass user endpoint (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
onurpolattimur authored Oct 22, 2021
1 parent ece3f25 commit 6f19f8e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
15 changes: 15 additions & 0 deletions samples/payment/CheckMasterpassUser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const Craftgate = require('../../dist');

const craftgate = new Craftgate.Client({
apiKey: 'api-key',
secretKey: 'secret-key',
baseUrl: 'https://sandbox-api.craftgate.io'
});

const request = {
masterpassGsmNumber: '903000000000'
};

craftgate.payment().checkMasterpassUser(request)
.then(results => console.info('Check masterpass user response', results))
.catch(err => console.error('Failed to check masterpass user', err));
6 changes: 6 additions & 0 deletions src/adapter/PaymentAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import PaymentTransactionRefundResponse from '../response/PaymentTransactionRefu
import StoredCardResponse from '../response/StoredCardResponse';

import BaseAdapter from './BaseAdapter';
import CheckMasterpassUserRequest from '../request/CheckMasterpassUserRequest';
import CheckMasterpassUserResponse from '../response/CheckMasterpassUserResponse';

export default class PaymentAdapter extends BaseAdapter {
constructor(options: ClientCreationOptions) {
Expand Down Expand Up @@ -111,4 +113,8 @@ export default class PaymentAdapter extends BaseAdapter {
async disapprovePaymentTransactions(request: DisapprovePaymentTransactionsRequest): Promise<PaymentTransactionApprovalListResponse> {
return this._client.post('/payment/v1/payment-transactions/disapprove', request);
}

async checkMasterpassUser(request: CheckMasterpassUserRequest): Promise<CheckMasterpassUserResponse> {
return this._client.post('/payment/v1/masterpass-payments/check-user', request);
}
}
5 changes: 5 additions & 0 deletions src/request/CheckMasterpassUserRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type CheckMasterpassUserRequest = {
masterpassGsmNumber: string
};

export default CheckMasterpassUserRequest;
12 changes: 12 additions & 0 deletions src/response/CheckMasterpassUserResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type CheckMasterpassUserResponse = {
isEligibleToUseMasterpass: boolean;
isAnyCardSavedInCustomerProgram: boolean;
hasMasterpassAccount: boolean;
hashAnyCardSavedInMasterpassAccount: boolean;
isMasterpassAccountLinkedWithMerchant: boolean;
isMasterpassAccountLocked: boolean;
isPhoneNumberUpdatedInAnotherMerchant: boolean;
accountStatus: string;
};

export default CheckMasterpassUserResponse;

0 comments on commit 6f19f8e

Please sign in to comment.