I have a simple Unity App to test on LAT.
As the document said, the Purchase() suppose to callback PurchaseResponse() but its not.
Here is the code:
void Initialize()
{
iap = AmazonIapV2Impl.Instance;
RegisterEvent();
Debug.Log("Init");
}
#region Event Handle
private void RegisterEvent()
{
iap.AddGetUserDataResponseListener(GetUserResponse);
iap.AddPurchaseResponseListener(GetPurchaseResponse);
iap.AddGetPurchaseUpdatesResponseListener(GetPurchaseUpdateResponse);
iap.AddGetProductDataResponseListener(GetProductDataResponse);
}
private void GetPurchaseResponse(PurchaseResponse args)
{
Debug.LogWarning("Event purchase response");
string requestId = args.RequestId;
string userId = args.AmazonUserData.UserId;
string marketplace = args.AmazonUserData.Marketplace;
string receiptId = args.PurchaseReceipt.ReceiptId;
long cancelDate = args.PurchaseReceipt.CancelDate;
long purchaseDate = args.PurchaseReceipt.PurchaseDate;
string sku = args.PurchaseReceipt.Sku;
string productType = args.PurchaseReceipt.ProductType;
string status = args.Status;
Debug.Log("Request ID: " + requestId);
Debug.Log("User ID: " + userId);
Debug.Log("Marketplace: " + marketplace);
Debug.Log("Receipt ID: " + receiptId);
Debug.Log("Cancel Date: " + cancelDate);
Debug.Log("Purchase Date: " + purchaseDate);
Debug.Log("SKU: " + sku);
Debug.Log("Product Type: " + productType);
Debug.Log("Status: " + status);
Purchase(sku);
if (args.Status == "FULFILLED")
{
NotifyFulfillment(sku);
Debug.Log("Purchase successful");
}
else
{
Debug.Log("Purchase failed");
}
}
public void PurchaseProduct(string productId)
{
// Bắt đầu một yêu cầu mua hàng, trả về một RequestId
SkuInput sku = new SkuInput();
sku.Sku = productId;
RequestOutput request = iap.Purchase(sku);
string requestId = request.RequestId;
Debug.Log("Purchase Request: " + requestId);
}