Exemplo n.º 1
0
    def create_refund(self):
        """
        Create a refund for this purchase if total billed was more than 0 iCredits
        Return true if refund was made, otherwise False
        """
        db = current.db
        app = db(db.app_data.id > 0).select().first()
        ssn_row = db(db.app_session.id==self.app_session_id).select().first()

        if float(self.amount_total) > 0:
            store_api = BillingAPI(app.store_url, app.version, ssn_row.app_session_num, self.access_token)         
            if self.refund_status == 'NOTREFUNDED':
                comment = 'Automatic refund was triggered by a PicardSpace error'
                store_api.refundPurchase(self.purchase_num, self.refund_secret, 
                                         comment=comment)                
                self.set_refund_status('COMPLETED', comment)                
                return True
        return False
Exemplo n.º 2
0
"""
# cloud-hoth
client_key                 = "" # from dev portal app Credentials tab
client_secret              = "" # from dev portal app Credentials tab
AppSessionId               = "" # from launching an app
accessToken                = "" # from oauth2
BaseSpaceUrl               = "" # eg. "https://api.cloud-hoth.illumina.com/"
BaseSpaceStoreUrl          = "" # eg. "https://hoth-store.basespace.illumina.com/"
version                    = "" # eg. 'v1pre3'
product_id                 = "" # from dev portal Pricing tab

if not client_key:
    raise Exception("Please fill in client values (in the script) before running the script")

# Create a client for making calls for this user session 
billAPI   = BillingAPI(BaseSpaceStoreUrl, version, AppSessionId, AccessToken=accessToken)

# create a non-consumable purchase
#purch = billAPI.createPurchase([{'id':product_id,'quantity':4 }])

# create a consumable purchase, and associated it with an AppSession
# also add tags to provide (fake) details about the purchase
print "\nCreating purchase\n"
purch = billAPI.createPurchase({'id':product_id,'quantity':4, 'tags':["test","test_tag"] }, AppSessionId)

# record the purchase Id and RefundSecret for refunding later
purchaseId = purch.Id
refundSecret = purch.RefundSecret

print "Now complete the purchase in your web browser"
print "CLOSE the browser window/tab after you click 'Purchase' (and don't proceed into the app)"
Exemplo n.º 3
0
client_secret = ""  # from dev portal app Credentials tab
AppSessionId = ""  # from launching an app
accessToken = ""  # from oauth2
BaseSpaceUrl = ""  # eg. "https://api.cloud-hoth.illumina.com/"
BaseSpaceStoreUrl = ""  # eg. "https://hoth-store.basespace.illumina.com/"
version = ""  # eg. 'v1pre3'
product_id = ""  # from dev portal Pricing tab

if not client_key:
    raise Exception(
        "Please fill in client values (in the script) before running the script"
    )

# Create a client for making calls for this user session
billAPI = BillingAPI(BaseSpaceStoreUrl,
                     version,
                     AppSessionId,
                     AccessToken=accessToken)

# create a non-consumable purchase
#purch = billAPI.createPurchase([{'id':product_id,'quantity':4 }])

# create a consumable purchase, and associated it with an AppSession
# also add tags to provide (fake) details about the purchase
print("\nCreating purchase\n")
purch = billAPI.createPurchase(
    {
        'id': product_id,
        'quantity': 4,
        'tags': ["test", "test_tag"]
    }, AppSessionId)