Skip to main content
Solved

Encountering error "Parameter specified as non-null is null" when attempting purchase

  • January 11, 2024
  • 1 reply
  • 232 views

Forum|alt.badge.img+4

Everything is configured correctly on RevenueCat and the app stores, and I’m able to fetch and display my offerings using `Purchases.getOfferings()`.

 

console.log(offerings.current.availablePackages);


LOG  [{"identifier": "pay_black", "offeringIdentifier": "default", "packageType": "CUSTOM", "product": {"currencyCode": "KRW", "defaultOption": null, "description": "Test1", "discounts": null, "identifier": "pay_black", "introPrice": null, "presentedOfferingIdentifier": "default", "price": 10000, "priceString": "₩10,000", "productCategory": "NON_SUBSCRIPTION", "productType": "CONSUMABLE", "subscriptionOptions": null, "subscriptionPeriod": null, "title": "Black"}}, {"identifier": "pay_blue", "offeringIdentifier": "default", "packageType": "CUSTOM", "product": {"currencyCode": "KRW", "defaultOption": null, "description": "Test2", "discounts": null, "identifier": "pay_blue", "introPrice": null, "presentedOfferingIdentifier": "default", "price": 30000, "priceString": "₩30,000", "productCategory": "NON_SUBSCRIPTION", "productType": "CONSUMABLE", "subscriptionOptions": null, "subscriptionPeriod": null, "title": "Blue"}}]

 

However, when I try to execute `Purchases.purchasePackage()`, I encounter the following error: “Parameter specified as non-null is null: method com.revenuecat.purchases.hybridcommon.CommonKt.purchasePackage, parameter packageIdentifier”

 

const { purchaserInfo, productIdentifier } = await Purchases.purchasePackage('pay_black');

 

A similar error occurs when I try to execute `Purchases.purchaseStoreProduct()`. The error suggests that I’m passing `null` as a parameter, but I’m definitely passing the correct identifier as a string.

 

Thanks in advance to anyone who can help me resolve this :)

Best answer by eragon4445

Hi, this is because you shouldn't pass the ID as an argument to the purchasePackage() function, but the entire product. 

If you're using react native, it's best to do it like this: 

const [product, setproduct] = useState('')

setproduct(offerings.current.availablePackages[0].product)

Purchases.purchasePackage(product)

 

Hope this helps!

View original
Did this post help you find an answer to your question?
This post has been closed for comments

1 reply

Forum|alt.badge.img+2
  • Helper
  • 2 replies
  • Answer
  • January 16, 2024

Hi, this is because you shouldn't pass the ID as an argument to the purchasePackage() function, but the entire product. 

If you're using react native, it's best to do it like this: 

const [product, setproduct] = useState('')

setproduct(offerings.current.availablePackages[0].product)

Purchases.purchasePackage(product)

 

Hope this helps!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings