Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add metadata field to payment intent #656

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ internal fun mapFromPaymentIntent(paymentIntent: PaymentIntent, uuid: String): R
putString("sdkUuid", uuid)
putString("paymentMethodId", paymentIntent.paymentMethodId)
putMap("offlineDetails", mapFromOfflineDetails(paymentIntent?.offlineDetails))
putMap(
"metadata",
nativeMapOf {
paymentIntent.metadata?.map {
putString(it.key, it.value)
}
}
)
}

internal fun mapFromSetupIntent(setupIntent: SetupIntent, uuid: String): ReadableMap = nativeMapOf {
Expand Down
2 changes: 1 addition & 1 deletion dev-app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.apache.tools.ant.taskdefs.condition.Os

buildscript {
ext {
buildToolsVersion = "33.0.0"
buildToolsVersion = "33.0.1"
minSdkVersion = 26
compileSdkVersion = 34
targetSdkVersion = 33
Expand Down
2 changes: 1 addition & 1 deletion example-app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '33.0.0'
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '33.0.1'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '26')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '33')
Expand Down
9 changes: 7 additions & 2 deletions ios/Mappers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ class Mappers {
if let offlineDetails = paymentIntent.offlineDetails {
offlineDetailsMap = mapFromOfflineDetails(offlineDetails)
}
var metadataMap: NSDictionary?
if let paymentMetadata = paymentIntent.metadata {
metadataMap = NSDictionary(dictionary: paymentMetadata)
}
let result: NSDictionary = [
"amount": paymentIntent.amount,
"charges": mapFromCharges(paymentIntent.charges),
Expand All @@ -153,7 +157,8 @@ class Mappers {
"id": paymentIntent.stripeId,
"sdkUuid": uuid,
"paymentMethodId": paymentIntent.paymentMethodId,
"offlineDetails": offlineDetailsMap ?? NSNull()
"offlineDetails": offlineDetailsMap ?? NSNull(),
"metadata": metadataMap ?? NSNull(),
]
return result
}
Expand Down Expand Up @@ -510,7 +515,7 @@ class Mappers {
default: return "unknown"
}
}

class func mapFromCardPresentDetailsNetwork(_ type: NSNumber) -> String {
switch type {
case 0: return "visa"
Expand Down
1 change: 1 addition & 0 deletions src/types/PaymentIntent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export namespace PaymentIntent {
paymentMethodId: string;
paymentMethod: PaymentMethod.Type;
offlineDetails: OfflineDetails;
metadata: Record<string, string>;
}

export type Status =
Expand Down