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
58 changes: 47 additions & 11 deletions dist/FlamSaasSDK.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions dist/FlamSaasSDK.min.esm.js

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

1 change: 1 addition & 0 deletions dist/FlamSaasSDK.min.esm.js.map

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions dist/FlamSaasSDK.min.js

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

1 change: 1 addition & 0 deletions dist/FlamSaasSDK.min.js.map

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions examples/vanilla-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,25 +118,28 @@ function buyCard(id) {
key: key
});

// photo: 'https://images.pexels.com/photos/2274725/pexels-photo-2274725.jpeg',
// const sample = {
// productId: id,
// refId: random,
// photo: 'https://images.pexels.com/photos/2274725/pexels-photo-2274725.jpeg',
// video: '',
// animation: 'CONFETTI',
// photo: 'https://images.pexels.com/photos/2274725/pexels-photo-2274725.jpeg',
// video:'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
// theme: {
// color: '#234f55'
// },
// prefill: {
// name: 'John Doe Prints',
// email: 'support@email.com',
// phone: '+91 98765 43210'
// },
// logo: 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/51/Facebook_f_logo_%282019%29.svg/2048px-Facebook_f_logo_%282019%29.svg.png'
// };

let orderDetails = {
productId: id,
refId: random,
prefill: {
name: 'Yuvraj Singh',
email: 'support@email.com',
phone: '+91 98765 43210'
}
// logo: 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/51/Facebook_f_logo_%282019%29.svg/2048px-Facebook_f_logo_%282019%29.svg.png'
refId: random
};

flam.placeOrder(orderDetails, (err, res) => {
Expand Down
56 changes: 46 additions & 10 deletions src/placeOrder.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import { PAGES } from './constants';
import assert from './helper/assert';

/**
* Runs the SDK for Placing Order
* @function
* @param {Object} options
* @param {String} options.key the API Key found on your Application settings page
* @param {String} [options.environment] enviornment sandbox | production
*/

// TODO: write the parameter descriptions

export default async function placeOrder(order_details, callback) {
try {
// validate client data
Expand Down Expand Up @@ -73,6 +63,52 @@ export default async function placeOrder(order_details, callback) {
}
);

// validate prefill
if (order_details.prefill) {
assert.check(
order_details.prefill,
{
type: 'object',
message: "'prefill' is not valid."
},
{
name: {
optional: true,
type: 'string',
message: "'name' is required string."
},
email: {
optional: true,
type: 'string',
message: "'email' is required string."
},
phone: {
optional: true,
type: 'string',
message: "'phone' must be string."
}
}
);
}

// validate theme
if (order_details.theme) {
assert.check(
order_details.theme,
{
type: 'object',
message: "'theme' is not valid."
},
{
color: {
optional: true,
type: 'string',
message: "'name' is required string."
}
}
);
}

// validate callback function
assert.check(callback, {
type: 'function',
Expand Down
2 changes: 1 addition & 1 deletion ui/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,5 @@ export const updateCard = async ({
}
});

return res;
return res.data;
};
Loading