Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ApplePay integration #151

Merged
merged 2 commits into from
Oct 6, 2023
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
5 changes: 5 additions & 0 deletions src/adapter/PaymentAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {ClientCreationOptions} from '../lib/HttpClient';
import {calculateHash} from '../lib/utils';

import ApplePayMerchantSessionCreateRequest from '../request/ApplePayMerchantSessionCreateRequest';
import ApprovePaymentTransactionsRequest from '../request/ApprovePaymentTransactionsRequest';
import CompleteApmPaymentRequest from '../request/CompleteApmPaymentRequest';
import CompletePosApmPaymentRequest from '../request/CompletePosApmPaymentRequest';
Expand Down Expand Up @@ -176,6 +177,10 @@ export default class PaymentAdapter extends BaseAdapter {
return this._client.put(`/payment/v1/payment-transactions/${paymentTransactionId}`, request);
}

async createApplePayMerchantSession(request: ApplePayMerchantSessionCreateRequest): Promise<any> {
return this._client.post(`/payment/v1/apple-pay/merchant-sessions`, request);
}

async is3DSecureCallbackVerified(threeDSecureCallbackKey: string, params: Map<string, string>): Promise<boolean> {
const hash = params['hash'];
let hashString: string = [
Expand Down
5 changes: 5 additions & 0 deletions src/model/TokenizedCardType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enum TokenizedCardType {
APPLE_PAY = 'APPLE_PAY'
}

export default TokenizedCardType;
4 changes: 3 additions & 1 deletion src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import SettlementEarningsDestination from './SettlementEarningsDestination';
import SettlementSource from './SettlementSource';
import SettlementType from './SettlementType';
import Status from './Status';
import TokenizedCardType from './TokenizedCardType';
import TransactionPayoutStatus from './TransactionPayoutStatus';
import TransactionStatus from './TransactionStatus';
import WalletTransactionRefundTransactionType from './WalletTransactionRefundTransactionType';
Expand Down Expand Up @@ -79,5 +80,6 @@ export = {
WalletTransactionType,
ReportFileType,
WebhookEventType,
WebhookStatus
WebhookStatus,
TokenizedCardType
};
9 changes: 9 additions & 0 deletions src/request/ApplePayMerchantSessionCreateRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type ApplePayMerchantSessionCreateRequest = {
merchantIdentifier: string;
displayName: string;
initiative: string;
initiativeContext: string;
validationUrl: string;
};

export default ApplePayMerchantSessionCreateRequest;
10 changes: 9 additions & 1 deletion src/request/dto/Card.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Loyalty} from '../../model/Loyalty';
import TokenizedCardType from '../../model/TokenizedCardType';

export type PaymentCard = {
cardAlias?: string;
Expand All @@ -24,4 +25,11 @@ export type First6Last4CardWithIdentityNumber = {
lastFourDigits: string;
};

export type Card = PaymentCard | StoredCard | First6Last4CardWithIdentityNumber;
export type TokenizedCard = {
tokenizedCard: {
type: TokenizedCardType;
data: any;
};
};

export type Card = PaymentCard | StoredCard | First6Last4CardWithIdentityNumber | TokenizedCard;
Loading