@@ -64,6 +64,7 @@ export async function getOrders({
6464
6565export async function createOrder ( {
6666 secretKey,
67+ coupons,
6768 accountId,
6869 orderSchemaId,
6970 userId,
@@ -84,6 +85,7 @@ export async function createOrder({
8485 'Content-Type' : 'application/json' ,
8586 } ,
8687 body : JSON . stringify ( {
88+ coupons,
8789 accountId,
8890 orderSchemaId,
8991 userId,
@@ -495,3 +497,63 @@ export async function cancelSubscription({secretKey, id, customerId}) {
495497
496498 return response ;
497499}
500+
501+ export async function getApplicableCoupons ( {
502+ secretKey,
503+ codes,
504+ orderSchemaId,
505+ userId,
506+ lines,
507+ asGuest,
508+ } ) {
509+ const response = await server . loadJson (
510+ `${ Config . apiUrl } ${ Endpoints . PROJECT . PAYMENTS . DISCOUNTS . GET_APPLICABLE_COUPONS } ` ,
511+ {
512+ method : 'POST' ,
513+ headers : {
514+ 'X-CM-ProjectId' : Config . projectId ,
515+ Authorization : `Bearer ${ secretKey || Config . secretKey } ` ,
516+ Accept : 'application/json' ,
517+ 'Content-Type' : 'application/json' ,
518+ } ,
519+ body : JSON . stringify ( {
520+ codes,
521+ orderSchemaId,
522+ userId,
523+ lines,
524+ asGuest,
525+ } ) ,
526+ }
527+ ) ;
528+
529+ return response ;
530+ }
531+
532+ export async function getApplicableDiscounts ( {
533+ secretKey,
534+ orderSchemaId,
535+ userId,
536+ lines,
537+ asGuest,
538+ } ) {
539+ const response = await server . loadJson (
540+ `${ Config . apiUrl } ${ Endpoints . PROJECT . PAYMENTS . DISCOUNTS . GET_APPLICABLE_DISCOUNTS } ` ,
541+ {
542+ method : 'POST' ,
543+ headers : {
544+ 'X-CM-ProjectId' : Config . projectId ,
545+ Authorization : `Bearer ${ secretKey || Config . secretKey } ` ,
546+ Accept : 'application/json' ,
547+ 'Content-Type' : 'application/json' ,
548+ } ,
549+ body : JSON . stringify ( {
550+ orderSchemaId,
551+ userId,
552+ lines,
553+ asGuest,
554+ } ) ,
555+ }
556+ ) ;
557+
558+ return response ;
559+ }
0 commit comments