Skip to content
This repository was archived by the owner on Oct 20, 2021. It is now read-only.

Commit cbc9900

Browse files
committed
implement #10
1 parent 693d784 commit cbc9900

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

demo/app/main-page.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ export function pageLoaded(args: observable.EventData) {
3232
viewModel.set("items", res);
3333
})
3434
.catch((e) => alert(e));
35-
36-
console.log(purchase.getStoreReceipt().replace(/[\r\n]/gi, ""));
37-
35+
3836
page.bindingContext = viewModel;
3937
}
4038

demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@
3838
"webpack-sources": "~1.0.1",
3939
"css-loader": "~0.28.7"
4040
}
41-
}
41+
}

purchase.ios.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ let productRequest: SKProductsRequest;
2424
let productIds: NSMutableSet<string>;
2525
let productRequestDelegate: SKProductRequestDelegateImpl;
2626
let paymentTransactionObserver: SKPaymentTransactionObserverImpl;
27+
let storedDeveloperPayload: string;
2728

2829
export function init(productIdentifiers: Array<string>): Promise<any> {
2930
return new Promise((resolve, reject) => {
@@ -46,11 +47,13 @@ export function getProducts(): Promise<Array<Product>> {
4647
});
4748
}
4849

49-
export function buyProduct(product: Product) {
50+
export function buyProduct(product: Product, developerPayload?: string) {
5051
if (!product.nativeValue) {
5152
throw "Invalid Product! (missing native value)";
5253
}
5354

55+
storedDeveloperPayload = developerPayload;
56+
5457
const payment = SKPayment.paymentWithProduct(product.nativeValue);
5558
SKPaymentQueue.defaultQueue().addPayment(payment);
5659
}
@@ -123,12 +126,15 @@ class SKPaymentTransactionObserverImpl extends NSObject implements SKPaymentTran
123126
const transaction = transactions.objectAtIndex(loop);
124127
const resultTransaction = new Transaction(transaction);
125128

129+
resultTransaction.developerPayload = storedDeveloperPayload;
130+
126131
common._notify(common.transactionUpdatedEvent, resultTransaction);
127132

128133
if (transaction.transactionState === SKPaymentTransactionState.Failed
129134
|| transaction.transactionState === SKPaymentTransactionState.Purchased
130135
|| transaction.transactionState === SKPaymentTransactionState.Restored) {
131136
SKPaymentQueue.defaultQueue().finishTransaction(transaction);
137+
storedDeveloperPayload = undefined;
132138
}
133139
}
134140
}

0 commit comments

Comments
 (0)