feat: Added missing info to IAP transaction and product structures (#31739)
This commit is contained in:
parent
d26d337bb8
commit
2fe5d0e1e8
11 changed files with 323 additions and 6 deletions
|
@ -15,6 +15,22 @@
|
|||
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<in_app_purchase::PaymentDiscount> {
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const in_app_purchase::PaymentDiscount& paymentDiscount) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("identifier", paymentDiscount.identifier);
|
||||
dict.Set("keyIdentifier", paymentDiscount.keyIdentifier);
|
||||
dict.Set("nonce", paymentDiscount.nonce);
|
||||
dict.Set("signature", paymentDiscount.signature);
|
||||
dict.Set("timestamp", paymentDiscount.timestamp);
|
||||
return dict.GetHandle();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<in_app_purchase::Payment> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
|
@ -23,6 +39,10 @@ struct Converter<in_app_purchase::Payment> {
|
|||
dict.SetHidden("simple", true);
|
||||
dict.Set("productIdentifier", payment.productIdentifier);
|
||||
dict.Set("quantity", payment.quantity);
|
||||
dict.Set("applicationUsername", payment.applicationUsername);
|
||||
if (payment.paymentDiscount.has_value()) {
|
||||
dict.Set("paymentDiscount", payment.paymentDiscount.value());
|
||||
}
|
||||
return dict.GetHandle();
|
||||
}
|
||||
};
|
||||
|
@ -45,6 +65,41 @@ struct Converter<in_app_purchase::Transaction> {
|
|||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<in_app_purchase::ProductSubscriptionPeriod> {
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const in_app_purchase::ProductSubscriptionPeriod&
|
||||
productSubscriptionPeriod) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("numberOfUnits", productSubscriptionPeriod.numberOfUnits);
|
||||
dict.Set("unit", productSubscriptionPeriod.unit);
|
||||
return dict.GetHandle();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<in_app_purchase::ProductDiscount> {
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const in_app_purchase::ProductDiscount& productDiscount) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("identifier", productDiscount.identifier);
|
||||
dict.Set("type", productDiscount.type);
|
||||
dict.Set("price", productDiscount.price);
|
||||
dict.Set("priceLocale", productDiscount.priceLocale);
|
||||
dict.Set("paymentMode", productDiscount.paymentMode);
|
||||
dict.Set("numberOfPeriods", productDiscount.numberOfPeriods);
|
||||
if (productDiscount.subscriptionPeriod.has_value()) {
|
||||
dict.Set("subscriptionPeriod",
|
||||
productDiscount.subscriptionPeriod.value());
|
||||
}
|
||||
return dict.GetHandle();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<in_app_purchase::Product> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
|
@ -54,18 +109,25 @@ struct Converter<in_app_purchase::Product> {
|
|||
dict.Set("productIdentifier", val.productIdentifier);
|
||||
dict.Set("localizedDescription", val.localizedDescription);
|
||||
dict.Set("localizedTitle", val.localizedTitle);
|
||||
dict.Set("contentVersion", val.localizedTitle);
|
||||
dict.Set("contentVersion", val.contentVersion);
|
||||
dict.Set("contentLengths", val.contentLengths);
|
||||
|
||||
// Pricing Information
|
||||
dict.Set("price", val.price);
|
||||
dict.Set("formattedPrice", val.formattedPrice);
|
||||
|
||||
// Currency Information
|
||||
dict.Set("currencyCode", val.currencyCode);
|
||||
|
||||
if (val.introductoryPrice.has_value()) {
|
||||
dict.Set("introductoryPrice", val.introductoryPrice.value());
|
||||
}
|
||||
dict.Set("discounts", val.discounts);
|
||||
dict.Set("subscriptionGroupIdentifier", val.subscriptionGroupIdentifier);
|
||||
if (val.subscriptionPeriod.has_value()) {
|
||||
dict.Set("subscriptionPeriod", val.subscriptionPeriod.value());
|
||||
}
|
||||
// Downloadable Content Information
|
||||
dict.Set("isDownloadable", val.isDownloadable);
|
||||
dict.Set("downloadContentVersion", val.downloadContentVersion);
|
||||
dict.Set("downloadContentLengths", val.downloadContentLengths);
|
||||
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue