2014-09-05 44 views
2

客户信息,我使用解析云模块菌柄来检索条纹我使用解析云模块菌柄来检索条纹

的API,我使用的客户信息 - Stripe.Customers.retrieve有一个选项“扩大”内联展开属性来获取整个对象 - https://stripe.com/docs/api/node#expand

这是我的代码 -

Stripe.Customers.retrieve(customerId,{ 
         expand: ["default_card"], 
         success: function(stripeCustomer){ 

          console.log("GetCreditCardInformationForCustomerStripe: Customer info received: "+JSON.stringify(stripeCustomer)); 
          var creditCardResponse = { 
            "id"    : stripeCustomer.id, 
            "cardId"   : stripeCustomer.default_card.id, 
            "cardHolderName" : stripeCustomer.default_card.name, 
            "cardBrand"   : stripeCustomer.default_card.brand, 
            "cardExpMonth"  : stripeCustomer.default_card.exp_month, 
            "cardExpYear"  : stripeCustomer.default_card.exp_year, 
            "cardLast4Digits" : stripeCustomer.default_card.last4, 
            "cardFundingType" : stripeCustomer.default_card.funding 
          }; 

          response.success(creditCardResponse); 

         }, error: function(error){ 

          console.log("getCreditCardInformationForCustomer: Fetch Stripe Customer failed for Stripe customerId: "+customerId); 
          console.log("error "+JSON.stringify(error)); 
          var error = new Parse.Error(Parse.Error.OTHER_CAUSE, "FetchStipeCustomerFailed"); 
          response.error(error); 

         } 
        }); 

这里是响应

Customer info received: 
    { 
     "object": "customer", 
     "created": 1408129243, 
     "id": "cus_4b20U8dcPZcQgb", 
     "livemode": false, 
     "description": null, 
     "email": "[email protected]", 
     "delinquent": false, 
     "metadata": { 
     "name": "Ankit Gangal", 
     "parseUserId": "undefined" 
     }, 
     "subscriptions": { 
     "object": "list", 
     "total_count": 0, 
     "has_more": false, 
     "url": "/v1/customers/cus_4b20U8dcPZcQgb/subscriptions", 
     "data": [ 

     ] 
     }, 
     "discount": null, 
     "account_balance": 0, 
     "currency": null, 
     "cards": { 
     "object": "list", 
     "total_count": 1, 
     "has_more": false, 
     "url": "/v1/customers/cus_4b20U8dcPZcQgb/cards", 
     "data": [ 
      { 
      "id": "card_14VqYZ28ck1ONXovNwtwPw0k", 
      "object": "card", 
      "last4": "4242", 
      "brand": "Visa", 
      "funding": "credit", 
      "exp_month": 4, 
      "exp_year": 2021, 
      "fingerprint": "kQf99zmtHwo0T0P2", 
      "country": "US", 
      "name": null, 
      "address_line1": null, 
      "address_line2": null, 
      "address_city": null, 
      "address_state": null, 
      "address_zip": null, 
      "address_country": null, 
      "cvc_check": "pass", 
      "address_line1_check": null, 
      "address_zip_check": null, 
      "customer": "cus_4b20U8dcPZcQgb" 
      } 
     ] 
     }, 
     "default_card": "card_14VqYZ28ck1ONXovNwtwPw0k" 
    } 

正如你可以看到default_card没有展开,

我尝试过其他组合如{“扩展”:“customer.default_card”]}等,但没有任何工程, 没有任何人知道如何使这项工作?

感谢

+0

此API太糟糕了。 – SleepsOnNewspapers 2015-05-15 23:28:43

+0

对此有何更新? – SleepsOnNewspapers 2015-05-15 23:30:23

回答

0

作为一种变通方法,我已经直接使用API​​调用从CloudCode一些运气,传递“扩大”在URL中。 “data.source”上的“展开”帐户余额GET请求如下所示:

Parse.Cloud.httpRequest({ 
    url: 'https://MY_SECRET_KEY:@api.stripe.com/v1/balance/history?expand[]=data.source', 
    method: "GET", 
    headers: { 
     'Stripe-Account': THE_ACCOUNT_ID, 
     }, 
    body:{} 

}).then(function(httpResponse) { 

    response.success(httpResponse.data); 

},function(error) { 

    response.error(error); 

});