j3k0 / cordova-plugin-purchase

In-App Purchase for Cordova on iOS, Android and Windows
https://purchase.cordova.fovea.cc
1.29k stars 529 forks source link

Server Validation Question #1488

Closed rubanraj7 closed 6 months ago

rubanraj7 commented 6 months ago

Hello,

I am migrating from a PWA that used the digital goods API for In-App-Purchase's.

Previously, I received a purchase token which i used to validate the subscription purchase server side.

My question now is...is that not necessary?! Does the purchase get verified with the '.store.when().approved((transaction) => {}).verified((receipt) =>{})' flow?

If so, that's incredible, I am just looking for confirmation.

If not, then what do we return from the custom validator URL?

dchase-sir commented 6 months ago

My question I think goes along with this - even after going through 4 or 5 tutorials and even the examples, I'm not sure I understand the role of the receipt validation server other than "you should have one", and every example of one simply duplicates what apple would provide anyway without it. I must be off base but I'm lost on the benefit of inserting the customer's subscriptions into a database, much less why I 'should'. If Apple says they have a subscription, they're going to be billed for it. Who am I to tell the app NO because my server is out of date or something, and why involve another 3rd party like iaptic. Even the examples where you implement your own server involve iaptic, doesn't make a lot of sense if anyone could clarify it'd probably help the OP and I'd gleam a lot from it I'm sure.

mifkys commented 6 months ago

My question I think goes along with this - even after going through 4 or 5 tutorials and even the examples, I'm not sure I understand the role of the receipt validation server other than "you should have one", and every example of one simply duplicates what apple would provide anyway without it. I must be off base but I'm lost on the benefit of inserting the customer's subscriptions into a database, much less why I 'should'. If Apple says they have a subscription, they're going to be billed for it. Who am I to tell the app NO because my server is out of date or something, and why involve another 3rd party like iaptic. Even the examples where you implement your own server involve iaptic, doesn't make a lot of sense if anyone could clarify it'd probably help the OP and I'd gleam a lot from it I'm sure.

It's can be not Apple says but your hacked application. So you need to verify this purchase by your server who send request to apple server to confirm that purchase has been really made

rubanraj7 commented 6 months ago

My question I think goes along with this - even after going through 4 or 5 tutorials and even the examples, I'm not sure I understand the role of the receipt validation server other than "you should have one", and every example of one simply duplicates what apple would provide anyway without it. I must be off base but I'm lost on the benefit of inserting the customer's subscriptions into a database, much less why I 'should'. If Apple says they have a subscription, they're going to be billed for it. Who am I to tell the app NO because my server is out of date or something, and why involve another 3rd party like iaptic. Even the examples where you implement your own server involve iaptic, doesn't make a lot of sense if anyone could clarify it'd probably help the OP and I'd gleam a lot from it I'm sure.

I finally figured it out. I was able to use my own server without Iaptic. When you set the url to an endpoint in your api, it needs to return a 200 call in this format:

return response()->json(["ok" => true, "data"=>['id'=>$productId]], 200) ( or equivalent).

I found this in the iaptic docs. Then it will hit the .verified((receipt )=>( //your code here )) in your front end.

For it to fail, it should return return response()->json(["ok" => false, "data"=>['id'=>$productId]], 400);

RayCode98 commented 2 months ago

It's can be not Apple says but your hacked application. So you need to verify this purchase by your server who send request to apple server to confirm that purchase has been really made

Hello friend, I have the same problem...

Do you place the endpoint of your server in store.validator = "url"?? or where you configure it.