Perpustakaan Server Node.js untuk API Server App Store dan Pemberitahuan Server App Store. Juga tersedia dalam Swift, Python, dan Java.
Instalasi
Dokumentasi
Penggunaan
Mendukung
Node 16+
# Dengan npmnpm instal @apple/app-store-server-library --save# dengan yarnyarn tambahkan @apel/app-store-server-library
Dokumentasi
Video WWDC
Untuk menggunakan API Server App Store atau membuat tanda tangan penawaran promosi, diperlukan kunci penandatanganan dari App Store Connect. Untuk mendapatkan kunci ini, Anda harus memiliki peran admin. Pergi ke pengguna dan akses> Integrasi> pembelian dalam aplikasi. Di sini Anda dapat membuat dan mengelola kunci, serta menemukan ID penerbit Anda. Saat menggunakan kunci, Anda akan memerlukan ID kunci dan ID penerbit juga.
Unduh dan simpan sertifikat root yang ditemukan di bagian Apple Root Certificate di situs Apple PKI. Berikan sertifikat ini sebagai array ke SignedDataVerifier untuk memungkinkan memverifikasi data yang ditandatangani berasal dari Apple.
Impor {AppStoreServerapiClient, Environment, SendTestNotificationResponse} dari "@apple/app-store-server-library" consuerid = "99b16628-15e4-4668-972b-ef55eeff55" const keyid = "abcdefge" constlexplef55 "constlexplef55" consteD = "ABCDEFGGHI" CONSTOXPLEF55 "CONSTERLEX =" ABCDEFGGHI = "ABCDEFGHI" CONSTERLEF. "ABCDEFGHI" CONSTLEF. "CONSTLEF." CONSTLEXPLEF5555 filepath = "/path/to/key/subscription_abcdefghij.p8"const encodedKey = readfile (filepath) // implementasi spesifik dapat varycoNst lingkungan = lingkungan. Klien NEW APPSTORESERVERAPICLIENT (EncodedKey, Keyid, Issuerid, Bundeling, Bundle, Bundle) (encodedKey, Keyid, Issuerid, Bundle, Bundle, Bundle, Bundle, Bundle, Bundle, Respons: SendTestNotificationResponse = Await client.RequestTestNotification () console.log (respons)} catch (e) {console.error (e)}
Impor {SignedDataVerifier} dari "@@apple/app-store-server-library" const bundleid = "com.example" const applerootcas: buffer [] = loadrootcas () // implementasi spesifik dapat bervariasi enableOnlinecheck = truecons lingkungan = lingkungan.sandboxconst = tidak terdefinisi // appappleid diperlukan ketika lingkungan adalah produksicoNst verifier = new SignedDataVerifier (applerootcas, enableOnlinechecks, lingkungan, bundleid, appappleid) const notificationPayLoad = "ey ..." const verifiedNotification = Await verifier.verifiFiFiFiFiFYDECODEDOODLOADIFIFIKASI (notificationPotification (notificationPotification (notificationpotification (notificationP. verifier. VerifiedNotification)
Impor {AppStoreServerapiClient, Lingkungan, GetTransactionHistoryVersion, Penerimaan, Pesanan, ProductType, HistoryResponse, TransactionHistoryRequest} dari "@apple/app-store-server-library" consuerid = "99b16628-15e4-4-4668-97.97B167B1666628-15E4-4-4668-97.97BRAY = 99B166628-15E4-4-4668-97A. "const bundleid =" com.example "const filepath =" /path/to/key/subscription_abcdefghij.p8"const encodedKey = readfile (filepath) // implementasi spesifik dapat varycoNst lingkungan = lingkungan. , issuerId, bundleId, environment)const appReceipt = "MI..."const receiptUtil = new ReceiptUtility()const transactionId = receiptUtil.extractTransactionIdFromAppReceipt(appReceipt)if (transactionId != null) {const transactionHistoryRequest: TransactionHistoryRequest = {sort: Order. Ascending, Revoked: False, ProductTypes: [ProductType.Auto_Renewable]} Biarkan Respons: HistoryResponse | null = transaksi nulllet: string [] = [] do {const revisionToken = response! == null && response.revision! == null? response.revision: nullResponse = menunggu client.gettransactionhistory (transactionid, revisionToken, transactionHistoryRequest, getTransactionHistoryVersion.v2) if (response.signedtransactions) {transactions = transactions.concat (response.signedtransactions)}}}}}} {transactions) (response. transaksi)}
Impor {PromosifersignatureCreator} dari "@@apple/app-store-server-library" const keyid = "abcdefghij" const bundleid = "com.example" const filepath = "/path/to/key/subscription_abcdefghij.p8"conceredkey = excodedkey = readfile = readfile = readfile = readfile = readfile = readfile = readfile = readfile = readfile_abcdefghij.p8"concingkey =subscripcription = (FilePath) // Implementasi spesifik dapat varyconst productId = "<product_id>" constcriptionofferid = "<splipcription_offer_id>" const applicationUserName = "<plication_username>" const nonce = "<nonce>" const timestamp = date.now () constandreator constandreator = PromosifersignatureCreator (encodedKey, keyid, bundleid) baru Signature = SignatureCreator.createSignature (ProductId, SubscriptionOfferID, ApplicationUserName, Nonce, Timestamp) Console.log (Signature)
Hanya versi utama perpustakaan terbaru yang akan menerima pembaruan, termasuk pembaruan keamanan. Oleh karena itu, disarankan untuk memperbarui ke versi utama baru.