-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Donations: Fall back to default products if no products are already d…
…efined. (#43665)
- Loading branch information
Showing
4 changed files
with
63 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
apps/full-site-editing/full-site-editing-plugin/donations/fetch-default-products.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* eslint-disable wpcalypso/import-docblock */ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import apiFetch from '@wordpress/api-fetch'; | ||
|
||
const fetchDefaultProducts = async ( currency ) => { | ||
try { | ||
const result = await apiFetch( { | ||
path: '/wpcom/v2/memberships/products', | ||
method: 'POST', | ||
data: { | ||
type: 'donation', | ||
currency, | ||
}, | ||
} ); | ||
return result; | ||
} catch ( error ) { | ||
return Promise.reject( error.message ); | ||
} | ||
}; | ||
|
||
export default fetchDefaultProducts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters