Skip to content

Commit

Permalink
Merge pull request #5 from tonderio/metadata
Browse files Browse the repository at this point in the history
Add metadata field
  • Loading branch information
adrian-martinez-dev authored Jan 25, 2024
2 parents e294cdb + 2caa288 commit bbea26c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ const checkoutData = {
amount_total: 399,
},
]
},
metadata: {
order_id: 123456
}
};

Expand Down
7 changes: 7 additions & 0 deletions src/classes/inlineCheckout.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class InlineCheckout {
collectContainer = null
merchantData = {}
cartTotal = null
metadata = {}

constructor ({
apiKey,
Expand Down Expand Up @@ -80,6 +81,7 @@ export class InlineCheckout {
this.#handleCustomer(data.customer)
this.setCartTotal(data.cart?.total)
this.setCartItems(data.cart?.items)
this.#handleMetadata(data)
const response = await this.#checkout()
if (response) {
const process3ds = new ThreeDSHandler({ payload: response });
Expand Down Expand Up @@ -111,6 +113,10 @@ export class InlineCheckout {
this.phone = customer?.phone
}

#handleMetadata(data) {
this.metadata = data?.metadata
}

setCartItems (items) {
console.log('items: ', items)
this.cartItems = items
Expand Down Expand Up @@ -271,6 +277,7 @@ export class InlineCheckout {
business_id: business.pk,
payment_id: jsonResponsePayment.pk,
source: 'sdk',
metadata: this.metadata
};
const jsonResponseRouter = await startCheckoutRouter(
this.baseUrl,
Expand Down
3 changes: 3 additions & 0 deletions src/index-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ const checkoutData = {
amount_total: 399,
},
]
},
metadata: {
order_id: 123456
}
};

Expand Down

0 comments on commit bbea26c

Please sign in to comment.