Crates.io | iapiab |
lib.rs | iapiab |
version | 0.1.0 |
source | src |
created_at | 2021-06-10 03:49:52.643902 |
updated_at | 2021-06-10 03:49:52.643902 |
description | iapiab verifies the purchase receipt via AppStore or GooglePlayStore. |
homepage | |
repository | https://github.com/yoshidan/rust-iap |
max_upload_size | |
id | 408453 |
size | 31,756 |
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};
#[tokio::main]
async fn main() {
let v = IAPRequest {
receipt_data: "your receipt data encoded by base64".to_string(),
password: None,
exclude_old_transactions: false,
};
let client = IAPClient::new(reqwest::Client::new());
let res = client.verify(&v).await.unwrap();
println!("{}", res.status);
}
use iapiab::playstore::validator::{IABClient, IABProduct};
#[tokio::main]
async fn main() {
let client = IABClient::new(
b"your google service account json key",
hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()),
)
.await;
let res = client
.verify("package name", "product id", "purchase token")
.await;
println!("{}", res.unwrap().acknowledgement_state.unwrap());
}
use iapiab::playstore::validator::{verify_signature, SignatureError};
#[tokio::main]
async fn main() {
// ex) UnityIAP payload is {"json":{"orderId":"GPA.-..",...,"acknowledged":".."},"signature":"XXXXX", ...}
let receipt = b"receipt json value"; //{"orderId":"GPA.-..",...,"acknowledged":".."}
let pub_key = b"your pub key in play store";
let signature = b"signature value";
let result = verify_signature(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.