Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

- Drop support for Node 12, 13, 14, and 15
- Adds `webhook_secret` and `custom_headers` properties to Typescript definitions of a Webhook
- Adds the following functions to assist ReferralCustomers add credit cards and bank accounts:
- `betaReferralCustomer.createCreditCardClientSecret`
- `betaReferralCustomer.createBankAccountClientSecret`
- `referralCustomer.addCreditCardFromStripe`
- `referralCustomer.addBankAccountFromStripe`
- Properly returns the response body of the following functions: `addPaymentMethod`, `refundByAmount`, `refundByPaymentLog`
- `findMatchingMockRequest` mocking function made private
- Removes undocumented and unmaintained `repl`
- Bumps dependencies
Expand Down
2 changes: 1 addition & 1 deletion examples
Submodule examples updated 47 files
+0 −5 .babelrc
+29 −25 Gemfile.lock
+11 −9 README.md
+3 −3 examples.gemspec
+10 −0 official/fixtures/client-library-fixtures.json
+2,036 −1,408 package-lock.json
+0 −2 package.json
+10 −9 style_guides/ruby/.rubocop.yml
+2 −2 style_guides/ruby/easycop.yml
+2 −0 tools/docs/responses/.gitignore
+62 −0 tools/docs/responses/Makefile
+19 −0 tools/docs/responses/README.md
+0 −0 tools/docs/responses/builder/__init__.py
+164 −0 tools/docs/responses/builder/snippets.py
+45 −0 tools/docs/responses/setup.py
+0 −0 tools/docs/responses/tests/__init__.py
+256 −0 tools/docs/responses/tests/conftest.py
+68 −0 tools/docs/responses/tests/test_address.py
+69 −0 tools/docs/responses/tests/test_api_keys.py
+100 −0 tools/docs/responses/tests/test_batch.py
+69 −0 tools/docs/responses/tests/test_billing.py
+11 −0 tools/docs/responses/tests/test_brand.py
+48 −0 tools/docs/responses/tests/test_carrier_account.py
+10 −0 tools/docs/responses/tests/test_carrier_types.py
+18 −0 tools/docs/responses/tests/test_customs_info.py
+18 −0 tools/docs/responses/tests/test_customs_item.py
+54 −0 tools/docs/responses/tests/test_end_shipper.py
+112 −0 tools/docs/responses/tests/test_event.py
+15 −0 tools/docs/responses/tests/test_form.py
+25 −0 tools/docs/responses/tests/test_insurance.py
+11 −0 tools/docs/responses/tests/test_options.py
+48 −0 tools/docs/responses/tests/test_order.py
+18 −0 tools/docs/responses/tests/test_parcel.py
+43 −0 tools/docs/responses/tests/test_pickup.py
+20 −0 tools/docs/responses/tests/test_rate.py
+84 −0 tools/docs/responses/tests/test_referral_customer.py
+31 −0 tools/docs/responses/tests/test_refund.py
+34 −0 tools/docs/responses/tests/test_report.py
+11 −0 tools/docs/responses/tests/test_returns.py
+27 −0 tools/docs/responses/tests/test_scan_form.py
+61 −0 tools/docs/responses/tests/test_shipment.py
+18 −0 tools/docs/responses/tests/test_shipping_insurance.py
+11 −0 tools/docs/responses/tests/test_smartrate.py
+12 −0 tools/docs/responses/tests/test_tax_identifiers.py
+18 −0 tools/docs/responses/tests/test_tracker.py
+37 −0 tools/docs/responses/tests/test_user.py
+50 −0 tools/docs/responses/tests/test_webhook.py
591 changes: 297 additions & 294 deletions package-lock.json

Large diffs are not rendered by default.

36 changes: 31 additions & 5 deletions src/services/beta_referral_customer_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default (easypostClient) =>
* @returns {Object} - A JSON object representing the payment method.
*/
static async addPaymentMethod(stripeCustomerId, paymentMethodReference, priority = 'primary') {
const wrappedParams = {
const params = {
payment_method: {
stripe_customer_id: stripeCustomerId,
payment_method_reference: paymentMethodReference,
Expand All @@ -20,9 +20,9 @@ export default (easypostClient) =>

const url = 'beta/referral_customers/payment_method';

const response = await easypostClient._post(url, wrappedParams);
const response = await easypostClient._post(url, params);

return response;
return response.body;
}

/**
Expand All @@ -39,7 +39,7 @@ export default (easypostClient) =>

const response = await easypostClient._post(url, params);

return response;
return response.body;
}

/**
Expand All @@ -56,6 +56,32 @@ export default (easypostClient) =>

const response = await easypostClient._post(url, params);

return response;
return response.body;
}

/**
* Creates a client secret to use with Stripe when adding a credit card.
* @returns {object} - A JSON object representing the client secret.
*/
static async createCreditCardClientSecret() {
const url = 'beta/setup_intents';

const response = await easypostClient._post(url, null);

return response.body;
}

/**
* Creates a client secret to use with Stripe when adding a credit card.
* @returns {object} - A JSON object representing the client secret.
*/
static async createBankAccountClientSecret(returnUrl) {
const params = returnUrl ? { return_url: returnUrl } : null;

const url = 'beta/financial_connections_sessions';

const response = await easypostClient._post(url, params);

return response.body;
}
};
47 changes: 46 additions & 1 deletion src/services/referral_customer_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export default (easypostClient) =>
}

/**
* Add a credit card to a {@link User referral customer's} account.
* Add a credit card to EasyPost for a ReferralCustomer without needing a Stripe account. This function requires the ReferralCustomer User's API key.
* See {@link https://www.easypost.com/docs/api/node#create-credit-card EasyPost API Documentation} for more information.
* @param {string} referralApiKey - The referral customer's production API key.
* @param {string} number - The credit card number.
Expand Down Expand Up @@ -159,6 +159,51 @@ export default (easypostClient) =>
return paymentMethod;
}

/**
* Add a credit card to EasyPost for a ReferralCustomer with a payment method ID from Stripe.
* This function requires the ReferralCustomer User's API key.
* @returns {object} - A JSON object representing the credit card.
*/
static async addCreditCardFromStripe(referralApiKey, paymentMethodId, priority = 'primary') {
const _client = _getReferralClient(easypostClient, referralApiKey);
const params = {
credit_card: {
payment_method_id: paymentMethodId,
priority: priority,
},
};
const url = 'credit_cards';

const response = await _client._post(url, params);

return this._convertToEasyPostObject(response.body, params);
}

/**
* Add a bank account to EasyPost for a ReferralCustomer.
* This function requires the ReferralCustomer User's API key.
* @returns {object} - A JSON object representing the bank account.
*/
static async addBankAccountFromStripe(
referralApiKey,
financialConnectionsId,
mandateData,
priority = 'primary',
) {
const _client = _getReferralClient(easypostClient, referralApiKey);
const params = {
financial_connections_id: financialConnectionsId,
mandate_data: mandateData,
priority: priority,
};

const url = 'bank_accounts';

const response = await _client._post(url, params);

return this._convertToEasyPostObject(response.body, params);
}

/**
* Retrieve all {@link User referral customers} associated with the current authenticated user.
* See {@link https://www.easypost.com/docs/api/node#retrieve-a-list-of-referral-customers EasyPost API Documentation} for more information.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading