@tap-payments/apple-pay-button 1.0.4-test → 1.0.5-test

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.
@@ -56,9 +56,10 @@ export interface ApplePayButtonProps {
56
56
  onClick?: () => void;
57
57
  onReady?: () => void;
58
58
  onMerchantValidation?: (status: 'initiated' | 'completed' | 'error') => void;
59
- onShippingContactSelected?: (shippingContact: ApplePayPaymentContact) => Promise<ApplePayUpdateData | void>;
60
- onPaymentMethodSelected?: (paymentMethod: ApplePayPaymentMethod) => Promise<ApplePayUpdateData | void>;
61
- onCouponChanged?: (couponCode: string) => Promise<ApplePayUpdateData | void>;
59
+ onShippingMethodSelected?: (shippingMethod: ApplePayShippingMethod) => Promise<ApplePayUpdateData>;
60
+ onShippingContactSelected?: (shippingContact: ApplePayPaymentContact) => Promise<ApplePayUpdateData>;
61
+ onPaymentMethodSelected?: (paymentMethod: ApplePayPaymentMethod) => Promise<ApplePayUpdateData>;
62
+ onCouponChanged?: (couponCode: string) => Promise<ApplePayUpdateData>;
62
63
  metaData?: MetaData;
63
64
  debug?: boolean;
64
65
  }
@@ -6,5 +6,5 @@ interface UseApplePayReturnProps {
6
6
  onApplePayButtonClicked: () => Promise<void>;
7
7
  abortApplePaySession: () => void;
8
8
  }
9
- export declare const useApplePay: ({ publicKey, merchant, transaction, interface: interfaceObj, customer, onCancel, onError, onSuccess, scope, acceptance, metaData, debug, environment, onReady, onMerchantValidation, onShippingContactSelected, onPaymentMethodSelected, onCouponChanged }: UseApplePayProps) => UseApplePayReturnProps;
9
+ export declare const useApplePay: ({ publicKey, merchant, transaction, interface: interfaceObj, customer, onCancel, onError, onSuccess, scope, acceptance, metaData, debug, environment, onReady, onMerchantValidation, onShippingMethodSelected, onShippingContactSelected, onPaymentMethodSelected, onCouponChanged }: UseApplePayProps) => UseApplePayReturnProps;
10
10
  export {};
@@ -52,7 +52,7 @@ import { setAxiosGlobalHeaders } from '../api/httpClient';
52
52
  import { getApplePayPaymentMethod, getApplePayRequest, validateCurrency, validateSupportedNetworks } from '../utils/config';
53
53
  import { getMerchantCapaplities } from '../utils/defaultValues';
54
54
  export var useApplePay = function (_a) {
55
- var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, interfaceObj = _a.interface, customer = _a.customer, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, scope = _a.scope, acceptance = _a.acceptance, metaData = _a.metaData, debug = _a.debug, environment = _a.environment, onReady = _a.onReady, onMerchantValidation = _a.onMerchantValidation, onShippingContactSelected = _a.onShippingContactSelected, onPaymentMethodSelected = _a.onPaymentMethodSelected, onCouponChanged = _a.onCouponChanged;
55
+ var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, interfaceObj = _a.interface, customer = _a.customer, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, scope = _a.scope, acceptance = _a.acceptance, metaData = _a.metaData, debug = _a.debug, environment = _a.environment, onReady = _a.onReady, onMerchantValidation = _a.onMerchantValidation, onShippingMethodSelected = _a.onShippingMethodSelected, onShippingContactSelected = _a.onShippingContactSelected, onPaymentMethodSelected = _a.onPaymentMethodSelected, onCouponChanged = _a.onCouponChanged;
56
56
  var _b = useState(false), loading = _b[0], setLoading = _b[1];
57
57
  var _c = useState(null), profileData = _c[0], setProfile = _c[1];
58
58
  var _d = useState(false), disabled = _d[0], setDisabled = _d[1];
@@ -274,6 +274,25 @@ export var useApplePay = function (_a) {
274
274
  });
275
275
  };
276
276
  }
277
+ if (onShippingMethodSelected) {
278
+ session_1.onshippingmethodselected = function (_a) {
279
+ var shippingMethod = _a.shippingMethod;
280
+ return __awaiter(void 0, void 0, void 0, function () {
281
+ var response;
282
+ return __generator(this, function (_b) {
283
+ switch (_b.label) {
284
+ case 0: return [4, onShippingMethodSelected(shippingMethod)];
285
+ case 1:
286
+ response = _b.sent();
287
+ if (response) {
288
+ session_1.completePaymentMethodSelection(response);
289
+ }
290
+ return [2];
291
+ }
292
+ });
293
+ });
294
+ };
295
+ }
277
296
  if (onPaymentMethodSelected) {
278
297
  session_1.onpaymentmethodselected = function (_a) {
279
298
  var paymentMethod = _a.paymentMethod;
@@ -23,9 +23,10 @@ export declare const getDefaultValues: (mainObject: ApplePayButtonProps) => {
23
23
  onClick?: (() => void) | undefined;
24
24
  onReady?: (() => void) | undefined;
25
25
  onMerchantValidation?: ((status: "initiated" | "completed" | "error") => void) | undefined;
26
- onShippingContactSelected?: ((shippingContact: import("../@types").ApplePayPaymentContact) => Promise<void | import("../@types").ApplePayUpdateData>) | undefined;
27
- onPaymentMethodSelected?: ((paymentMethod: import("../@types").ApplePayPaymentMethod) => Promise<void | import("../@types").ApplePayUpdateData>) | undefined;
28
- onCouponChanged?: ((couponCode: string) => Promise<void | import("../@types").ApplePayUpdateData>) | undefined;
26
+ onShippingMethodSelected?: ((shippingMethod: import("../@types").ApplePayShippingMethod) => Promise<import("../@types").ApplePayUpdateData>) | undefined;
27
+ onShippingContactSelected?: ((shippingContact: import("../@types").ApplePayPaymentContact) => Promise<import("../@types").ApplePayUpdateData>) | undefined;
28
+ onPaymentMethodSelected?: ((paymentMethod: import("../@types").ApplePayPaymentMethod) => Promise<import("../@types").ApplePayUpdateData>) | undefined;
29
+ onCouponChanged?: ((couponCode: string) => Promise<import("../@types").ApplePayUpdateData>) | undefined;
29
30
  metaData?: import("../@types").MetaData | undefined;
30
31
  debug?: boolean | undefined;
31
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/apple-pay-button",
3
- "version": "1.0.4-test",
3
+ "version": "1.0.5-test",
4
4
  "description": "Apple Pay Button React Component",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",