قالب وردپرس درنا توس
Home / IOS Development / IOS – Could not buy with subscription offer

IOS – Could not buy with subscription offer



I'm trying to make In-App Purchase subscription offers worked. So I get coded signature, nonce, timestamp and key identifier from our server. I create a SKPaymentDiscount object and set it to paymentDiscount by SKMutablePayment item.

On the first pop it shows the revised price as expected -> enter the password and continue -> Other popups: Confirm subscription: Ok -> Third popup: Displays the following error Cannot be purchased Contact the developer for more information.

I tried to send a non-relevant offer identifier for a product. Then it threw it right wrong and said: This can't be used for this.

  PromoOfferAPI.prepareOffer (usernameHash: "name", productIdentifier: "bundleid.product", offerIdentifier: "TEST1
0") { change result { case la .success (discount): // The original product is purchased. la payment = SKMutablePayment (product: option.product) // You must enter the program name to be the same as the one used to generate the signature. payment.applicationUsername = "name" // Add the offer to the payment. payment.paymentDiscount = discount // Add the payment to the queue for purchases. SKPaymentQueue.default (). Add (payment) break case la .customFail (message): print (message) break case la .failure (error): print (error.localizedDescription) break } }

No matter how many times I try, it continues to give me the same error. Can not buy Contact the developer for more information. What can be done to solve this problem. Any help is much appreciated.

Thanks in advance!

Edit 1: It never enters the updatedTransactions function. It logs only Finishing transaction for "bundleid.product" payment with state: failed.

Edit 2: Got the error: code – 12 (invalidSignature). Cannot connect to iTunes Store

Node.JS code that generates the encoded signature. Const UUID = requires ("uuid-v4");
const microtime = requires (& # 39; microtime & # 39;);
const express = require (& # 39; express & # 39;);
const router = express.Router ();
const EC = requires ("elliptical"). ec;
const ec = new EC ("secp256k1");
const crypto = requires (& # 39; crypto & # 39;);

const privateKey = `—– BEGIN PRIVATE KEY —–
The key goes here
—– END PRIVATE KEY —– `;
// const key = ec.keyFromPrivate (privateKey, & # 39; hex & # 39;);

router.post (& # 39; / & # 39 ;, (req, res) => {
const bundle_id = "bundle.id";
const key_id = "keyed";
const nonce = String (UUID ()). toLowerCase (); // Must be lowercase
const timestamp = microtime.now ();

const product = req.body.product;
const offer = req.body.offer;
const application_username = req.body.application_username;

const payload = bundle_id + & # 39; + key_id + & # 39; + product + & # 39; + offers + & # 39; + application_user + & # 39; + String (nonce) + & # 39; + String timestamp)
la shaMsg = crypto.createHash ("sha256"). Update (payload) .digest ();
la signature = ec.sign (shaMsg, privateKey, {canonical: true});
let derSign = signature.toDER ();
la buff = new buffer (derSign);
leave base64EncodedSignature = buff.toString (& # 39; base64 & # 39;);
la response = {
"signeture": base64EncodedSignature,
"nonce": nonce,
"timestamp": timestamp,
"keyIdentifier": key_id
}
Res.type (& # 39; sonic & # 39;) send (response) .;
});

module.exports = router;


Source link