2014-09-05 65 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); 

});