Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #5 from remedyproduct/development
Browse files Browse the repository at this point in the history
Add new parametr for confirmPaymen
  • Loading branch information
vad9s6 authored Nov 30, 2021
2 parents 3e5aa8f + 50cfea6 commit 544c0b8
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v0.0.5

- Add new param to `confirmPaymentIntentByCard`
### v0.0.4

- Added method `getAllCards`
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const stripe = await loadStripe("pk_test_TYooMQauvdEDq54NiTphI7jx");

| Method | Arguments | Description |
| -------------------------- | ------------------------------------------------- | ------------------------------------------------------ |
| confirmPaymentIntentByCard | [client_secret], [card_id] | Confirm payment with the user's payment intent card. |
| confirmPaymentIntentByCard | [client_secret], [card_id], [returnUrl] | Confirm payment with the user's payment intent card. |
| addSourceToCustomer | [source or token], [customer_id], [ephemeral_key] | Add payment method to customer (from source or token). |
| deleteSourceFromCustomer | [source_id], [customer_id], [ephemeral_key] | Delete payment method from customer. |
| getAllCards | [ephemeral_key], [customer_id] | Get all cards from customer. |
Expand All @@ -40,7 +40,8 @@ const stripe = await loadStripe("pk_test_TYooMQauvdEDq54NiTphI7jx");
```
stripe.confirmPaymentIntentByCard(
'pi_3Jrk80HdlMaZle3e1tGtSxiH_secret_mWdWNlqJfkYEoYOml1GqRPyPm',
'card_1JrMi8HdlMaZle3eSPPOvapJ'
'card_1JrMi8HdlMaZle3eSPPOvapJ',
'https://stripe.com/'
);
stripe.addSourceToCustomer(
Expand All @@ -56,18 +57,18 @@ stripe.deleteSourceFromCustomer(
);
stripe.getAllCards(
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ',
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ',
'cus_KO9SkBdMeHoMXR'
);
stripe.getCustomer(
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ',
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ',
'cus_KO9SkBdMeHoMXR'
);
stripe.setDefaultCard(
'card_1JrMi8HdlMaZle3eSPPOvapJ',
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ',
'card_1JrMi8HdlMaZle3eSPPOvapJ',
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ',
'cus_KO9SkBdMeHoMXR'
);
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remedyproduct/stripe-js",
"version": "0.0.4",
"version": "0.0.5",
"description": "Additional methods for working with stripe-js",
"main": "./lib/index.js",
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions src/methods/confirmPaymentIntentByCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { RemedyProductStripe } from "./index";
export const confirmPaymentIntentByCard = async function (
this: RemedyProductStripe,
paymentIntentSecret: string,
paymentMethodId: string
paymentMethodId: string,
returnUrl?: string
): Promise<PaymentIntentResult["paymentIntent"] | undefined> {
/* eslint-disable */
const stripeApiKey = this._apiKey;
Expand All @@ -26,7 +27,7 @@ export const confirmPaymentIntentByCard = async function (
return fetch(
`${stripeApiUrl}/payment_intents/${paymentIntentId}/confirm?client_secret=${paymentIntentSecret}`,
{
body: `payment_method=${paymentMethodId}`,
body: `payment_method=${paymentMethodId}${typeof returnUrl === 'string' ? `&return_url=${returnUrl}` : ''}`,
headers: {
Authorization: `Bearer ${stripeApiKey}`,
"Content-Type": `application/x-www-form-urlencoded`,
Expand Down
2 changes: 1 addition & 1 deletion src/methods/getAllCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const getAllCards = async function (
throw new Error("Initialization failed.");

// make request
return await fetch(
return fetch(
`${stripeApiUrl}/payment_methods?customer=${customerId}&type=card&limit=100`,
{
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/methods/getCustomer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const getCustomer = async function (
throw new Error("Initialization failed.");

// make request
return await fetch(`${stripeApiUrl}/customers/${customerId}`, {
return fetch(`${stripeApiUrl}/customers/${customerId}`, {
headers: {
Authorization: `Bearer ${customerKey}`,
"Stripe-Version": stripeApiVersion,
Expand Down
2 changes: 1 addition & 1 deletion src/methods/setDefaultCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const setDefaultCard = async function (
throw new Error("Initialization failed.");

// make request
return await fetch(`${stripeApiUrl}/customers/${customerId}`, {
return fetch(`${stripeApiUrl}/customers/${customerId}`, {
body: `default_source=${defaultCardId}`,
headers: {
Authorization: `Bearer ${customerKey}`,
Expand Down

0 comments on commit 544c0b8

Please sign in to comment.