Skip to content

Commit

Permalink
refactor: Generate scheme qrcode for payment (#689)
Browse files Browse the repository at this point in the history
  • Loading branch information
YeungKC authored Jun 13, 2024
1 parent ca18e9d commit ff96f97
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions src/pay/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,24 @@ Pay.prototype = {
if (+amount > 0 && +amount !== +collection.unit)
return respError({ error: { code: 400 } });

const params = {
isInitialized: false,
address,
inscription,
collection,
amount,
memo,
traceId,
};

self.refreshSafePaymentInscription(params);
const qrCodeURL = `https://mixin.one${window.location.pathname}${window.location.search}`;

self.api.code.generateSchema((resp) => {
if (resp.error) return respError(resp);

const params = {
isInitialized: false,
address,
inscription,
collection,
amount,
memo,
traceId,
schemeId: resp.data.scheme_id,
};

self.refreshSafePaymentInscription(params);
}, qrCodeURL);
}, resp.data.collection_hash);
}, inscription);

Expand Down Expand Up @@ -410,8 +417,18 @@ Pay.prototype = {

refreshSafePaymentInscription: function (params) {
const self = this;
const { isInitialized, address, collection, inscription, memo, traceId } =
params;
const {
isInitialized,
address,
collection,
inscription,
memo,
traceId,
schemeId,
} = params;

const mixinURL = `mixin://mixin.one${window.location.pathname}${window.location.search}`;
const qrCodeURL = `https://mixin.one/schemes/${schemeId}`;

self.api.payment.fetchSafeTrace(function (resp) {
if (resp.error) {
Expand All @@ -430,8 +447,6 @@ Pay.prototype = {
}

const payment = resp.data;
const mixinURL = `mixin://mixin.one${window.location.pathname}${window.location.search}`;
const qrCodeURL = `https://mixin.one${window.location.pathname}${window.location.search}`;
const data = {
logoURL: blueLogo,
iconUrl: inscription.content_url,
Expand Down

0 comments on commit ff96f97

Please sign in to comment.