@osovitny/anatoly 3.17.67 → 3.17.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/payments/PayPal/components/paypal.component.mjs +317 -0
- package/esm2022/lib/payments/PayPal/models/paypal-models.mjs +17 -0
- package/esm2022/lib/payments/PayPal/services/paypal-script.service.mjs +98 -0
- package/esm2022/lib/payments/index.mjs +22 -0
- package/esm2022/lib/payments/payments.module.mjs +54 -0
- package/esm2022/lib/payments/services/script.service.mjs +63 -0
- package/esm2022/public-api.mjs +5 -7
- package/fesm2022/osovitny-anatoly.mjs +550 -2
- package/fesm2022/osovitny-anatoly.mjs.map +1 -1
- package/lib/payments/PayPal/components/paypal.component.d.ts +50 -0
- package/lib/payments/PayPal/models/paypal-models.d.ts +309 -0
- package/lib/payments/PayPal/services/paypal-script.service.d.ts +14 -0
- package/lib/payments/index.d.ts +4 -0
- package/lib/payments/payments.module.d.ts +8 -0
- package/lib/payments/services/script.service.d.ts +11 -0
- package/package.json +1 -1
- package/public-api.d.ts +2 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AfterViewInit, ChangeDetectorRef, ElementRef, EventEmitter, NgZone, OnChanges, OnDestroy, SimpleChanges } from "@angular/core";
|
|
2
|
+
import { IPayPalConfig } from "../models/paypal-models";
|
|
3
|
+
import { PayPalScriptService } from "../services/paypal-script.service";
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class PayPalComponent implements OnChanges, OnDestroy, AfterViewInit {
|
|
6
|
+
private paypalScriptService;
|
|
7
|
+
private cdr;
|
|
8
|
+
private ngZone;
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for paypal.
|
|
11
|
+
*/
|
|
12
|
+
config?: IPayPalConfig;
|
|
13
|
+
/**
|
|
14
|
+
* If enabled, paypal SDK script will be loaded. Useful if you want to have multiple PayPal components on the same page
|
|
15
|
+
* sharing base configuration. In such a case only a single component may register script.
|
|
16
|
+
*/
|
|
17
|
+
registerScript: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Emitted when paypal script is loaded
|
|
20
|
+
*/
|
|
21
|
+
scriptLoaded: EventEmitter<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Id of the element where PayPal button will be rendered
|
|
24
|
+
*/
|
|
25
|
+
payPalButtonContainerId?: string;
|
|
26
|
+
private readonly ngUnsubscribe;
|
|
27
|
+
private payPalButtonContainerElem?;
|
|
28
|
+
set payPalButtonContainer(content: ElementRef);
|
|
29
|
+
/**
|
|
30
|
+
* Flag that indicates if paypal should be initialized (required for handling script load events and availability of DOM element)
|
|
31
|
+
*/
|
|
32
|
+
private initializePayPal;
|
|
33
|
+
/**
|
|
34
|
+
* Reference to PayPal global API
|
|
35
|
+
*/
|
|
36
|
+
private payPal;
|
|
37
|
+
constructor(paypalScriptService: PayPalScriptService, cdr: ChangeDetectorRef, ngZone: NgZone);
|
|
38
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
39
|
+
ngOnDestroy(): void;
|
|
40
|
+
ngAfterViewInit(): void;
|
|
41
|
+
customInit(payPal: any): void;
|
|
42
|
+
reinitialize(config: IPayPalConfig | undefined): void;
|
|
43
|
+
private doPayPalCheck;
|
|
44
|
+
private initPayPalScript;
|
|
45
|
+
private generateElementId;
|
|
46
|
+
private initPayPal;
|
|
47
|
+
private generateGuid;
|
|
48
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PayPalComponent, never>;
|
|
49
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<PayPalComponent, "anatoly-paypal", never, { "config": { "alias": "config"; "required": false; }; "registerScript": { "alias": "registerScript"; "required": false; }; }, { "scriptLoaded": "scriptLoaded"; }, never, never, false, never>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
export interface IPayPalConfig {
|
|
2
|
+
/**
|
|
3
|
+
* Currency - Defaults to USD if not provided
|
|
4
|
+
*/
|
|
5
|
+
currency?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Use when creating order on client
|
|
8
|
+
*/
|
|
9
|
+
createOrderOnClient?: (data: any) => ICreateOrderRequest;
|
|
10
|
+
/**
|
|
11
|
+
* Use when creating subscription on client
|
|
12
|
+
*/
|
|
13
|
+
createSubscriptionOnClient?: (data: any) => ICreateSubscriptionRequest;
|
|
14
|
+
/**
|
|
15
|
+
* Use for creating orders on server. PayPal expects you to return 'orderId' in this method
|
|
16
|
+
*/
|
|
17
|
+
createOrderOnServer?: (data: any) => Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Advanced configuration
|
|
20
|
+
*/
|
|
21
|
+
advanced?: IAdvancedConfiguration;
|
|
22
|
+
/**
|
|
23
|
+
* Client id
|
|
24
|
+
*/
|
|
25
|
+
clientId: string;
|
|
26
|
+
/**
|
|
27
|
+
* Shipping callback
|
|
28
|
+
* see https://developer.paypal.com/docs/checkout/integration-features/shipping-callback/
|
|
29
|
+
*/
|
|
30
|
+
onShippingChange?: OnShippingChangeCallback;
|
|
31
|
+
/**
|
|
32
|
+
* Called when 'onApprove' event occurs
|
|
33
|
+
*/
|
|
34
|
+
onApprove?: (data: IOnApproveCallbackData, actions: any) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Called when authorization on client succeeds
|
|
37
|
+
*/
|
|
38
|
+
onClientAuthorization?: (authorization: IClientAuthorizeCallbackData) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Implement for authorizing on server side
|
|
41
|
+
*/
|
|
42
|
+
authorizeOnServer?: (data: IOnApproveCallbackData, actions: any) => Promise<any>;
|
|
43
|
+
/**
|
|
44
|
+
* Button style configuration
|
|
45
|
+
*/
|
|
46
|
+
style?: IPayPalButtonStyle;
|
|
47
|
+
/**
|
|
48
|
+
* Error handler
|
|
49
|
+
*/
|
|
50
|
+
onError?: (err: any) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Click handler
|
|
53
|
+
*/
|
|
54
|
+
onClick?: (data: any, actions: IOnClickCallbackActions) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Cancel handler
|
|
57
|
+
*/
|
|
58
|
+
onCancel?: (data: ICancelCallbackData, actions: any) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Init handler.
|
|
61
|
+
* can be used for validation, see: https://developer.paypal.com/docs/checkout/integration-features/validation/#
|
|
62
|
+
*/
|
|
63
|
+
onInit?: (data: IInitCallbackData, actions: IOnInitCallbackActions) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Create subscription handler
|
|
66
|
+
* https://developer.paypal.com/docs/subscriptions/integrate/
|
|
67
|
+
*
|
|
68
|
+
* Note: the vault property in the advanced configuration also has to be set to true
|
|
69
|
+
*/
|
|
70
|
+
createSubscription?: (data: any) => ICreateSubscriptionRequest;
|
|
71
|
+
/**
|
|
72
|
+
* Vault - must be set to true when creating subscriptions
|
|
73
|
+
*/
|
|
74
|
+
vault?: TrueFalse;
|
|
75
|
+
intent?: OrderIntent;
|
|
76
|
+
fundingSource?: "PAYPAL" | "CARD" | "PAYLATER" | "CREDIT" | "VENMO";
|
|
77
|
+
}
|
|
78
|
+
export type TrueFalse = "true" | "false";
|
|
79
|
+
export interface IPayPalUrlConfig {
|
|
80
|
+
clientId: string;
|
|
81
|
+
currency?: string;
|
|
82
|
+
funding?: boolean;
|
|
83
|
+
commit?: TrueFalse;
|
|
84
|
+
vault?: TrueFalse;
|
|
85
|
+
intent?: OrderIntent;
|
|
86
|
+
locale?: string;
|
|
87
|
+
extraParams?: IQueryParam[];
|
|
88
|
+
}
|
|
89
|
+
export interface IOrderDetails {
|
|
90
|
+
create_time: string;
|
|
91
|
+
update_time: string;
|
|
92
|
+
id: string;
|
|
93
|
+
intent: OrderIntent;
|
|
94
|
+
payer: IPayer;
|
|
95
|
+
status: OrderStatus;
|
|
96
|
+
links: ILinkDescription[];
|
|
97
|
+
purchase_units: IPurchaseUnit[];
|
|
98
|
+
}
|
|
99
|
+
export interface IClientAuthorizeCallbackData extends IOrderDetails {
|
|
100
|
+
links: ILinkDescription[];
|
|
101
|
+
}
|
|
102
|
+
export interface ILinkDescription {
|
|
103
|
+
href: string;
|
|
104
|
+
rel: String;
|
|
105
|
+
method?: LinkMethod;
|
|
106
|
+
}
|
|
107
|
+
export interface IQueryParam {
|
|
108
|
+
name: string;
|
|
109
|
+
value: string;
|
|
110
|
+
}
|
|
111
|
+
export type OnShippingChangeCallback = (data: IOnShippingChangeData, actions: IOnShippingChangeActions) => any;
|
|
112
|
+
export interface IOnShippingChangeData {
|
|
113
|
+
paymentToken: string;
|
|
114
|
+
shipping_address: any;
|
|
115
|
+
selected_shipping_method?: any;
|
|
116
|
+
}
|
|
117
|
+
export interface IOnShippingChangeActions {
|
|
118
|
+
resolve: () => any;
|
|
119
|
+
reject: () => any;
|
|
120
|
+
patch: () => any;
|
|
121
|
+
}
|
|
122
|
+
export type LinkMethod = "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "CONNECT" | "OPTIONS" | "PATCH";
|
|
123
|
+
export interface IAdvancedConfiguration {
|
|
124
|
+
commit?: TrueFalse;
|
|
125
|
+
locale?: string;
|
|
126
|
+
extraQueryParams?: IQueryParam[];
|
|
127
|
+
}
|
|
128
|
+
export interface IOnApproveCallbackData {
|
|
129
|
+
orderID: string;
|
|
130
|
+
payerID: string;
|
|
131
|
+
subscriptionID: string;
|
|
132
|
+
}
|
|
133
|
+
export interface ICreateOrderCallbackActions {
|
|
134
|
+
order: {
|
|
135
|
+
create: (order: ICreateOrderRequest) => Promise<any>;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
export interface ICancelCallbackData {
|
|
139
|
+
orderID: string;
|
|
140
|
+
}
|
|
141
|
+
export interface IOnApproveCallbackActions {
|
|
142
|
+
redirect: () => void;
|
|
143
|
+
restart: () => void;
|
|
144
|
+
order: {
|
|
145
|
+
authorize: () => Promise<any>;
|
|
146
|
+
capture: () => Promise<any>;
|
|
147
|
+
get: () => Promise<IOrderDetails>;
|
|
148
|
+
patch: () => Promise<any>;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
export interface IOnInitCallbackActions {
|
|
152
|
+
enable: () => void;
|
|
153
|
+
disable: () => void;
|
|
154
|
+
}
|
|
155
|
+
export interface ICreateSubscriptionCallbackActions {
|
|
156
|
+
subscription: {
|
|
157
|
+
create: (subscription: ICreateSubscriptionRequest) => Promise<any>;
|
|
158
|
+
revise: (subscriptionId: string, subscription: ICreateSubscriptionRequest) => Promise<any>;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
export interface IInitCallbackData {
|
|
162
|
+
}
|
|
163
|
+
export interface ICreateSubscriptionCallbackData {
|
|
164
|
+
}
|
|
165
|
+
export interface IOnClickCallbackActions {
|
|
166
|
+
resolve: () => void;
|
|
167
|
+
reject: () => void;
|
|
168
|
+
}
|
|
169
|
+
export interface IPayPalButtonStyle {
|
|
170
|
+
label?: "paypal" | "checkout" | "pay" | "installment" | "buynow" | "subscribe";
|
|
171
|
+
shape?: "pill" | "rect";
|
|
172
|
+
color?: "gold" | "blue" | "silver" | "white" | "black";
|
|
173
|
+
layout?: "horizontal" | "vertical";
|
|
174
|
+
tagline?: boolean;
|
|
175
|
+
height?: number;
|
|
176
|
+
fundingicons?: boolean;
|
|
177
|
+
}
|
|
178
|
+
export interface ICreateOrderRequest {
|
|
179
|
+
intent: OrderIntent;
|
|
180
|
+
purchase_units: IPurchaseUnit[];
|
|
181
|
+
payer?: IPayer;
|
|
182
|
+
application_context?: IApplicationContext;
|
|
183
|
+
}
|
|
184
|
+
export interface ICreateSubscriptionRequest {
|
|
185
|
+
plan_id: string;
|
|
186
|
+
quantity?: number;
|
|
187
|
+
custom_id: string;
|
|
188
|
+
}
|
|
189
|
+
export interface IPayer {
|
|
190
|
+
name?: IPartyName;
|
|
191
|
+
email_address?: string;
|
|
192
|
+
payer_id?: string;
|
|
193
|
+
birth_date?: string;
|
|
194
|
+
tax_info?: ITaxInfo;
|
|
195
|
+
address?: IAddressPortable;
|
|
196
|
+
phone?: IPhone;
|
|
197
|
+
}
|
|
198
|
+
export interface IApplicationContext {
|
|
199
|
+
brand_name?: string;
|
|
200
|
+
locale?: string;
|
|
201
|
+
landing_page?: PaypalLandingPage;
|
|
202
|
+
shipping_preference?: ShippingPreference;
|
|
203
|
+
user_action?: PayPalUserAction;
|
|
204
|
+
payment_method?: IPaymentMethod;
|
|
205
|
+
return_url?: string;
|
|
206
|
+
cancel_url?: string;
|
|
207
|
+
}
|
|
208
|
+
export interface IPaymentMethod {
|
|
209
|
+
payer_selected?: PayerSelected;
|
|
210
|
+
payee_preferred?: PayeePreferred;
|
|
211
|
+
}
|
|
212
|
+
export type PayeePreferred = "UNRESTRICTED" | "IMMEDIATE_PAYMENT_REQUIRED";
|
|
213
|
+
export type PayerSelected = "PAYPAL_CREDIT" | "PAYPAL";
|
|
214
|
+
export type PayPalUserAction = "CONTINUE" | "PAY_NOW";
|
|
215
|
+
export type ShippingPreference = "GET_FROM_FILE" | "NO_SHIPPING" | "SET_PROVIDED_ADDRESS";
|
|
216
|
+
export type PaypalLandingPage = "LOGIN" | "BILLING";
|
|
217
|
+
export type OrderIntent = "CAPTURE" | "AUTHORIZE" | "subscription";
|
|
218
|
+
export type DisbursementMode = "INSTANT" | "DELAYED";
|
|
219
|
+
export type ItemCategory = "DIGITAL_GOODS" | "PHYSICAL_GOODS";
|
|
220
|
+
export type PhoneType = "FAX" | "HOME" | "MOBILE" | "OTHER" | "PAGER";
|
|
221
|
+
export type TaxIdType = "BR_CPF" | "BR_CNPJ";
|
|
222
|
+
export interface IPhone {
|
|
223
|
+
phone_type?: PhoneType;
|
|
224
|
+
phone_number?: IPhoneNumber;
|
|
225
|
+
}
|
|
226
|
+
export interface ITaxInfo {
|
|
227
|
+
tax_id: string;
|
|
228
|
+
tax_id_type: TaxIdType;
|
|
229
|
+
}
|
|
230
|
+
export interface IPhoneNumber {
|
|
231
|
+
national_number: string;
|
|
232
|
+
}
|
|
233
|
+
export interface IPurchaseUnit {
|
|
234
|
+
amount: IUnitAmount;
|
|
235
|
+
reference_id?: string;
|
|
236
|
+
payee?: IPayee;
|
|
237
|
+
payment_instruction?: IPaymentInstructions;
|
|
238
|
+
description?: string;
|
|
239
|
+
custom_id?: string;
|
|
240
|
+
invoice_id?: string;
|
|
241
|
+
soft_descriptor?: string;
|
|
242
|
+
items: ITransactionItem[];
|
|
243
|
+
shipping?: IShipping;
|
|
244
|
+
}
|
|
245
|
+
export interface IPayee {
|
|
246
|
+
email_address?: string;
|
|
247
|
+
merchant_id?: string;
|
|
248
|
+
}
|
|
249
|
+
export interface IPaymentInstructions {
|
|
250
|
+
platform_fees?: IPlatformFee[];
|
|
251
|
+
disbursement_mode?: DisbursementMode;
|
|
252
|
+
}
|
|
253
|
+
export interface IPlatformFee {
|
|
254
|
+
amount: IUnitAmount;
|
|
255
|
+
payee?: IPayee;
|
|
256
|
+
}
|
|
257
|
+
export interface ITransactionItem {
|
|
258
|
+
name: string;
|
|
259
|
+
unit_amount: IUnitAmount;
|
|
260
|
+
quantity: string;
|
|
261
|
+
description?: string;
|
|
262
|
+
sku?: string;
|
|
263
|
+
category?: ItemCategory;
|
|
264
|
+
tax?: ITax;
|
|
265
|
+
}
|
|
266
|
+
export interface ITax {
|
|
267
|
+
currency_code: string;
|
|
268
|
+
value: string;
|
|
269
|
+
}
|
|
270
|
+
export interface IUnitAmount {
|
|
271
|
+
currency_code: string;
|
|
272
|
+
value: string;
|
|
273
|
+
breakdown?: IUnitBreakdown;
|
|
274
|
+
}
|
|
275
|
+
export interface IMoney {
|
|
276
|
+
currency_code: string;
|
|
277
|
+
value: string;
|
|
278
|
+
}
|
|
279
|
+
export interface IUnitBreakdown {
|
|
280
|
+
item_total?: IUnitAmount;
|
|
281
|
+
shipping?: IUnitAmount;
|
|
282
|
+
handling?: IUnitAmount;
|
|
283
|
+
tax_total?: IUnitAmount;
|
|
284
|
+
insurance?: IUnitAmount;
|
|
285
|
+
shipping_discount?: IUnitAmount;
|
|
286
|
+
discount?: IMoney;
|
|
287
|
+
}
|
|
288
|
+
export interface IPartyName {
|
|
289
|
+
prefix?: string;
|
|
290
|
+
given_name?: string;
|
|
291
|
+
surname?: string;
|
|
292
|
+
middle_name?: string;
|
|
293
|
+
suffix?: string;
|
|
294
|
+
alternate_full_name?: string;
|
|
295
|
+
full_name?: string;
|
|
296
|
+
}
|
|
297
|
+
export interface IAddressPortable {
|
|
298
|
+
country_code: string;
|
|
299
|
+
address_line_1?: string;
|
|
300
|
+
address_line_2?: string;
|
|
301
|
+
admin_area_2?: string;
|
|
302
|
+
admin_area_1?: string;
|
|
303
|
+
postal_code?: string;
|
|
304
|
+
}
|
|
305
|
+
export interface IShipping {
|
|
306
|
+
name?: IPartyName;
|
|
307
|
+
address?: IAddressPortable;
|
|
308
|
+
}
|
|
309
|
+
export type OrderStatus = "APPROVED" | "SAVED" | "CREATED" | "VOIDED" | "COMPLETED";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IPayPalUrlConfig } from '../models/paypal-models';
|
|
2
|
+
import { ScriptService } from '../../services/script.service';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class PayPalScriptService {
|
|
5
|
+
protected scriptService: ScriptService;
|
|
6
|
+
private readonly paypalWindowName;
|
|
7
|
+
constructor(scriptService: ScriptService);
|
|
8
|
+
registerPayPalScript(config: IPayPalUrlConfig, onReady: (payPalApi: any) => void): void;
|
|
9
|
+
destroyPayPalScript(): void;
|
|
10
|
+
private getUrlForConfig;
|
|
11
|
+
private getQueryString;
|
|
12
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PayPalScriptService, never>;
|
|
13
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<PayPalScriptService>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "./PayPal/components/paypal.component";
|
|
3
|
+
import * as i2 from "@angular/common";
|
|
4
|
+
export declare class AnatolyPaymentsModule {
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AnatolyPaymentsModule, never>;
|
|
6
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<AnatolyPaymentsModule, [typeof i1.PayPalComponent], [typeof i2.CommonModule], [typeof i1.PayPalComponent]>;
|
|
7
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<AnatolyPaymentsModule>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NgZone } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class ScriptService {
|
|
4
|
+
protected zone: NgZone;
|
|
5
|
+
constructor(zone: NgZone);
|
|
6
|
+
registerScript(url: string, globalVar: string, onReady: (globalVar: any) => void): void;
|
|
7
|
+
cleanup(globalVar: string): void;
|
|
8
|
+
private getElemId;
|
|
9
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScriptService, never>;
|
|
10
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ScriptService>;
|
|
11
|
+
}
|
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './lib/core';
|
|
2
2
|
export * from './lib/data';
|
|
3
3
|
export * from './lib/iam';
|
|
4
|
+
export * from './lib/payments';
|
|
4
5
|
export * from './lib/ui/components';
|
|
5
6
|
export * from './lib/ui/dialogs';
|
|
6
7
|
export * from './lib/ui/directives';
|
|
@@ -11,5 +12,6 @@ export * from './lib/core/core.module';
|
|
|
11
12
|
export * from './lib/data/data.module';
|
|
12
13
|
export * from './lib/iam/iam.module';
|
|
13
14
|
export * from './lib/iam/iam-pages.module';
|
|
15
|
+
export * from './lib/payments/payments.module';
|
|
14
16
|
export * from './lib/ui/ui.module';
|
|
15
17
|
export * from './lib/anatoly.module';
|