Skip to content

Instantly share code, notes, and snippets.

@rickithadi
Created September 8, 2023 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickithadi/4207a58a04d1d8bf7e9885b485c61ef1 to your computer and use it in GitHub Desktop.
Save rickithadi/4207a58a04d1d8bf7e9885b485c61ef1 to your computer and use it in GitHub Desktop.
client side dpay checkout init
const {
data: { access_token, id },
} = await createDurianPayOrder();
console.log(access_token, id);
// @ts-ignore
let dpay = await window.Durianpay.init({
locale: "id",
environment: "production", // Value should be 'production' for both sandbox and live mode
access_key: access_token,
// access_key:'dp_test_XXXXXXXXX',
order_info: {
id,
customer_info: {
id: currentUser.uid,
email: currentUser.email,
},
},
onClose: function (response: any) {
console.log('closed', response)
},
onSuccess: function (response: any) {
// this happens after the payment is completed successfully
console.log("success", response);
},
onFailure: function (error: any) {
console.log("paymentFailed", error);
},
});
dpay.checkout();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment