diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d61825..2eb61ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ All notable changes to this project are documented in this file. ### Added +- **`googlePayAssuranceDetailsRequired`** in `PaymentRequest` and the `usePaymentCheckout` config. + `true` sends Google Pay's `assuranceDetailsRequired` in the payment request, and the token's + `paymentMethod.assuranceDetails` (`GooglePayAssuranceDetails`: `accountVerified`, + `cardHolderAuthenticated`) reports whether Google verified the card and authenticated the + cardholder, in `onAuthorize` and the result. When both are `true`, Google says the payment + needs no 3-D Secure step-up. The details are not in the encrypted token, so your server gets + them only from your app, unsigned: treat them as a risk signal. Omitted or `false`, the request + and the result are unchanged. Android only + ([#88](https://github.com/gmi-software/react-native-pay/issues/88)). - **Google Pay `DIRECT` tokenization.** `PaymentRequest` and `usePaymentCheckout` add `googlePayTokenization`. `{ type: 'direct', publicKey }` has Google encrypt the token with your own EC public key (`protocolVersion: "ECv2"`), for a PCI DSS compliant server that decrypts it; diff --git a/README.md b/README.md index 7021bd8..401518c 100644 --- a/README.md +++ b/README.md @@ -366,6 +366,7 @@ interface UsePaymentCheckoutConfig { googlePayTokenization?: GooglePayTokenization; // Default: gateway. { type: "direct", publicKey } to decrypt yourself googlePayAllowedAuthMethods?: GooglePayAuthMethod[]; // Default: ['PAN_ONLY', 'CRYPTOGRAM_3DS'] googlePayAllowPrepaidCards?: boolean; // false leaves prepaid cards out. Default: true + googlePayAssuranceDetailsRequired?: boolean; // true returns token.paymentMethod.assuranceDetails. Default: false googlePayCheckoutOption?: GooglePayCheckoutOption; // Sheet button label. Default: Google Pay picks // Contact details, returned in the result (see "Shipping and contact details") billingContactRequired?: boolean; @@ -811,6 +812,7 @@ interface PaymentRequest { googlePayTokenization?: GooglePayTokenization; // who encrypts the token googlePayAllowedAuthMethods?: string[]; // GooglePayAuthMethod values googlePayAllowPrepaidCards?: boolean; // false leaves prepaid cards out + googlePayAssuranceDetailsRequired?: boolean; // ask whether Google verified the card googlePayCheckoutOption?: GooglePayCheckoutOption; // the sheet's button label } @@ -847,6 +849,13 @@ interface PaymentMethod { type: PaymentMethodType; // funding source; "store" is iOS only secureElementPass?: PKSecureElementPass; billingAddress?: CNContact; + assuranceDetails?: GooglePayAssuranceDetails; // Android, with googlePayAssuranceDetailsRequired +} + +// What Google checked about the card (Android) +interface GooglePayAssuranceDetails { + accountVerified: boolean; // the payer possesses the card + cardHolderAuthenticated: boolean; // Google identified and verified the cardholder } // Payment Networks. Google Pay offers visa, mastercard, amex, discover, jcb diff --git a/docs/docs/api/types.md b/docs/docs/api/types.md index 963828f..1e440bc 100644 --- a/docs/docs/api/types.md +++ b/docs/docs/api/types.md @@ -93,6 +93,7 @@ interface PaymentRequest { googlePayTokenization?: GooglePayTokenization // default: gateway googlePayAllowedAuthMethods?: string[] // GooglePayAuthMethod values googlePayAllowPrepaidCards?: boolean // default: true + googlePayAssuranceDetailsRequired?: boolean // default: false googlePayCheckoutOption?: GooglePayCheckoutOption // the sheet's button label } ``` @@ -115,6 +116,8 @@ Without `googlePayEnvironment`, Android uses `'TEST'`. When it is omitted, an An `googlePayAllowPrepaidCards: false` leaves prepaid cards out of the Google Pay sheet, for a gateway or risk policy that refuses them. Sent as Google Pay's `allowPrepaidCards`. Omitted or `true`, prepaid cards are accepted. Android only: Apple Pay cannot leave prepaid cards out. +`googlePayAssuranceDetailsRequired: true` asks Google Pay whether it verified the card and authenticated the cardholder, returned as [`token.paymentMethod.assuranceDetails`](#googlepayassurancedetails). Sent as Google Pay's `assuranceDetailsRequired`. Omitted or `false`, the request and the result are unchanged. Android only. + `googlePayCheckoutOption` sets the label of the Google Pay sheet's button: see [`GooglePayCheckoutOption`](#googlepaycheckoutoption). Omitted, Google Pay picks "Continue" or "Pay". Android only. `billingContactRequired`, `shippingContactRequired`, `emailRequired` and `phoneNumberRequired` ask the payer for contact details, which come back in the result as [`PaymentDetails`](#paymentdetails). On Android, a phone number is collected with an address. See [Shipping and contact details](/docs/guides/contact-details). @@ -328,6 +331,7 @@ interface PaymentMethod { type: PaymentMethodType secureElementPass?: PKSecureElementPass // iOS billingAddress?: CNContact // iOS + assuranceDetails?: GooglePayAssuranceDetails // Android } type PaymentMethodType = 'unknown' | 'debit' | 'credit' | 'prepaid' | 'store' @@ -338,6 +342,21 @@ type PaymentMethodType = 'unknown' | 'debit' | 'credit' | 'prepaid' | 'store' - **displayName** — Describes the card to the payer, as the wallet words it: `PKPaymentMethod.displayName` on iOS, `paymentMethodData.description` on Android (for example "Visa •••• 1234"). Show it as is; don't parse it. - **network** — The card's [`PaymentNetwork`](#paymentnetwork), or `'unknown'` for a network the library cannot name. Use `network` rather than `displayName` for logic. - **type** — How the card is funded: `PKPaymentMethod.type` on iOS, Google Pay's `cardFundingSource` on Android. Android reports `'credit'`, `'debit'` or `'prepaid'`, and `'unknown'` when Google Pay does not know; `'store'` (a store card) is iOS only. +- **assuranceDetails** — What Google checked about the card. Set only when `googlePayAssuranceDetailsRequired` asked for it and Google Pay returned it. Android only. See [GooglePayAssuranceDetails](#googlepayassurancedetails). + +### GooglePayAssuranceDetails + +```ts no-check +interface GooglePayAssuranceDetails { + accountVerified: boolean + cardHolderAuthenticated: boolean +} +``` + +- **accountVerified** — Google validated that the payer possesses the card. +- **cardHolderAuthenticated** — Google identified and verified the cardholder (ID&V). `false` leaves it to the risk checks you run for other card payments, such as a 3-D Secure step-up. + +When both are `true`, Google says you don't need to step up the payment. A flag missing from Google Pay's response reads as `false`. The details are not part of the encrypted `paymentData`: they reach your server through your app, with nothing to prove Google sent them. Treat them as a risk signal, not as the only reason to skip 3-D Secure, and prefer your gateway's own report of them if it has one. See [Card authentication and 3-D Secure](/docs/setup/android-google-pay#card-authentication-and-3-d-secure) and Google's [AssuranceDetailsSpecifications](https://developers.google.com/pay/api/android/reference/response-objects#assurance-details-specifications). --- diff --git a/docs/docs/api/use-payment-checkout.md b/docs/docs/api/use-payment-checkout.md index e0240d3..2871ef2 100644 --- a/docs/docs/api/use-payment-checkout.md +++ b/docs/docs/api/use-payment-checkout.md @@ -31,6 +31,7 @@ interface UsePaymentCheckoutConfig { googlePayTokenization?: GooglePayTokenization // default: gateway googlePayAllowedAuthMethods?: GooglePayAuthMethod[] // default: both googlePayAllowPrepaidCards?: boolean // default: true + googlePayAssuranceDetailsRequired?: boolean // default: false googlePayCheckoutOption?: GooglePayCheckoutOption // the sheet's button label // Contact details, returned in the result billingContactRequired?: boolean @@ -57,6 +58,7 @@ interface UsePaymentCheckoutConfig { - **googlePayTokenization** — Android only. Who encrypts the Google Pay token. Omitted or `{ type: 'gateway' }`, your gateway does, from `googlePayGateway` and `googlePayGatewayMerchantId`. `{ type: 'direct', publicKey }` has Google encrypt it with your own key, for a PCI DSS compliant server that decrypts it; it needs Google's approval. A missing `publicKey` fails with a `'CONFIGURATION'` error. See [GooglePayTokenization](/docs/api/types#googlepaytokenization). - **googlePayAllowedAuthMethods** — Android only. Which Google Pay cards to accept: `'PAN_ONLY'` (saved to the Google account), `'CRYPTOGRAM_3DS'` (tokenized on the device), or both, the default. See [GooglePayAuthMethod](/docs/api/types#googlepayauthmethod). - **googlePayAllowPrepaidCards** — Android only. `false` leaves prepaid cards out of the Google Pay sheet, for a gateway or risk policy that refuses them; without it, the payer learns only when the charge fails. Defaults to `true`. Pass the same value to [`GooglePayButton`](/docs/api/components#googlepaybutton-android-only). +- **googlePayAssuranceDetailsRequired** — Android only. `true` asks Google Pay whether it verified the card and authenticated the cardholder, returned as `token.paymentMethod.assuranceDetails` in `onAuthorize` and the result, for example to skip a 3-D Secure step-up. Defaults to `false`. See [GooglePayAssuranceDetails](/docs/api/types#googlepayassurancedetails). - **googlePayCheckoutOption** — Android only. The label of the Google Pay sheet's button: `'default'` ("Continue" or "Pay", as when it is omitted), `'completeImmediatePurchase'` ("Pay now") or `'continueToReview'` ("Review Order"). `'completeImmediatePurchase'` needs a final total: with a `'pending'` item, `startPayment()` fails with a `'CONFIGURATION'` error before the sheet opens. See [GooglePayCheckoutOption](/docs/api/types#googlepaycheckoutoption). - **merchantCapabilities** — The card types to accept and, on iOS, the payment protocols. iOS adds `'3DS'` when neither `'3DS'` nor `'EMV'` is given. On Android only `'Debit'` without `'Credit'` has an effect: it leaves credit cards out. Google Pay cannot leave debit cards out, so `['3DS', 'Credit']` accepts every card type on Android. An unknown value fails the payment on both platforms. Pass the same list to [`GooglePayButton`](/docs/api/components#googlepaybutton-android-only). See [MerchantCapability](/docs/api/types#merchantcapability). - **supportedNetworks**, **merchantCapabilities**, **googlePayAllowedAuthMethods**, **googlePayAllowPrepaidCards**, **googlePayEnvironment** — Also used for the availability check, which fails like the payment for a value the payment would refuse. Set `googlePayEnvironment: 'PRODUCTION'` in a live app: in `TEST`, Google Pay reports a card whether or not there is one. Omitted, it is `'TEST'`, and an Android release build logs a warning once per app run when `startPayment()` builds a payment. The availability check alone logs nothing. diff --git a/docs/docs/setup/android-google-pay.md b/docs/docs/setup/android-google-pay.md index 261b967..e47a027 100644 --- a/docs/docs/setup/android-google-pay.md +++ b/docs/docs/setup/android-google-pay.md @@ -124,7 +124,30 @@ usePaymentCheckout({ }) ``` -Google can also report whether it has already verified the card and the cardholder ([`assuranceDetailsRequired`](https://developers.google.com/pay/api/android/reference/response-objects#assurance-details-specifications)), so you can skip the step-up when both checks pass. This library does not request it yet. +Google can also report whether it has already verified the card and authenticated the cardholder. Ask for it with `googlePayAssuranceDetailsRequired`, and read [`token.paymentMethod.assuranceDetails`](/docs/api/types#googlepayassurancedetails). When both `accountVerified` and `cardHolderAuthenticated` are `true`, Google says you don't need to step up the payment: + +```ts +import { usePaymentCheckout } from '@gmisoftware/react-native-pay' + +const order = { id: 'order_123' } // your order + +usePaymentCheckout({ + googlePayAssuranceDetailsRequired: true, + onAuthorize: async (token) => { + const assurance = token.paymentMethod.assuranceDetails + // Your server charges each order at most once, also when the app + // retries after a lost response. + const response = await fetch('https://api.yourserver.com/process-payment', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ token, orderId: order.id, assurance }), + }) + return response.ok ? { status: 'success' } : { status: 'failure' } + }, +}) +``` + +The details are not part of the encrypted token: they reach your server through your app, as above, with nothing to prove Google sent them. Treat them as a risk signal, not as the only reason to skip 3-D Secure, and prefer your gateway's own report of them if it has one. See Google's [AssuranceDetailsSpecifications](https://developers.google.com/pay/api/android/reference/response-objects#assurance-details-specifications). ## The `donate` button diff --git a/package/android/src/main/java/com/margelo/nitro/pay/GooglePayRequestBuilder.kt b/package/android/src/main/java/com/margelo/nitro/pay/GooglePayRequestBuilder.kt index a091bdf..4095162 100644 --- a/package/android/src/main/java/com/margelo/nitro/pay/GooglePayRequestBuilder.kt +++ b/package/android/src/main/java/com/margelo/nitro/pay/GooglePayRequestBuilder.kt @@ -199,6 +199,10 @@ object GooglePayRequestBuilder { }) } } + if (request.googlePayAssuranceDetailsRequired == true) { + // Only the payment request: the readiness check and the button have no result to carry it. + baseMethod.getJSONObject("parameters").put("assuranceDetailsRequired", true) + } baseMethod.put("tokenizationSpecification", createTokenizationSpec(request, environment)) return baseMethod } diff --git a/package/android/src/main/java/com/margelo/nitro/pay/PaymentMapper.kt b/package/android/src/main/java/com/margelo/nitro/pay/PaymentMapper.kt index 1411b03..66ae55c 100644 --- a/package/android/src/main/java/com/margelo/nitro/pay/PaymentMapper.kt +++ b/package/android/src/main/java/com/margelo/nitro/pay/PaymentMapper.kt @@ -41,7 +41,8 @@ object PaymentMapper { network = GooglePayNetworks.fromGooglePay(cardNetwork), type = mapCardFundingSource(cardFundingSource), secureElementPass = null, - billingAddress = null + billingAddress = null, + assuranceDetails = info.optJSONObject("assuranceDetails")?.let(::mapAssuranceDetails) ) // Create payment token @@ -125,6 +126,17 @@ object PaymentMapper { ) } + /** + * Maps Google Pay's `assuranceDetails`, returned only when the request set + * `assuranceDetailsRequired`. A missing flag reads as `false`: not checked. + */ + private fun mapAssuranceDetails(details: JSONObject): GooglePayAssuranceDetails { + return GooglePayAssuranceDetails( + accountVerified = details.optBoolean("accountVerified", false), + cardHolderAuthenticated = details.optBoolean("cardHolderAuthenticated", false) + ) + } + /** * The trimmed string at [key], or null when it is missing, JSON null or blank */ diff --git a/package/android/src/test/java/com/margelo/nitro/pay/AuthorizationAttemptTest.kt b/package/android/src/test/java/com/margelo/nitro/pay/AuthorizationAttemptTest.kt index 8cf4865..0fcd09f 100644 --- a/package/android/src/test/java/com/margelo/nitro/pay/AuthorizationAttemptTest.kt +++ b/package/android/src/test/java/com/margelo/nitro/pay/AuthorizationAttemptTest.kt @@ -17,7 +17,8 @@ class AuthorizationAttemptTest { network = PaymentNetwork.VISA, type = PaymentMethodType.CREDIT, secureElementPass = null, - billingAddress = null + billingAddress = null, + assuranceDetails = null ), transactionIdentifier = null, paymentData = "gateway-token" diff --git a/package/android/src/test/java/com/margelo/nitro/pay/GooglePayRequestBuilderTest.kt b/package/android/src/test/java/com/margelo/nitro/pay/GooglePayRequestBuilderTest.kt index a3570cd..083ffcd 100644 --- a/package/android/src/test/java/com/margelo/nitro/pay/GooglePayRequestBuilderTest.kt +++ b/package/android/src/test/java/com/margelo/nitro/pay/GooglePayRequestBuilderTest.kt @@ -841,6 +841,38 @@ class GooglePayRequestBuilderTest { assertFalse(parameters.getBoolean("allowPrepaidCards")) } + // Assurance details + + @Test + fun assuranceDetailsRequired_asksForThemInThePaymentRequestOnly() { + val request = build(paymentRequest(coffee, googlePayAssuranceDetailsRequired = true)) + val readiness = GooglePayRequestBuilder.createIsReadyToPayRequest(GooglePayCardParameters.DEFAULT) + val button = GooglePayRequestBuilder.createAllowedPaymentMethods(GooglePayCardParameters.DEFAULT) + + assertTrue(request.cardParameters().getBoolean("assuranceDetailsRequired")) + assertFalse(readiness.cardParameters().has("assuranceDetailsRequired")) + assertFalse(button.getJSONObject(0).getJSONObject("parameters").has("assuranceDetailsRequired")) + } + + @Test + fun assuranceDetailsOmittedOrFalse_sendsTheSameRequestAsBefore() { + val omitted = build(paymentRequest(coffee)) + val notRequired = build(paymentRequest(coffee, googlePayAssuranceDetailsRequired = false)) + + assertFalse(omitted.cardParameters().has("assuranceDetailsRequired")) + assertEquals(omitted.toString(), notRequired.toString()) + } + + @Test + fun assuranceDetailsRequired_combinesWithABillingAddress() { + val parameters = build( + paymentRequest(coffee, billingContactRequired = true, googlePayAssuranceDetailsRequired = true) + ).cardParameters() + + assertTrue(parameters.getBoolean("assuranceDetailsRequired")) + assertTrue(parameters.getBoolean("billingAddressRequired")) + } + // Payment data callbacks private fun buildWithCallbacks(request: PaymentRequest, callbacks: CallbackIntents): JSONObject = diff --git a/package/android/src/test/java/com/margelo/nitro/pay/PaymentMapperTest.kt b/package/android/src/test/java/com/margelo/nitro/pay/PaymentMapperTest.kt index e588c52..1b9b552 100644 --- a/package/android/src/test/java/com/margelo/nitro/pay/PaymentMapperTest.kt +++ b/package/android/src/test/java/com/margelo/nitro/pay/PaymentMapperTest.kt @@ -98,6 +98,60 @@ class PaymentMapperTest { assertNull(token.paymentMethod.billingAddress) } + @Test + fun mapPaymentDataToResult_readsTheAssuranceDetails() { + // Google's sample response for a request with assuranceDetailsRequired + val result = PaymentMapper.mapPaymentDataToResult( + paymentData( + """ + { + "type": "CARD", + "description": "Visa •••• 1234", + "info": { + "cardNetwork": "VISA", + "cardDetails": "1234", + "assuranceDetails": {"accountVerified": true, "cardHolderAuthenticated": false} + }, + "tokenizationData": {"type": "PAYMENT_GATEWAY", "token": "gateway-token"} + } + """ + ) + ) + + assertEquals( + GooglePayAssuranceDetails(accountVerified = true, cardHolderAuthenticated = false), + result.token!!.paymentMethod.assuranceDetails + ) + } + + @Test + fun mapPaymentDataToResult_reportsAMissingAssuranceFlagAsNotChecked() { + val result = PaymentMapper.mapPaymentDataToResult( + paymentData( + """ + { + "info": {"cardNetwork": "VISA", "assuranceDetails": {"cardHolderAuthenticated": true}}, + "tokenizationData": {"token": "gateway-token"} + } + """ + ) + ) + + assertEquals( + GooglePayAssuranceDetails(accountVerified = false, cardHolderAuthenticated = true), + result.token!!.paymentMethod.assuranceDetails + ) + } + + @Test + fun mapPaymentDataToResult_reportsNoAssuranceDetailsWithoutThem() { + val result = PaymentMapper.mapPaymentDataToResult( + paymentData("""{"info": {"cardNetwork": "VISA"}, "tokenizationData": {"token": "gateway-token"}}""") + ) + + assertNull(result.token!!.paymentMethod.assuranceDetails) + } + @Test fun mapPaymentDataToResult_fillsMissingCardInfo() { val result = PaymentMapper.mapPaymentDataToResult( diff --git a/package/android/src/test/java/com/margelo/nitro/pay/SheetAuthorizationTest.kt b/package/android/src/test/java/com/margelo/nitro/pay/SheetAuthorizationTest.kt index 56fe1fd..7392567 100644 --- a/package/android/src/test/java/com/margelo/nitro/pay/SheetAuthorizationTest.kt +++ b/package/android/src/test/java/com/margelo/nitro/pay/SheetAuthorizationTest.kt @@ -17,7 +17,8 @@ class SheetAuthorizationTest { network = PaymentNetwork.VISA, type = PaymentMethodType.CREDIT, secureElementPass = null, - billingAddress = null + billingAddress = null, + assuranceDetails = null ), transactionIdentifier = null, paymentData = token diff --git a/package/android/src/test/java/com/margelo/nitro/pay/TestFixtures.kt b/package/android/src/test/java/com/margelo/nitro/pay/TestFixtures.kt index de34d8f..e05d960 100644 --- a/package/android/src/test/java/com/margelo/nitro/pay/TestFixtures.kt +++ b/package/android/src/test/java/com/margelo/nitro/pay/TestFixtures.kt @@ -34,6 +34,7 @@ internal fun paymentRequest( supportedNetworks: Array = arrayOf("visa"), googlePayAllowedAuthMethods: Array? = null, googlePayAllowPrepaidCards: Boolean? = null, + googlePayAssuranceDetailsRequired: Boolean? = null, merchantCapabilities: Array = arrayOf("3DS"), recurring: RecurringPaymentRequest? = null, deferred: DeferredPaymentRequest? = null, @@ -68,6 +69,7 @@ internal fun paymentRequest( googlePayTokenization = googlePayTokenization, googlePayAllowedAuthMethods = googlePayAllowedAuthMethods, googlePayAllowPrepaidCards = googlePayAllowPrepaidCards, + googlePayAssuranceDetailsRequired = googlePayAssuranceDetailsRequired, googlePayCheckoutOption = googlePayCheckoutOption ) diff --git a/package/ios/HybridPaymentHandler.swift b/package/ios/HybridPaymentHandler.swift index 8868602..026ab68 100644 --- a/package/ios/HybridPaymentHandler.swift +++ b/package/ios/HybridPaymentHandler.swift @@ -419,7 +419,9 @@ private struct PaymentTokenConverter { network: pkMethod.network.map { PassKitTypeMapper.convert($0) }, type: PassKitTypeMapper.convert(pkMethod.type), secureElementPass: convertSecureElementPass(pkMethod), - billingAddress: convertBillingAddress(pkMethod) + billingAddress: convertBillingAddress(pkMethod), + // Google Pay only + assuranceDetails: nil ) } diff --git a/package/ios/Tests/PaymentSheetSessionTests.swift b/package/ios/Tests/PaymentSheetSessionTests.swift index a7160c7..081fff9 100644 --- a/package/ios/Tests/PaymentSheetSessionTests.swift +++ b/package/ios/Tests/PaymentSheetSessionTests.swift @@ -32,7 +32,8 @@ final class PaymentSheetSessionTests: XCTestCase { network: .visa, type: .credit, secureElementPass: nil, - billingAddress: nil + billingAddress: nil, + assuranceDetails: nil ), transactionIdentifier: "transaction", paymentData: "data" @@ -85,6 +86,7 @@ final class PaymentSheetSessionTests: XCTestCase { googlePayTokenization: nil, googlePayAllowedAuthMethods: nil, googlePayAllowPrepaidCards: nil, + googlePayAssuranceDetailsRequired: nil, googlePayCheckoutOption: nil ) } diff --git a/package/ios/Tests/TestFixtures.swift b/package/ios/Tests/TestFixtures.swift index b9b5d76..4a47ecd 100644 --- a/package/ios/Tests/TestFixtures.swift +++ b/package/ios/Tests/TestFixtures.swift @@ -65,6 +65,7 @@ func paymentRequest( googlePayTokenization: nil, googlePayAllowedAuthMethods: nil, googlePayAllowPrepaidCards: nil, + googlePayAssuranceDetailsRequired: nil, googlePayCheckoutOption: nil ) } diff --git a/package/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_PaymentAuthorizationResult_____PaymentToken_PaymentDetails.hpp b/package/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_PaymentAuthorizationResult_____PaymentToken_PaymentDetails.hpp index c356e75..60012de 100644 --- a/package/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_PaymentAuthorizationResult_____PaymentToken_PaymentDetails.hpp +++ b/package/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_PaymentAuthorizationResult_____PaymentToken_PaymentDetails.hpp @@ -48,6 +48,8 @@ #include "JCNLabeledPostalAddress.hpp" #include "CNPostalAddress.hpp" #include "JCNPostalAddress.hpp" +#include "GooglePayAssuranceDetails.hpp" +#include "JGooglePayAssuranceDetails.hpp" #include "JPaymentDetails.hpp" #include "PaymentContact.hpp" #include "JPaymentContact.hpp" diff --git a/package/nitrogen/generated/android/c++/JGooglePayAssuranceDetails.hpp b/package/nitrogen/generated/android/c++/JGooglePayAssuranceDetails.hpp new file mode 100644 index 0000000..ea8a09d --- /dev/null +++ b/package/nitrogen/generated/android/c++/JGooglePayAssuranceDetails.hpp @@ -0,0 +1,61 @@ +/// +/// JGooglePayAssuranceDetails.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "GooglePayAssuranceDetails.hpp" + + + +namespace margelo::nitro::pay { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "GooglePayAssuranceDetails" and the Kotlin data class "GooglePayAssuranceDetails". + */ + struct JGooglePayAssuranceDetails final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pay/GooglePayAssuranceDetails;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct GooglePayAssuranceDetails by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + GooglePayAssuranceDetails toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldAccountVerified = clazz->getField("accountVerified"); + jboolean accountVerified = this->getFieldValue(fieldAccountVerified); + static const auto fieldCardHolderAuthenticated = clazz->getField("cardHolderAuthenticated"); + jboolean cardHolderAuthenticated = this->getFieldValue(fieldCardHolderAuthenticated); + return GooglePayAssuranceDetails( + static_cast(accountVerified), + static_cast(cardHolderAuthenticated) + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const GooglePayAssuranceDetails& value) { + using JSignature = JGooglePayAssuranceDetails(jboolean, jboolean); + static const auto clazz = javaClassStatic(); + static const auto create = clazz->getStaticMethod("fromCpp"); + return create( + clazz, + value.accountVerified, + value.cardHolderAuthenticated + ); + } + }; + +} // namespace margelo::nitro::pay diff --git a/package/nitrogen/generated/android/c++/JHybridPaymentHandlerSpec.cpp b/package/nitrogen/generated/android/c++/JHybridPaymentHandlerSpec.cpp index f99f361..44780d2 100644 --- a/package/nitrogen/generated/android/c++/JHybridPaymentHandlerSpec.cpp +++ b/package/nitrogen/generated/android/c++/JHybridPaymentHandlerSpec.cpp @@ -41,6 +41,8 @@ namespace margelo::nitro::pay { struct CNLabeledEmailAddress; } namespace margelo::nitro::pay { struct CNLabeledPostalAddress; } // Forward declaration of `CNPostalAddress` to properly resolve imports. namespace margelo::nitro::pay { struct CNPostalAddress; } +// Forward declaration of `GooglePayAssuranceDetails` to properly resolve imports. +namespace margelo::nitro::pay { struct GooglePayAssuranceDetails; } // Forward declaration of `PaymentContact` to properly resolve imports. namespace margelo::nitro::pay { struct PaymentContact; } // Forward declaration of `ShippingMethod` to properly resolve imports. @@ -141,6 +143,8 @@ namespace margelo::nitro::pay { struct PaymentSheetCard; } #include "JCNLabeledPostalAddress.hpp" #include "CNPostalAddress.hpp" #include "JCNPostalAddress.hpp" +#include "GooglePayAssuranceDetails.hpp" +#include "JGooglePayAssuranceDetails.hpp" #include "PaymentContact.hpp" #include "JPaymentContact.hpp" #include "ShippingMethod.hpp" diff --git a/package/nitrogen/generated/android/c++/JPaymentMethod.hpp b/package/nitrogen/generated/android/c++/JPaymentMethod.hpp index fec6acb..506cb41 100644 --- a/package/nitrogen/generated/android/c++/JPaymentMethod.hpp +++ b/package/nitrogen/generated/android/c++/JPaymentMethod.hpp @@ -17,6 +17,7 @@ #include "CNLabeledPostalAddress.hpp" #include "CNPhoneNumber.hpp" #include "CNPostalAddress.hpp" +#include "GooglePayAssuranceDetails.hpp" #include "JCNContact.hpp" #include "JCNContactType.hpp" #include "JCNLabeledEmailAddress.hpp" @@ -24,6 +25,7 @@ #include "JCNLabeledPostalAddress.hpp" #include "JCNPhoneNumber.hpp" #include "JCNPostalAddress.hpp" +#include "JGooglePayAssuranceDetails.hpp" #include "JPKSecureElementPass.hpp" #include "JPassActivationState.hpp" #include "JPaymentMethodType.hpp" @@ -65,12 +67,15 @@ namespace margelo::nitro::pay { jni::local_ref secureElementPass = this->getFieldValue(fieldSecureElementPass); static const auto fieldBillingAddress = clazz->getField("billingAddress"); jni::local_ref billingAddress = this->getFieldValue(fieldBillingAddress); + static const auto fieldAssuranceDetails = clazz->getField("assuranceDetails"); + jni::local_ref assuranceDetails = this->getFieldValue(fieldAssuranceDetails); return PaymentMethod( displayName != nullptr ? std::make_optional(displayName->toStdString()) : std::nullopt, network != nullptr ? std::make_optional(network->toCpp()) : std::nullopt, type->toCpp(), secureElementPass != nullptr ? std::make_optional(secureElementPass->toCpp()) : std::nullopt, - billingAddress != nullptr ? std::make_optional(billingAddress->toCpp()) : std::nullopt + billingAddress != nullptr ? std::make_optional(billingAddress->toCpp()) : std::nullopt, + assuranceDetails != nullptr ? std::make_optional(assuranceDetails->toCpp()) : std::nullopt ); } @@ -80,7 +85,7 @@ namespace margelo::nitro::pay { */ [[maybe_unused]] static jni::local_ref fromCpp(const PaymentMethod& value) { - using JSignature = JPaymentMethod(jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref); + using JSignature = JPaymentMethod(jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref); static const auto clazz = javaClassStatic(); static const auto create = clazz->getStaticMethod("fromCpp"); return create( @@ -89,7 +94,8 @@ namespace margelo::nitro::pay { value.network.has_value() ? JPaymentNetwork::fromCpp(value.network.value()) : nullptr, JPaymentMethodType::fromCpp(value.type), value.secureElementPass.has_value() ? JPKSecureElementPass::fromCpp(value.secureElementPass.value()) : nullptr, - value.billingAddress.has_value() ? JCNContact::fromCpp(value.billingAddress.value()) : nullptr + value.billingAddress.has_value() ? JCNContact::fromCpp(value.billingAddress.value()) : nullptr, + value.assuranceDetails.has_value() ? JGooglePayAssuranceDetails::fromCpp(value.assuranceDetails.value()) : nullptr ); } }; diff --git a/package/nitrogen/generated/android/c++/JPaymentRequest.hpp b/package/nitrogen/generated/android/c++/JPaymentRequest.hpp index 4c9c4e7..cea302a 100644 --- a/package/nitrogen/generated/android/c++/JPaymentRequest.hpp +++ b/package/nitrogen/generated/android/c++/JPaymentRequest.hpp @@ -127,6 +127,8 @@ namespace margelo::nitro::pay { jni::local_ref> googlePayAllowedAuthMethods = this->getFieldValue(fieldGooglePayAllowedAuthMethods); static const auto fieldGooglePayAllowPrepaidCards = clazz->getField("googlePayAllowPrepaidCards"); jni::local_ref googlePayAllowPrepaidCards = this->getFieldValue(fieldGooglePayAllowPrepaidCards); + static const auto fieldGooglePayAssuranceDetailsRequired = clazz->getField("googlePayAssuranceDetailsRequired"); + jni::local_ref googlePayAssuranceDetailsRequired = this->getFieldValue(fieldGooglePayAssuranceDetailsRequired); static const auto fieldGooglePayCheckoutOption = clazz->getField("googlePayCheckoutOption"); jni::local_ref googlePayCheckoutOption = this->getFieldValue(fieldGooglePayCheckoutOption); return PaymentRequest( @@ -212,6 +214,7 @@ namespace margelo::nitro::pay { return __vector; }(googlePayAllowedAuthMethods)) : std::nullopt, googlePayAllowPrepaidCards != nullptr ? std::make_optional(static_cast(googlePayAllowPrepaidCards->value())) : std::nullopt, + googlePayAssuranceDetailsRequired != nullptr ? std::make_optional(static_cast(googlePayAssuranceDetailsRequired->value())) : std::nullopt, googlePayCheckoutOption != nullptr ? std::make_optional(googlePayCheckoutOption->toCpp()) : std::nullopt ); } @@ -222,7 +225,7 @@ namespace margelo::nitro::pay { */ [[maybe_unused]] static jni::local_ref fromCpp(const PaymentRequest& value) { - using JSignature = JPaymentRequest(jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref>, jni::alias_ref>, jni::alias_ref>, jni::alias_ref, jni::alias_ref>, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref>, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref>, jni::alias_ref, jni::alias_ref); + using JSignature = JPaymentRequest(jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref>, jni::alias_ref>, jni::alias_ref>, jni::alias_ref, jni::alias_ref>, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref>, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref>, jni::alias_ref, jni::alias_ref, jni::alias_ref); static const auto clazz = javaClassStatic(); static const auto create = clazz->getStaticMethod("fromCpp"); return create( @@ -309,6 +312,7 @@ namespace margelo::nitro::pay { return __array; }(value.googlePayAllowedAuthMethods.value()) : nullptr, value.googlePayAllowPrepaidCards.has_value() ? jni::JBoolean::valueOf(value.googlePayAllowPrepaidCards.value()) : nullptr, + value.googlePayAssuranceDetailsRequired.has_value() ? jni::JBoolean::valueOf(value.googlePayAssuranceDetailsRequired.value()) : nullptr, value.googlePayCheckoutOption.has_value() ? JGooglePayCheckoutOption::fromCpp(value.googlePayCheckoutOption.value()) : nullptr ); } diff --git a/package/nitrogen/generated/android/c++/JPaymentResult.hpp b/package/nitrogen/generated/android/c++/JPaymentResult.hpp index f814fdc..841afcf 100644 --- a/package/nitrogen/generated/android/c++/JPaymentResult.hpp +++ b/package/nitrogen/generated/android/c++/JPaymentResult.hpp @@ -17,6 +17,7 @@ #include "CNLabeledPostalAddress.hpp" #include "CNPhoneNumber.hpp" #include "CNPostalAddress.hpp" +#include "GooglePayAssuranceDetails.hpp" #include "JCNContact.hpp" #include "JCNContactType.hpp" #include "JCNLabeledEmailAddress.hpp" @@ -24,6 +25,7 @@ #include "JCNLabeledPostalAddress.hpp" #include "JCNPhoneNumber.hpp" #include "JCNPostalAddress.hpp" +#include "JGooglePayAssuranceDetails.hpp" #include "JPKSecureElementPass.hpp" #include "JPassActivationState.hpp" #include "JPaymentAmount.hpp" diff --git a/package/nitrogen/generated/android/c++/JPaymentToken.hpp b/package/nitrogen/generated/android/c++/JPaymentToken.hpp index 07a6f03..e10a8e3 100644 --- a/package/nitrogen/generated/android/c++/JPaymentToken.hpp +++ b/package/nitrogen/generated/android/c++/JPaymentToken.hpp @@ -17,6 +17,7 @@ #include "CNLabeledPostalAddress.hpp" #include "CNPhoneNumber.hpp" #include "CNPostalAddress.hpp" +#include "GooglePayAssuranceDetails.hpp" #include "JCNContact.hpp" #include "JCNContactType.hpp" #include "JCNLabeledEmailAddress.hpp" @@ -24,6 +25,7 @@ #include "JCNLabeledPostalAddress.hpp" #include "JCNPhoneNumber.hpp" #include "JCNPostalAddress.hpp" +#include "JGooglePayAssuranceDetails.hpp" #include "JPKSecureElementPass.hpp" #include "JPassActivationState.hpp" #include "JPaymentMethod.hpp" diff --git a/package/nitrogen/generated/android/c++/JStartPaymentOptions.hpp b/package/nitrogen/generated/android/c++/JStartPaymentOptions.hpp index d9c4ee2..7b1867c 100644 --- a/package/nitrogen/generated/android/c++/JStartPaymentOptions.hpp +++ b/package/nitrogen/generated/android/c++/JStartPaymentOptions.hpp @@ -17,6 +17,7 @@ #include "CNLabeledPostalAddress.hpp" #include "CNPhoneNumber.hpp" #include "CNPostalAddress.hpp" +#include "GooglePayAssuranceDetails.hpp" #include "JCNContact.hpp" #include "JCNContactType.hpp" #include "JCNLabeledEmailAddress.hpp" @@ -29,6 +30,7 @@ #include "JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_PaymentSheetUpdate_____PaymentSheetCard_PaymentSheetSelection.hpp" #include "JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_PaymentSheetUpdate_____ShippingMethod_PaymentSheetSelection.hpp" #include "JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_PaymentSheetUpdate_____std__string_PaymentSheetSelection.hpp" +#include "JGooglePayAssuranceDetails.hpp" #include "JPKSecureElementPass.hpp" #include "JPassActivationState.hpp" #include "JPaymentAmount.hpp" diff --git a/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayAssuranceDetails.kt b/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayAssuranceDetails.kt new file mode 100644 index 0000000..13ea2ab --- /dev/null +++ b/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayAssuranceDetails.kt @@ -0,0 +1,56 @@ +/// +/// GooglePayAssuranceDetails.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.pay + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip +import java.util.Objects + + +/** + * Represents the JavaScript object/struct "GooglePayAssuranceDetails". + */ +@DoNotStrip +@Keep +data class GooglePayAssuranceDetails( + @DoNotStrip + @Keep + val accountVerified: Boolean, + @DoNotStrip + @Keep + val cardHolderAuthenticated: Boolean +) { + /* primary constructor */ + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is GooglePayAssuranceDetails) return false + return Objects.deepEquals(this.accountVerified, other.accountVerified) + && Objects.deepEquals(this.cardHolderAuthenticated, other.cardHolderAuthenticated) + } + + override fun hashCode(): Int { + return arrayOf( + accountVerified, + cardHolderAuthenticated + ).contentDeepHashCode() + } + + companion object { + /** + * Constructor called from C++ + */ + @DoNotStrip + @Keep + @Suppress("unused") + @JvmStatic + private fun fromCpp(accountVerified: Boolean, cardHolderAuthenticated: Boolean): GooglePayAssuranceDetails { + return GooglePayAssuranceDetails(accountVerified, cardHolderAuthenticated) + } + } +} diff --git a/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentMethod.kt b/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentMethod.kt index 694827b..999a92c 100644 --- a/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentMethod.kt +++ b/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentMethod.kt @@ -32,7 +32,10 @@ data class PaymentMethod( val secureElementPass: PKSecureElementPass?, @DoNotStrip @Keep - val billingAddress: CNContact? + val billingAddress: CNContact?, + @DoNotStrip + @Keep + val assuranceDetails: GooglePayAssuranceDetails? ) { /* primary constructor */ @@ -44,6 +47,7 @@ data class PaymentMethod( && Objects.deepEquals(this.type, other.type) && Objects.deepEquals(this.secureElementPass, other.secureElementPass) && Objects.deepEquals(this.billingAddress, other.billingAddress) + && Objects.deepEquals(this.assuranceDetails, other.assuranceDetails) } override fun hashCode(): Int { @@ -52,7 +56,8 @@ data class PaymentMethod( network, type, secureElementPass, - billingAddress + billingAddress, + assuranceDetails ).contentDeepHashCode() } @@ -64,8 +69,8 @@ data class PaymentMethod( @Keep @Suppress("unused") @JvmStatic - private fun fromCpp(displayName: String?, network: PaymentNetwork?, type: PaymentMethodType, secureElementPass: PKSecureElementPass?, billingAddress: CNContact?): PaymentMethod { - return PaymentMethod(displayName, network, type, secureElementPass, billingAddress) + private fun fromCpp(displayName: String?, network: PaymentNetwork?, type: PaymentMethodType, secureElementPass: PKSecureElementPass?, billingAddress: CNContact?, assuranceDetails: GooglePayAssuranceDetails?): PaymentMethod { + return PaymentMethod(displayName, network, type, secureElementPass, billingAddress, assuranceDetails) } } } diff --git a/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentRequest.kt b/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentRequest.kt index 42c1790..df26b8e 100644 --- a/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentRequest.kt +++ b/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentRequest.kt @@ -104,6 +104,9 @@ data class PaymentRequest( val googlePayAllowPrepaidCards: Boolean?, @DoNotStrip @Keep + val googlePayAssuranceDetailsRequired: Boolean?, + @DoNotStrip + @Keep val googlePayCheckoutOption: GooglePayCheckoutOption? ) { /* primary constructor */ @@ -139,6 +142,7 @@ data class PaymentRequest( && Objects.deepEquals(this.googlePayTokenization, other.googlePayTokenization) && Objects.deepEquals(this.googlePayAllowedAuthMethods, other.googlePayAllowedAuthMethods) && Objects.deepEquals(this.googlePayAllowPrepaidCards, other.googlePayAllowPrepaidCards) + && Objects.deepEquals(this.googlePayAssuranceDetailsRequired, other.googlePayAssuranceDetailsRequired) && Objects.deepEquals(this.googlePayCheckoutOption, other.googlePayCheckoutOption) } @@ -172,6 +176,7 @@ data class PaymentRequest( googlePayTokenization, googlePayAllowedAuthMethods, googlePayAllowPrepaidCards, + googlePayAssuranceDetailsRequired, googlePayCheckoutOption ).contentDeepHashCode() } @@ -184,8 +189,8 @@ data class PaymentRequest( @Keep @Suppress("unused") @JvmStatic - private fun fromCpp(applePayMerchantIdentifier: String?, merchantName: String?, totalLabel: String?, countryCode: String, currencyCode: String, paymentItems: Array, merchantCapabilities: Array, supportedNetworks: Array, shippingType: String?, shippingMethods: Array?, billingContactRequired: Boolean?, shippingContactRequired: Boolean?, emailRequired: Boolean?, phoneNumberRequired: Boolean?, recurring: RecurringPaymentRequest?, deferred: DeferredPaymentRequest?, automaticReload: AutomaticReloadPaymentRequest?, applePayMultiTokenContexts: Array?, couponCode: String?, applePayMerchantCategoryCode: Double?, applePayLaterAvailability: String?, googlePayMerchantId: String?, googlePayEnvironment: GooglePayEnvironment?, googlePayGateway: String?, googlePayGatewayMerchantId: String?, googlePayTokenization: GooglePayTokenization?, googlePayAllowedAuthMethods: Array?, googlePayAllowPrepaidCards: Boolean?, googlePayCheckoutOption: GooglePayCheckoutOption?): PaymentRequest { - return PaymentRequest(applePayMerchantIdentifier, merchantName, totalLabel, countryCode, currencyCode, paymentItems, merchantCapabilities, supportedNetworks, shippingType, shippingMethods, billingContactRequired, shippingContactRequired, emailRequired, phoneNumberRequired, recurring, deferred, automaticReload, applePayMultiTokenContexts, couponCode, applePayMerchantCategoryCode, applePayLaterAvailability, googlePayMerchantId, googlePayEnvironment, googlePayGateway, googlePayGatewayMerchantId, googlePayTokenization, googlePayAllowedAuthMethods, googlePayAllowPrepaidCards, googlePayCheckoutOption) + private fun fromCpp(applePayMerchantIdentifier: String?, merchantName: String?, totalLabel: String?, countryCode: String, currencyCode: String, paymentItems: Array, merchantCapabilities: Array, supportedNetworks: Array, shippingType: String?, shippingMethods: Array?, billingContactRequired: Boolean?, shippingContactRequired: Boolean?, emailRequired: Boolean?, phoneNumberRequired: Boolean?, recurring: RecurringPaymentRequest?, deferred: DeferredPaymentRequest?, automaticReload: AutomaticReloadPaymentRequest?, applePayMultiTokenContexts: Array?, couponCode: String?, applePayMerchantCategoryCode: Double?, applePayLaterAvailability: String?, googlePayMerchantId: String?, googlePayEnvironment: GooglePayEnvironment?, googlePayGateway: String?, googlePayGatewayMerchantId: String?, googlePayTokenization: GooglePayTokenization?, googlePayAllowedAuthMethods: Array?, googlePayAllowPrepaidCards: Boolean?, googlePayAssuranceDetailsRequired: Boolean?, googlePayCheckoutOption: GooglePayCheckoutOption?): PaymentRequest { + return PaymentRequest(applePayMerchantIdentifier, merchantName, totalLabel, countryCode, currencyCode, paymentItems, merchantCapabilities, supportedNetworks, shippingType, shippingMethods, billingContactRequired, shippingContactRequired, emailRequired, phoneNumberRequired, recurring, deferred, automaticReload, applePayMultiTokenContexts, couponCode, applePayMerchantCategoryCode, applePayLaterAvailability, googlePayMerchantId, googlePayEnvironment, googlePayGateway, googlePayGatewayMerchantId, googlePayTokenization, googlePayAllowedAuthMethods, googlePayAllowPrepaidCards, googlePayAssuranceDetailsRequired, googlePayCheckoutOption) } } } diff --git a/package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Bridge.hpp b/package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Bridge.hpp index 2e82bf6..e94da0e 100644 --- a/package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Bridge.hpp +++ b/package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Bridge.hpp @@ -32,6 +32,8 @@ namespace margelo::nitro::pay { struct DeferredBillingItem; } namespace margelo::nitro::pay { struct DeferredPaymentRequest; } // Forward declaration of `FreeCancellation` to properly resolve imports. namespace margelo::nitro::pay { struct FreeCancellation; } +// Forward declaration of `GooglePayAssuranceDetails` to properly resolve imports. +namespace margelo::nitro::pay { struct GooglePayAssuranceDetails; } // Forward declaration of `GooglePayCheckoutOption` to properly resolve imports. namespace margelo::nitro::pay { enum class GooglePayCheckoutOption; } // Forward declaration of `GooglePayEnvironment` to properly resolve imports. @@ -124,6 +126,7 @@ namespace NitroPay { class HybridPaymentHandlerSpec_cxx; } #include "DeferredBillingItem.hpp" #include "DeferredPaymentRequest.hpp" #include "FreeCancellation.hpp" +#include "GooglePayAssuranceDetails.hpp" #include "GooglePayCheckoutOption.hpp" #include "GooglePayEnvironment.hpp" #include "GooglePayTokenization.hpp" @@ -477,6 +480,21 @@ namespace margelo::nitro::pay::bridge::swift { return optional.value(); } + // pragma MARK: std::optional + /** + * Specialized version of `std::optional`. + */ + using std__optional_GooglePayAssuranceDetails_ = std::optional; + inline std::optional create_std__optional_GooglePayAssuranceDetails_(const GooglePayAssuranceDetails& value) noexcept { + return std::optional(value); + } + inline bool has_value_std__optional_GooglePayAssuranceDetails_(const std::optional& optional) noexcept { + return optional.has_value(); + } + inline GooglePayAssuranceDetails get_std__optional_GooglePayAssuranceDetails_(const std::optional& optional) noexcept { + return optional.value(); + } + // pragma MARK: std::optional /** * Specialized version of `std::optional`. diff --git a/package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Umbrella.hpp b/package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Umbrella.hpp index 4829db1..a4cd95d 100644 --- a/package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Umbrella.hpp +++ b/package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Umbrella.hpp @@ -36,6 +36,8 @@ namespace margelo::nitro::pay { struct DeferredBillingItem; } namespace margelo::nitro::pay { struct DeferredPaymentRequest; } // Forward declaration of `FreeCancellation` to properly resolve imports. namespace margelo::nitro::pay { struct FreeCancellation; } +// Forward declaration of `GooglePayAssuranceDetails` to properly resolve imports. +namespace margelo::nitro::pay { struct GooglePayAssuranceDetails; } // Forward declaration of `GooglePayCheckoutOption` to properly resolve imports. namespace margelo::nitro::pay { enum class GooglePayCheckoutOption; } // Forward declaration of `GooglePayEnvironment` to properly resolve imports. @@ -126,6 +128,7 @@ namespace margelo::nitro::pay { struct StartPaymentOptions; } #include "DeferredBillingItem.hpp" #include "DeferredPaymentRequest.hpp" #include "FreeCancellation.hpp" +#include "GooglePayAssuranceDetails.hpp" #include "GooglePayCheckoutOption.hpp" #include "GooglePayEnvironment.hpp" #include "GooglePayTokenization.hpp" diff --git a/package/nitrogen/generated/ios/c++/HybridPaymentHandlerSpecSwift.hpp b/package/nitrogen/generated/ios/c++/HybridPaymentHandlerSpecSwift.hpp index c471107..a04db5f 100644 --- a/package/nitrogen/generated/ios/c++/HybridPaymentHandlerSpecSwift.hpp +++ b/package/nitrogen/generated/ios/c++/HybridPaymentHandlerSpecSwift.hpp @@ -50,6 +50,8 @@ namespace margelo::nitro::pay { struct CNLabeledEmailAddress; } namespace margelo::nitro::pay { struct CNLabeledPostalAddress; } // Forward declaration of `CNPostalAddress` to properly resolve imports. namespace margelo::nitro::pay { struct CNPostalAddress; } +// Forward declaration of `GooglePayAssuranceDetails` to properly resolve imports. +namespace margelo::nitro::pay { struct GooglePayAssuranceDetails; } // Forward declaration of `PaymentContact` to properly resolve imports. namespace margelo::nitro::pay { struct PaymentContact; } // Forward declaration of `ShippingMethod` to properly resolve imports. @@ -130,6 +132,7 @@ namespace margelo::nitro::pay { struct PaymentSheetCard; } #include "CNLabeledEmailAddress.hpp" #include "CNLabeledPostalAddress.hpp" #include "CNPostalAddress.hpp" +#include "GooglePayAssuranceDetails.hpp" #include "PaymentContact.hpp" #include "ShippingMethod.hpp" #include diff --git a/package/nitrogen/generated/ios/swift/GooglePayAssuranceDetails.swift b/package/nitrogen/generated/ios/swift/GooglePayAssuranceDetails.swift new file mode 100644 index 0000000..331327a --- /dev/null +++ b/package/nitrogen/generated/ios/swift/GooglePayAssuranceDetails.swift @@ -0,0 +1,34 @@ +/// +/// GooglePayAssuranceDetails.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Represents an instance of `GooglePayAssuranceDetails`, backed by a C++ struct. + */ +public typealias GooglePayAssuranceDetails = margelo.nitro.pay.GooglePayAssuranceDetails + +public extension GooglePayAssuranceDetails { + private typealias bridge = margelo.nitro.pay.bridge.swift + + /** + * Create a new instance of `GooglePayAssuranceDetails`. + */ + init(accountVerified: Bool, cardHolderAuthenticated: Bool) { + self.init(accountVerified, cardHolderAuthenticated) + } + + @inline(__always) + var accountVerified: Bool { + return self.__accountVerified + } + + @inline(__always) + var cardHolderAuthenticated: Bool { + return self.__cardHolderAuthenticated + } +} diff --git a/package/nitrogen/generated/ios/swift/PaymentMethod.swift b/package/nitrogen/generated/ios/swift/PaymentMethod.swift index 2191b22..c9dad03 100644 --- a/package/nitrogen/generated/ios/swift/PaymentMethod.swift +++ b/package/nitrogen/generated/ios/swift/PaymentMethod.swift @@ -18,7 +18,7 @@ public extension PaymentMethod { /** * Create a new instance of `PaymentMethod`. */ - init(displayName: String?, network: PaymentNetwork?, type: PaymentMethodType, secureElementPass: PKSecureElementPass?, billingAddress: CNContact?) { + init(displayName: String?, network: PaymentNetwork?, type: PaymentMethodType, secureElementPass: PKSecureElementPass?, billingAddress: CNContact?, assuranceDetails: GooglePayAssuranceDetails?) { self.init({ () -> bridge.std__optional_std__string_ in if let __unwrappedValue = displayName { return bridge.create_std__optional_std__string_(std.string(__unwrappedValue)) @@ -43,6 +43,12 @@ public extension PaymentMethod { } else { return .init() } + }(), { () -> bridge.std__optional_GooglePayAssuranceDetails_ in + if let __unwrappedValue = assuranceDetails { + return bridge.create_std__optional_GooglePayAssuranceDetails_(__unwrappedValue) + } else { + return .init() + } }()) } @@ -77,4 +83,9 @@ public extension PaymentMethod { var billingAddress: CNContact? { return self.__billingAddress.value } + + @inline(__always) + var assuranceDetails: GooglePayAssuranceDetails? { + return self.__assuranceDetails.value + } } diff --git a/package/nitrogen/generated/ios/swift/PaymentRequest.swift b/package/nitrogen/generated/ios/swift/PaymentRequest.swift index 74dafbd..9511910 100644 --- a/package/nitrogen/generated/ios/swift/PaymentRequest.swift +++ b/package/nitrogen/generated/ios/swift/PaymentRequest.swift @@ -18,7 +18,7 @@ public extension PaymentRequest { /** * Create a new instance of `PaymentRequest`. */ - init(applePayMerchantIdentifier: String?, merchantName: String?, totalLabel: String?, countryCode: String, currencyCode: String, paymentItems: [PaymentItem], merchantCapabilities: [String], supportedNetworks: [String], shippingType: String?, shippingMethods: [ShippingMethod]?, billingContactRequired: Bool?, shippingContactRequired: Bool?, emailRequired: Bool?, phoneNumberRequired: Bool?, recurring: RecurringPaymentRequest?, deferred: DeferredPaymentRequest?, automaticReload: AutomaticReloadPaymentRequest?, applePayMultiTokenContexts: [PaymentTokenContext]?, couponCode: String?, applePayMerchantCategoryCode: Double?, applePayLaterAvailability: String?, googlePayMerchantId: String?, googlePayEnvironment: GooglePayEnvironment?, googlePayGateway: String?, googlePayGatewayMerchantId: String?, googlePayTokenization: GooglePayTokenization?, googlePayAllowedAuthMethods: [String]?, googlePayAllowPrepaidCards: Bool?, googlePayCheckoutOption: GooglePayCheckoutOption?) { + init(applePayMerchantIdentifier: String?, merchantName: String?, totalLabel: String?, countryCode: String, currencyCode: String, paymentItems: [PaymentItem], merchantCapabilities: [String], supportedNetworks: [String], shippingType: String?, shippingMethods: [ShippingMethod]?, billingContactRequired: Bool?, shippingContactRequired: Bool?, emailRequired: Bool?, phoneNumberRequired: Bool?, recurring: RecurringPaymentRequest?, deferred: DeferredPaymentRequest?, automaticReload: AutomaticReloadPaymentRequest?, applePayMultiTokenContexts: [PaymentTokenContext]?, couponCode: String?, applePayMerchantCategoryCode: Double?, applePayLaterAvailability: String?, googlePayMerchantId: String?, googlePayEnvironment: GooglePayEnvironment?, googlePayGateway: String?, googlePayGatewayMerchantId: String?, googlePayTokenization: GooglePayTokenization?, googlePayAllowedAuthMethods: [String]?, googlePayAllowPrepaidCards: Bool?, googlePayAssuranceDetailsRequired: Bool?, googlePayCheckoutOption: GooglePayCheckoutOption?) { self.init({ () -> bridge.std__optional_std__string_ in if let __unwrappedValue = applePayMerchantIdentifier { return bridge.create_std__optional_std__string_(std.string(__unwrappedValue)) @@ -193,6 +193,12 @@ public extension PaymentRequest { } else { return .init() } + }(), { () -> bridge.std__optional_bool_ in + if let __unwrappedValue = googlePayAssuranceDetailsRequired { + return bridge.create_std__optional_bool_(__unwrappedValue) + } else { + return .init() + } }(), { () -> bridge.std__optional_GooglePayCheckoutOption_ in if let __unwrappedValue = googlePayCheckoutOption { return bridge.create_std__optional_GooglePayCheckoutOption_(__unwrappedValue) @@ -468,6 +474,18 @@ public extension PaymentRequest { }() } + @inline(__always) + var googlePayAssuranceDetailsRequired: Bool? { + return { () -> Bool? in + if bridge.has_value_std__optional_bool_(self.__googlePayAssuranceDetailsRequired) { + let __unwrapped = bridge.get_std__optional_bool_(self.__googlePayAssuranceDetailsRequired) + return __unwrapped + } else { + return nil + } + }() + } + @inline(__always) var googlePayCheckoutOption: GooglePayCheckoutOption? { return self.__googlePayCheckoutOption.value diff --git a/package/nitrogen/generated/shared/c++/GooglePayAssuranceDetails.hpp b/package/nitrogen/generated/shared/c++/GooglePayAssuranceDetails.hpp new file mode 100644 index 0000000..6c823ed --- /dev/null +++ b/package/nitrogen/generated/shared/c++/GooglePayAssuranceDetails.hpp @@ -0,0 +1,87 @@ +/// +/// GooglePayAssuranceDetails.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + + + +namespace margelo::nitro::pay { + + /** + * A struct which can be represented as a JavaScript object (GooglePayAssuranceDetails). + */ + struct GooglePayAssuranceDetails final { + public: + bool accountVerified SWIFT_PRIVATE; + bool cardHolderAuthenticated SWIFT_PRIVATE; + + public: + GooglePayAssuranceDetails() = default; + explicit GooglePayAssuranceDetails(bool accountVerified, bool cardHolderAuthenticated): accountVerified(accountVerified), cardHolderAuthenticated(cardHolderAuthenticated) {} + + public: + friend bool operator==(const GooglePayAssuranceDetails& lhs, const GooglePayAssuranceDetails& rhs) = default; + }; + +} // namespace margelo::nitro::pay + +namespace margelo::nitro { + + // C++ GooglePayAssuranceDetails <> JS GooglePayAssuranceDetails (object) + template <> + struct JSIConverter final { + static inline margelo::nitro::pay::GooglePayAssuranceDetails fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return margelo::nitro::pay::GooglePayAssuranceDetails( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accountVerified"))), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cardHolderAuthenticated"))) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::pay::GooglePayAssuranceDetails& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "accountVerified"), JSIConverter::toJSI(runtime, arg.accountVerified)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "cardHolderAuthenticated"), JSIConverter::toJSI(runtime, arg.cardHolderAuthenticated)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!nitro::isPlainObject(runtime, obj)) { + return false; + } + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accountVerified")))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cardHolderAuthenticated")))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/package/nitrogen/generated/shared/c++/PaymentMethod.hpp b/package/nitrogen/generated/shared/c++/PaymentMethod.hpp index cbdbbb6..86bc1c6 100644 --- a/package/nitrogen/generated/shared/c++/PaymentMethod.hpp +++ b/package/nitrogen/generated/shared/c++/PaymentMethod.hpp @@ -36,6 +36,8 @@ namespace margelo::nitro::pay { enum class PaymentMethodType; } namespace margelo::nitro::pay { struct PKSecureElementPass; } // Forward declaration of `CNContact` to properly resolve imports. namespace margelo::nitro::pay { struct CNContact; } +// Forward declaration of `GooglePayAssuranceDetails` to properly resolve imports. +namespace margelo::nitro::pay { struct GooglePayAssuranceDetails; } #include #include @@ -43,6 +45,7 @@ namespace margelo::nitro::pay { struct CNContact; } #include "PaymentMethodType.hpp" #include "PKSecureElementPass.hpp" #include "CNContact.hpp" +#include "GooglePayAssuranceDetails.hpp" namespace margelo::nitro::pay { @@ -56,10 +59,11 @@ namespace margelo::nitro::pay { PaymentMethodType type SWIFT_PRIVATE; std::optional secureElementPass SWIFT_PRIVATE; std::optional billingAddress SWIFT_PRIVATE; + std::optional assuranceDetails SWIFT_PRIVATE; public: PaymentMethod() = default; - explicit PaymentMethod(std::optional displayName, std::optional network, PaymentMethodType type, std::optional secureElementPass, std::optional billingAddress): displayName(displayName), network(network), type(type), secureElementPass(secureElementPass), billingAddress(billingAddress) {} + explicit PaymentMethod(std::optional displayName, std::optional network, PaymentMethodType type, std::optional secureElementPass, std::optional billingAddress, std::optional assuranceDetails): displayName(displayName), network(network), type(type), secureElementPass(secureElementPass), billingAddress(billingAddress), assuranceDetails(assuranceDetails) {} public: friend bool operator==(const PaymentMethod& lhs, const PaymentMethod& rhs) = default; @@ -79,7 +83,8 @@ namespace margelo::nitro { JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "network"))), JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "secureElementPass"))), - JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "billingAddress"))) + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "billingAddress"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "assuranceDetails"))) ); } static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::pay::PaymentMethod& arg) { @@ -89,6 +94,7 @@ namespace margelo::nitro { obj.setProperty(runtime, PropNameIDCache::get(runtime, "type"), JSIConverter::toJSI(runtime, arg.type)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "secureElementPass"), JSIConverter>::toJSI(runtime, arg.secureElementPass)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "billingAddress"), JSIConverter>::toJSI(runtime, arg.billingAddress)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "assuranceDetails"), JSIConverter>::toJSI(runtime, arg.assuranceDetails)); return obj; } static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { @@ -104,6 +110,7 @@ namespace margelo::nitro { if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "secureElementPass")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "billingAddress")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "assuranceDetails")))) return false; return true; } }; diff --git a/package/nitrogen/generated/shared/c++/PaymentRequest.hpp b/package/nitrogen/generated/shared/c++/PaymentRequest.hpp index 7b0e4e3..bf8e8f9 100644 --- a/package/nitrogen/generated/shared/c++/PaymentRequest.hpp +++ b/package/nitrogen/generated/shared/c++/PaymentRequest.hpp @@ -95,11 +95,12 @@ namespace margelo::nitro::pay { std::optional googlePayTokenization SWIFT_PRIVATE; std::optional> googlePayAllowedAuthMethods SWIFT_PRIVATE; std::optional googlePayAllowPrepaidCards SWIFT_PRIVATE; + std::optional googlePayAssuranceDetailsRequired SWIFT_PRIVATE; std::optional googlePayCheckoutOption SWIFT_PRIVATE; public: PaymentRequest() = default; - explicit PaymentRequest(std::optional applePayMerchantIdentifier, std::optional merchantName, std::optional totalLabel, std::string countryCode, std::string currencyCode, std::vector paymentItems, std::vector merchantCapabilities, std::vector supportedNetworks, std::optional shippingType, std::optional> shippingMethods, std::optional billingContactRequired, std::optional shippingContactRequired, std::optional emailRequired, std::optional phoneNumberRequired, std::optional recurring, std::optional deferred, std::optional automaticReload, std::optional> applePayMultiTokenContexts, std::optional couponCode, std::optional applePayMerchantCategoryCode, std::optional applePayLaterAvailability, std::optional googlePayMerchantId, std::optional googlePayEnvironment, std::optional googlePayGateway, std::optional googlePayGatewayMerchantId, std::optional googlePayTokenization, std::optional> googlePayAllowedAuthMethods, std::optional googlePayAllowPrepaidCards, std::optional googlePayCheckoutOption): applePayMerchantIdentifier(applePayMerchantIdentifier), merchantName(merchantName), totalLabel(totalLabel), countryCode(countryCode), currencyCode(currencyCode), paymentItems(paymentItems), merchantCapabilities(merchantCapabilities), supportedNetworks(supportedNetworks), shippingType(shippingType), shippingMethods(shippingMethods), billingContactRequired(billingContactRequired), shippingContactRequired(shippingContactRequired), emailRequired(emailRequired), phoneNumberRequired(phoneNumberRequired), recurring(recurring), deferred(deferred), automaticReload(automaticReload), applePayMultiTokenContexts(applePayMultiTokenContexts), couponCode(couponCode), applePayMerchantCategoryCode(applePayMerchantCategoryCode), applePayLaterAvailability(applePayLaterAvailability), googlePayMerchantId(googlePayMerchantId), googlePayEnvironment(googlePayEnvironment), googlePayGateway(googlePayGateway), googlePayGatewayMerchantId(googlePayGatewayMerchantId), googlePayTokenization(googlePayTokenization), googlePayAllowedAuthMethods(googlePayAllowedAuthMethods), googlePayAllowPrepaidCards(googlePayAllowPrepaidCards), googlePayCheckoutOption(googlePayCheckoutOption) {} + explicit PaymentRequest(std::optional applePayMerchantIdentifier, std::optional merchantName, std::optional totalLabel, std::string countryCode, std::string currencyCode, std::vector paymentItems, std::vector merchantCapabilities, std::vector supportedNetworks, std::optional shippingType, std::optional> shippingMethods, std::optional billingContactRequired, std::optional shippingContactRequired, std::optional emailRequired, std::optional phoneNumberRequired, std::optional recurring, std::optional deferred, std::optional automaticReload, std::optional> applePayMultiTokenContexts, std::optional couponCode, std::optional applePayMerchantCategoryCode, std::optional applePayLaterAvailability, std::optional googlePayMerchantId, std::optional googlePayEnvironment, std::optional googlePayGateway, std::optional googlePayGatewayMerchantId, std::optional googlePayTokenization, std::optional> googlePayAllowedAuthMethods, std::optional googlePayAllowPrepaidCards, std::optional googlePayAssuranceDetailsRequired, std::optional googlePayCheckoutOption): applePayMerchantIdentifier(applePayMerchantIdentifier), merchantName(merchantName), totalLabel(totalLabel), countryCode(countryCode), currencyCode(currencyCode), paymentItems(paymentItems), merchantCapabilities(merchantCapabilities), supportedNetworks(supportedNetworks), shippingType(shippingType), shippingMethods(shippingMethods), billingContactRequired(billingContactRequired), shippingContactRequired(shippingContactRequired), emailRequired(emailRequired), phoneNumberRequired(phoneNumberRequired), recurring(recurring), deferred(deferred), automaticReload(automaticReload), applePayMultiTokenContexts(applePayMultiTokenContexts), couponCode(couponCode), applePayMerchantCategoryCode(applePayMerchantCategoryCode), applePayLaterAvailability(applePayLaterAvailability), googlePayMerchantId(googlePayMerchantId), googlePayEnvironment(googlePayEnvironment), googlePayGateway(googlePayGateway), googlePayGatewayMerchantId(googlePayGatewayMerchantId), googlePayTokenization(googlePayTokenization), googlePayAllowedAuthMethods(googlePayAllowedAuthMethods), googlePayAllowPrepaidCards(googlePayAllowPrepaidCards), googlePayAssuranceDetailsRequired(googlePayAssuranceDetailsRequired), googlePayCheckoutOption(googlePayCheckoutOption) {} public: friend bool operator==(const PaymentRequest& lhs, const PaymentRequest& rhs) = default; @@ -143,6 +144,7 @@ namespace margelo::nitro { JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "googlePayTokenization"))), JSIConverter>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "googlePayAllowedAuthMethods"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "googlePayAllowPrepaidCards"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "googlePayAssuranceDetailsRequired"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "googlePayCheckoutOption"))) ); } @@ -176,6 +178,7 @@ namespace margelo::nitro { obj.setProperty(runtime, PropNameIDCache::get(runtime, "googlePayTokenization"), JSIConverter>::toJSI(runtime, arg.googlePayTokenization)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "googlePayAllowedAuthMethods"), JSIConverter>>::toJSI(runtime, arg.googlePayAllowedAuthMethods)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "googlePayAllowPrepaidCards"), JSIConverter>::toJSI(runtime, arg.googlePayAllowPrepaidCards)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "googlePayAssuranceDetailsRequired"), JSIConverter>::toJSI(runtime, arg.googlePayAssuranceDetailsRequired)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "googlePayCheckoutOption"), JSIConverter>::toJSI(runtime, arg.googlePayCheckoutOption)); return obj; } @@ -215,6 +218,7 @@ namespace margelo::nitro { if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "googlePayTokenization")))) return false; if (!JSIConverter>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "googlePayAllowedAuthMethods")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "googlePayAllowPrepaidCards")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "googlePayAssuranceDetailsRequired")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "googlePayCheckoutOption")))) return false; return true; } diff --git a/package/src/hooks/__tests__/usePaymentCheckout.integration.test.ts b/package/src/hooks/__tests__/usePaymentCheckout.integration.test.ts index 5fb3201..eba24a4 100644 --- a/package/src/hooks/__tests__/usePaymentCheckout.integration.test.ts +++ b/package/src/hooks/__tests__/usePaymentCheckout.integration.test.ts @@ -651,6 +651,7 @@ describe('usePaymentCheckout integration', () => { ['CRYPTOGRAM_3DS'], ], googlePayAllowPrepaidCards: [true, false], + googlePayAssuranceDetailsRequired: [false, true], googlePayCheckoutOption: ['default', 'completeImmediatePurchase'], billingContactRequired: [false, true], shippingContactRequired: [false, true], diff --git a/package/src/hooks/usePaymentCheckout.ts b/package/src/hooks/usePaymentCheckout.ts index 01c7155..304b96d 100644 --- a/package/src/hooks/usePaymentCheckout.ts +++ b/package/src/hooks/usePaymentCheckout.ts @@ -180,6 +180,13 @@ export interface UsePaymentCheckoutConfig */ googlePayAllowPrepaidCards?: boolean + /** + * `true` asks Google Pay whether it verified the card and authenticated + * the cardholder, returned as `token.paymentMethod.assuranceDetails`, for + * example to skip a 3-D Secure step-up. Defaults to `false`. Android only. + */ + googlePayAssuranceDetailsRequired?: boolean + /** * The label of the Google Pay sheet's button: `'default'` ("Continue" or * "Pay"), `'completeImmediatePurchase'` ("Pay now") or @@ -439,6 +446,7 @@ export function usePaymentCheckout( googlePayTokenization, googlePayAllowedAuthMethods, googlePayAllowPrepaidCards, + googlePayAssuranceDetailsRequired, googlePayCheckoutOption, billingContactRequired, shippingContactRequired, @@ -464,6 +472,7 @@ export function usePaymentCheckout( googlePayTokenization, googlePayAllowedAuthMethods, googlePayAllowPrepaidCards, + googlePayAssuranceDetailsRequired, googlePayCheckoutOption, billingContactRequired, shippingContactRequired, diff --git a/package/src/types/Payment.ts b/package/src/types/Payment.ts index 2cc9be5..2b9b9ec 100644 --- a/package/src/types/Payment.ts +++ b/package/src/types/Payment.ts @@ -217,6 +217,20 @@ export interface ShippingMethod { detail?: string } +/** + * What Google checked about the card the payer picked. Requested with + * `PaymentRequest.googlePayAssuranceDetailsRequired`. Android only. + */ +export interface GooglePayAssuranceDetails { + /** Google validated that the payer possesses the card. */ + accountVerified: boolean + /** + * Google authenticated the cardholder (identification and verification). + * `false` leaves it to your usual risk checks, such as 3-D Secure. + */ + cardHolderAuthenticated: boolean +} + export interface PaymentMethod { /** * Describes the card to the payer, for example `'Visa 1234'`. Comes from @@ -228,6 +242,11 @@ export interface PaymentMethod { type: PaymentMethodType secureElementPass?: PKSecureElementPass // Available from iOS 13.4+ billingAddress?: CNContact // Available from iOS 13.0+ + /** + * Set when `PaymentRequest.googlePayAssuranceDetailsRequired` asked for it + * and Google Pay returned it. Android only. + */ + assuranceDetails?: GooglePayAssuranceDetails } export interface PaymentToken { @@ -517,6 +536,12 @@ export interface PaymentRequest { * to `true`. Android only; Apple Pay has no such option. */ googlePayAllowPrepaidCards?: boolean + /** + * `true` asks Google Pay whether it verified the card and authenticated + * the cardholder, returned as `token.paymentMethod.assuranceDetails`. + * Defaults to `false`. Android only. + */ + googlePayAssuranceDetailsRequired?: boolean /** * The label of the Google Pay sheet's button. Omitted, Google Pay picks * "Continue" or "Pay", as with `'default'`. `'completeImmediatePurchase'`