@eluvio/elv-client-js 4.0.35 → 4.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1126,6 +1126,71 @@ exports.ClaimItem = async function({marketplaceParams, sku, email}) {
|
|
|
1126
1126
|
});
|
|
1127
1127
|
};
|
|
1128
1128
|
|
|
1129
|
+
/**
|
|
1130
|
+
* Redirect to the wallet app to purchase the specified item from the specified marketplace
|
|
1131
|
+
*
|
|
1132
|
+
* Use the <a href="#.PurchaseStatus">PurchaseStatus</a> method to check minting status after purchasing
|
|
1133
|
+
*
|
|
1134
|
+
* @methodGroup Purchase
|
|
1135
|
+
* @namedParams
|
|
1136
|
+
* @param {Object} marketplaceParams - Parameters of the marketplace
|
|
1137
|
+
* @param {string} sku - The SKU of the item to claim
|
|
1138
|
+
* @param {string=} confirmationId - Confirmation ID with which to reference this purchase. If not specified, a confirmation ID will be automatically generated. On success, the user will be returned to `successUrl` with the `confirmationId` as a URL parameter.
|
|
1139
|
+
* @param {string} successUrl - The URL to redirect back to upon successful purchase
|
|
1140
|
+
* @param {string} cancelUrl - The URL to redirect back to upon cancellation of purchase
|
|
1141
|
+
*/
|
|
1142
|
+
exports.PurchaseItem = async function({marketplaceParams, sku, confirmationId, successUrl, cancelUrl}) {
|
|
1143
|
+
const marketplaceInfo = await this.MarketplaceInfo({marketplaceParams});
|
|
1144
|
+
|
|
1145
|
+
window.location.href = this.FlowURL({
|
|
1146
|
+
type: "action",
|
|
1147
|
+
flow: "purchase",
|
|
1148
|
+
marketplaceId: marketplaceInfo.marketplaceId,
|
|
1149
|
+
parameters: {
|
|
1150
|
+
sku,
|
|
1151
|
+
confirmationId,
|
|
1152
|
+
successUrl,
|
|
1153
|
+
cancelUrl,
|
|
1154
|
+
login: true,
|
|
1155
|
+
auth: this.ClientAuthToken(),
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
};
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* Redirect to the wallet app to purchase the specified listing
|
|
1162
|
+
*
|
|
1163
|
+
* Use the <a href="#.PurchaseStatus">ListingPurchaseStatus</a> method to check minting status after purchasing
|
|
1164
|
+
*
|
|
1165
|
+
* @methodGroup Purchase
|
|
1166
|
+
* @namedParams
|
|
1167
|
+
* @param {Object=} marketplaceParams - Parameters of the marketplace
|
|
1168
|
+
* @param {string} listingId - The SKU of the item to claim
|
|
1169
|
+
* @param {string=} confirmationId - Confirmation ID with which to reference this purchase. If not specified, a confirmation ID will be automatically generated. On success, the user will be returned to `successUrl` with the `confirmationId` as a URL parameter.
|
|
1170
|
+
* @param {string} successUrl - The URL to redirect back to upon successful purchase
|
|
1171
|
+
* @param {string} cancelUrl - The URL to redirect back to upon cancellation of purchase
|
|
1172
|
+
*/
|
|
1173
|
+
exports.PurchaseListing = async function({marketplaceParams, listingId, confirmationId, successUrl, cancelUrl}) {
|
|
1174
|
+
let marketplaceInfo;
|
|
1175
|
+
if(marketplaceParams) {
|
|
1176
|
+
marketplaceInfo = await this.MarketplaceInfo({marketplaceParams});
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
window.location.href = this.FlowURL({
|
|
1180
|
+
type: "action",
|
|
1181
|
+
flow: "purchase",
|
|
1182
|
+
marketplaceId: marketplaceInfo && marketplaceInfo.marketplaceId,
|
|
1183
|
+
parameters: {
|
|
1184
|
+
listingId,
|
|
1185
|
+
confirmationId,
|
|
1186
|
+
successUrl,
|
|
1187
|
+
cancelUrl,
|
|
1188
|
+
login: true,
|
|
1189
|
+
auth: this.ClientAuthToken(),
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1129
1194
|
/* MINTING STATUS */
|
|
1130
1195
|
|
|
1131
1196
|
/**
|
|
@@ -619,6 +619,19 @@ class ElvWalletClient {
|
|
|
619
619
|
});
|
|
620
620
|
}
|
|
621
621
|
|
|
622
|
+
FlowURL({type="flow", flow, marketplaceId, parameters={}}) {
|
|
623
|
+
const url = new URL(this.appUrl);
|
|
624
|
+
if(marketplaceId) {
|
|
625
|
+
url.hash = UrlJoin("/", type, flow, "marketplace", marketplaceId, Utils.B58(JSON.stringify(parameters)));
|
|
626
|
+
} else {
|
|
627
|
+
url.hash = UrlJoin("/", type, flow, Utils.B58(JSON.stringify(parameters)));
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
url.searchParams.set("origin", window.location.origin);
|
|
631
|
+
|
|
632
|
+
return url.toString();
|
|
633
|
+
}
|
|
634
|
+
|
|
622
635
|
|
|
623
636
|
// Internal loading methods
|
|
624
637
|
|