Added name and address to stripe customer objects (#35066)

This commit is contained in:
Jamie Davies
2019-05-08 11:44:34 -07:00
committed by Jesse Trinity
parent 14c84d853f
commit 1ebe063797
2 changed files with 89 additions and 34 deletions
+52 -31
View File
@@ -21,6 +21,7 @@
// Jonas Keisel <https://github.com/0xJoKe>
// Andrew Delianides <https://github.com/delianides>
// Gokul Chandrasekaran <https://github.com/gokulchandra>
// Jamie Davies <https://github.com/viralpickaxe>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -1587,6 +1588,8 @@ declare namespace Stripe {
*/
account_balance?: number;
address: IAddress | null;
created: number;
/**
@@ -1617,6 +1620,8 @@ declare namespace Stripe {
metadata: IMetadata;
name: string | null;
/**
* Shipping information associated with the customer.
*/
@@ -1644,6 +1649,8 @@ declare namespace Stripe {
*/
account_balance?: number;
address?: IAddress;
/**
* If you provide a coupon code, the customer will have a discount applied on all recurring charges. Charges you create through the
* API will not have the discount.
@@ -1662,6 +1669,11 @@ declare namespace Stripe {
*/
email?: string;
/**
* The customer’s full name or business name.
*/
name?: string;
/**
* The identifier of the plan to subscribe the customer to. If provided, the returned customer object will have a list of subscriptions
* that the customer is currently subscribed to. If you subscribe a customer to a plan without a free trial, the customer must have a
@@ -1708,6 +1720,8 @@ declare namespace Stripe {
*/
account_balance?: number;
address?: IAddress;
/**
* If you provide a coupon code, the customer will have a discount applied on all recurring charges. Charges you create through the
* API will not have the discount.
@@ -1731,6 +1745,11 @@ declare namespace Stripe {
*/
email?: string;
/**
* The customer’s full name or business name.
*/
name?: string;
/**
* The prefix for the customer used to generate unique invoice numbers.
*/
@@ -8536,41 +8555,43 @@ declare namespace Stripe {
[x: string]: string;
}
interface IAddress {
/**
* Address line 1 (Street address/PO Box/Company name)
*/
line1: string;
/**
* Address line 2 (Apartment/Suite/Unit/Building)
*/
line2?: string;
/**
* City/Suburb/Town/Village
*/
city?: string;
/**
* State/Province/County
*/
state?: string;
/**
* Zip/Postal Code
*/
postal_code?: string;
/**
* 2-letter country code
*/
country?: string;
}
interface IShippingInformation {
/**
* Shipping address.
*/
address: {
/**
* Address line 1 (Street address/PO Box/Company name)
*/
line1: string;
/**
* Address line 2 (Apartment/Suite/Unit/Building)
*/
line2?: string;
/**
* City/Suburb/Town/Village
*/
city?: string;
/**
* State/Province/County
*/
state?: string;
/**
* Zip/Postal Code
*/
postal_code?: string;
/**
* 2-letter country code
*/
country?: string;
};
address: IAddress;
/**
* Recipient name.
+37 -3
View File
@@ -226,6 +226,7 @@ stripe.charges.markAsFraudulent('ch_15fvyXEe31JkLCeQOo0SwFk9').then((refunds) =>
// ##################################################################################
stripe.customers.create({
name: 'John Doe',
description: 'Customer for test@example.com',
source: "tok_15V2YhEe31JkLCeQy9iUgsJX", // obtained with Stripe.js
metadata: { test: "123", test2: 123 } // IOptionsMetadata test
@@ -260,8 +261,16 @@ stripe.customers.create({
customer.subscriptions.del("sub_8Eluur5KoIKxuy").then((subscription) => { });
customer.subscriptions.deleteDiscount("sub_8Eluur5KoIKxuy").then((confirmation) => { });
// IMetadata tests:
const str = '123';
// IAddress tests:
customer.address.line1 === str;
customer.address.line2 === str;
customer.address.city === str;
customer.address.postal_code === str;
customer.address.state === str;
customer.address.country === str;
// IMetadata tests:
customer.metadata["test"] === str;
customer.metadata.test1 === str;
@@ -284,6 +293,27 @@ stripe.customers.create({
metadata = null;
});
// With address
stripe.customers.create({
name: 'John Doe',
address: {
line1: '96 Road Drive',
country: 'United Kingdom'
}
}, (err, customer) => {
// asynchronously called
});
stripe.customers.create({
name: 'John Doe',
address: {
line1: '96 Road Drive',
line2: 'Something',
city: 'London'
}
}, (err, customer) => {
// asynchronously called
});
stripe.customers.create({
description: 'Customer for test@example.com',
source: "tok_15V2YhEe31JkLCeQy9iUgsJX" // obtained with Stripe.js
@@ -330,10 +360,14 @@ stripe.customers.retrieve("cus_5rfJKDJkuxzh5Q").then((customer) => {
});
stripe.customers.update("cus_5rfJKDJkuxzh5Q", {
description: "Customer for test@example.com"
name: 'John Doe',
description: "Customer for test@example.com",
address: {
line1: '2 New Road',
}
}, (err, customer) => {
// asynchronously called
});
});
stripe.customers.update("cus_5rfJKDJkuxzh5Q", {
description: "Customer for test@example.com"
}).then((customer) => {