iapiab verifies the purchase receipt via AppStore, GooglePlayStore.
iapiab is inspired by golang implementation for iap and iab
[dependencies]
iapiab = 0.1.0
or you can get latest branch.
[dependencies]
iapiab = { git = "https://github.com/yoshidan/rust-iap/", branch = "main"}
``` use iapiab::appstore::model::IAPRequest; use iapiab::appstore::validator::{IAPClient, IAPVerifier};
async fn main() { let v = IAPRequest { receiptdata: "your receipt data encoded by base64".tostring(), password: None, excludeoldtransactions: false, }; let client = IAPClient::new(reqwest::Client::new()); let res = client.verify(&v).await.unwrap(); println!("{}", res.status); } ```
``` use iapiab::playstore::validator::{IABClient, IABProduct};
async fn main() { let client = IABClient::new( b"your google service account json key", hyper::Client::builder().build(hyperrustls::HttpsConnector::withnativeroots()), ) .await; let res = client .verify("package name", "product id", "purchase token") .await; println!("{}", res.unwrap().acknowledgementstate.unwrap()); } ```
``` use iapiab::playstore::validator::{verify_signature, SignatureError};
async fn main() { // ex) UnityIAP payload is {"json":{"orderId":"GPA.-..",...,"acknowledged":".."},"signature":"XXXXX", ...} let receipt = b"receipt json value"; //{"orderId":"GPA.-..",...,"acknowledged":".."} let pubkey = b"your pub key in play store"; let signature = b"signature value"; let result = verifysignature(pub_key, receipt, signature); } ```
This validator supports the receipt type for iOS7 or above.
This validator uses Version 3 API.
iapiab is licensed under the MIT.