XiaoCongGame / sdk-smart-lib

The Android library project for Xiaocong SDK
0 stars 1 forks source link

Doc: How consumables can be implemented? #5

Closed thedmd closed 10 years ago

thedmd commented 10 years ago

I need to create consumables so one purchase button each time will try to purchase new item. Apparently one orderNo can be used only once, in that case how can I implement repetitive purchases? Should I increase orderNo after each payment? Is orderNo assigned to only my telephone number so it will not collide with another device?

ReDreamport commented 10 years ago

The orderNo is the transaction identifier actually. We're involved in a distributed transaction when you issue a payment request. It's the initiator of the transaction(here, you) that should generate the transaction identifier if there' no central transaction manager. And the identifier must be unique globally in our system to prevent all race conditions.

For example, the payment could be failed at client due to network timeout. The request may suspend in our server: the thread which is processing the request is suspended in our system. So if you query for the order immediately, the result is "no such order". For this case, you may re-send it to us again and the request is finished finally. Until now, the suspended thread go! Here we must use your unique orderNo to figure out that the order has been processed before. Otherwise users may pay twice!

The orderNo must be persisted before sending to us. And persisting in your server is preferred.

ReDreamport commented 10 years ago

Please use your partnerId as the prefix of the orderNo. The subsequent string must be unique in all of your requests.

thedmd commented 10 years ago

I didn't know partnerId must be a prefix of orderId. I will use it that way.

In demo application we can read orderId is a string which size should be 12 to 20. Is this correct or maybe there are some extra character I can utilize?

ReDreamport commented 10 years ago

Sorry for the misleading requirement. Let me fix it:

The orderNo(including the prefix) has 30 characters at most.

I'll fix the demo soon.

thedmd commented 10 years ago

Thank you.