@paykit-sdk/paystack 1.3.0 → 1.3.1
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/dist/index.js +34 -26
- package/dist/index.mjs +35 -27
- package/dist/paystack-provider.d.mts +1 -0
- package/dist/paystack-provider.d.ts +1 -0
- package/dist/paystack-provider.js +34 -26
- package/dist/paystack-provider.mjs +35 -27
- package/dist/schema.d.mts +6 -2
- package/dist/schema.d.ts +6 -2
- package/dist/utils/mapper.js +1 -1
- package/dist/utils/mapper.mjs +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4135,7 +4135,7 @@ var Checkout$inboundSchema = (init, transaction) => {
|
|
|
4135
4135
|
return {
|
|
4136
4136
|
id: init.reference,
|
|
4137
4137
|
customer,
|
|
4138
|
-
payment_url: init.
|
|
4138
|
+
payment_url: init.authorizationUrl,
|
|
4139
4139
|
metadata: Object.keys(metadata).length > 0 ? metadata : null,
|
|
4140
4140
|
session_type: type ?? "one_time",
|
|
4141
4141
|
products: [{ id: itemId, quantity }],
|
|
@@ -4266,6 +4266,19 @@ var PaystackProvider = class extends core.AbstractPayKitProvider {
|
|
|
4266
4266
|
}
|
|
4267
4267
|
return this._toCamel(result.value.data);
|
|
4268
4268
|
}
|
|
4269
|
+
async initializeTransaction(params) {
|
|
4270
|
+
const body = {
|
|
4271
|
+
...params.providerMetadata,
|
|
4272
|
+
email: params.email,
|
|
4273
|
+
amount: params.amount,
|
|
4274
|
+
currency: params.currency.toUpperCase(),
|
|
4275
|
+
reference: crypto.randomUUID(),
|
|
4276
|
+
...params.callbackUrl && { callback_url: params.callbackUrl },
|
|
4277
|
+
metadata: core.stringifyMetadataValues(params.metadata)
|
|
4278
|
+
};
|
|
4279
|
+
const response = await this._client.post("/transaction/initialize", { body: JSON.stringify(body) });
|
|
4280
|
+
return this.unwrap(response, "initializeTransaction");
|
|
4281
|
+
}
|
|
4269
4282
|
createCheckout = async (params) => {
|
|
4270
4283
|
const { error, data } = core.createCheckoutSchema.safeParse(params);
|
|
4271
4284
|
if (error) {
|
|
@@ -4296,21 +4309,20 @@ var PaystackProvider = class extends core.AbstractPayKitProvider {
|
|
|
4296
4309
|
type: data.session_type
|
|
4297
4310
|
})
|
|
4298
4311
|
};
|
|
4299
|
-
const
|
|
4312
|
+
const parsedAmount = parseInt(amount, 10);
|
|
4313
|
+
const upperCurrency = currency.toUpperCase();
|
|
4314
|
+
const initData = await this.initializeTransaction({
|
|
4300
4315
|
email: data.customer.email,
|
|
4301
|
-
amount:
|
|
4302
|
-
currency:
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
};
|
|
4308
|
-
const response = await this._client.post("/transaction/initialize", { body: JSON.stringify(body) });
|
|
4309
|
-
const initData = await this.unwrap(response, "createCheckout");
|
|
4316
|
+
amount: parsedAmount,
|
|
4317
|
+
currency: upperCurrency,
|
|
4318
|
+
metadata,
|
|
4319
|
+
callbackUrl: data.success_url,
|
|
4320
|
+
providerMetadata: data.provider_metadata
|
|
4321
|
+
});
|
|
4310
4322
|
const rawCustomer = await this._client.get(`/customer/${encodeURIComponent(data.customer.email)}`);
|
|
4311
4323
|
return Checkout$inboundSchema(initData, {
|
|
4312
|
-
amount:
|
|
4313
|
-
currency:
|
|
4324
|
+
amount: parsedAmount,
|
|
4325
|
+
currency: upperCurrency,
|
|
4314
4326
|
customer: await this.unwrap(rawCustomer, "createCheckout"),
|
|
4315
4327
|
metadata: JSON.stringify(metadata)
|
|
4316
4328
|
});
|
|
@@ -4321,7 +4333,7 @@ var PaystackProvider = class extends core.AbstractPayKitProvider {
|
|
|
4321
4333
|
const txn = response.value.data;
|
|
4322
4334
|
return Checkout$inboundSchema(
|
|
4323
4335
|
{
|
|
4324
|
-
|
|
4336
|
+
authorizationUrl: "",
|
|
4325
4337
|
reference: txn.reference
|
|
4326
4338
|
},
|
|
4327
4339
|
txn
|
|
@@ -4517,23 +4529,19 @@ var PaystackProvider = class extends core.AbstractPayKitProvider {
|
|
|
4517
4529
|
item_id: data.item_id
|
|
4518
4530
|
})
|
|
4519
4531
|
};
|
|
4520
|
-
const reference = crypto.randomUUID();
|
|
4521
|
-
const body = {
|
|
4522
|
-
email,
|
|
4523
|
-
amount: data.amount,
|
|
4524
|
-
currency: data.currency,
|
|
4525
|
-
reference,
|
|
4526
|
-
metadata,
|
|
4527
|
-
...data.provider_metadata
|
|
4528
|
-
};
|
|
4529
4532
|
if (this.opts.debug) {
|
|
4530
4533
|
console.info("[Paystack] Initializing transaction", {
|
|
4531
4534
|
email,
|
|
4532
4535
|
amount: data.amount
|
|
4533
4536
|
});
|
|
4534
4537
|
}
|
|
4535
|
-
const
|
|
4536
|
-
|
|
4538
|
+
const initData = await this.initializeTransaction({
|
|
4539
|
+
email,
|
|
4540
|
+
amount: data.amount,
|
|
4541
|
+
currency: data.currency,
|
|
4542
|
+
metadata,
|
|
4543
|
+
providerMetadata: data.provider_metadata
|
|
4544
|
+
});
|
|
4537
4545
|
return {
|
|
4538
4546
|
id: initData.reference,
|
|
4539
4547
|
amount: data.amount,
|
|
@@ -4545,7 +4553,7 @@ var PaystackProvider = class extends core.AbstractPayKitProvider {
|
|
|
4545
4553
|
),
|
|
4546
4554
|
item_id: data.item_id ?? null,
|
|
4547
4555
|
requires_action: true,
|
|
4548
|
-
payment_url: initData.
|
|
4556
|
+
payment_url: initData.authorizationUrl
|
|
4549
4557
|
};
|
|
4550
4558
|
};
|
|
4551
4559
|
retrievePayment = async (id) => {
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { schema, AbstractPayKitProvider, HTTPClient, OperationFailedError, createCheckoutSchema, ValidationError, isEmailCustomer, InvalidTypeError, validateRequiredKeys, PAYKIT_METADATA_KEY,
|
|
1
|
+
import { schema, AbstractPayKitProvider, HTTPClient, OperationFailedError, stringifyMetadataValues, createCheckoutSchema, ValidationError, isEmailCustomer, InvalidTypeError, validateRequiredKeys, PAYKIT_METADATA_KEY, ProviderNotSupportedError, createCustomerSchema, parseCustomerName, isIdCustomer, ResourceNotFoundError, createPaymentSchema, createRefundSchema, WebhookError, paykitEvent$InboundSchema, parseJSON, Schema, omitInternalMetadata, billingModeSchema } from '@paykit-sdk/core';
|
|
2
2
|
import { createHmac, timingSafeEqual } from 'crypto';
|
|
3
3
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -4133,7 +4133,7 @@ var Checkout$inboundSchema = (init, transaction) => {
|
|
|
4133
4133
|
return {
|
|
4134
4134
|
id: init.reference,
|
|
4135
4135
|
customer,
|
|
4136
|
-
payment_url: init.
|
|
4136
|
+
payment_url: init.authorizationUrl,
|
|
4137
4137
|
metadata: Object.keys(metadata).length > 0 ? metadata : null,
|
|
4138
4138
|
session_type: type ?? "one_time",
|
|
4139
4139
|
products: [{ id: itemId, quantity }],
|
|
@@ -4264,6 +4264,19 @@ var PaystackProvider = class extends AbstractPayKitProvider {
|
|
|
4264
4264
|
}
|
|
4265
4265
|
return this._toCamel(result.value.data);
|
|
4266
4266
|
}
|
|
4267
|
+
async initializeTransaction(params) {
|
|
4268
|
+
const body = {
|
|
4269
|
+
...params.providerMetadata,
|
|
4270
|
+
email: params.email,
|
|
4271
|
+
amount: params.amount,
|
|
4272
|
+
currency: params.currency.toUpperCase(),
|
|
4273
|
+
reference: crypto.randomUUID(),
|
|
4274
|
+
...params.callbackUrl && { callback_url: params.callbackUrl },
|
|
4275
|
+
metadata: stringifyMetadataValues(params.metadata)
|
|
4276
|
+
};
|
|
4277
|
+
const response = await this._client.post("/transaction/initialize", { body: JSON.stringify(body) });
|
|
4278
|
+
return this.unwrap(response, "initializeTransaction");
|
|
4279
|
+
}
|
|
4267
4280
|
createCheckout = async (params) => {
|
|
4268
4281
|
const { error, data } = createCheckoutSchema.safeParse(params);
|
|
4269
4282
|
if (error) {
|
|
@@ -4294,21 +4307,20 @@ var PaystackProvider = class extends AbstractPayKitProvider {
|
|
|
4294
4307
|
type: data.session_type
|
|
4295
4308
|
})
|
|
4296
4309
|
};
|
|
4297
|
-
const
|
|
4310
|
+
const parsedAmount = parseInt(amount, 10);
|
|
4311
|
+
const upperCurrency = currency.toUpperCase();
|
|
4312
|
+
const initData = await this.initializeTransaction({
|
|
4298
4313
|
email: data.customer.email,
|
|
4299
|
-
amount:
|
|
4300
|
-
currency:
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
};
|
|
4306
|
-
const response = await this._client.post("/transaction/initialize", { body: JSON.stringify(body) });
|
|
4307
|
-
const initData = await this.unwrap(response, "createCheckout");
|
|
4314
|
+
amount: parsedAmount,
|
|
4315
|
+
currency: upperCurrency,
|
|
4316
|
+
metadata,
|
|
4317
|
+
callbackUrl: data.success_url,
|
|
4318
|
+
providerMetadata: data.provider_metadata
|
|
4319
|
+
});
|
|
4308
4320
|
const rawCustomer = await this._client.get(`/customer/${encodeURIComponent(data.customer.email)}`);
|
|
4309
4321
|
return Checkout$inboundSchema(initData, {
|
|
4310
|
-
amount:
|
|
4311
|
-
currency:
|
|
4322
|
+
amount: parsedAmount,
|
|
4323
|
+
currency: upperCurrency,
|
|
4312
4324
|
customer: await this.unwrap(rawCustomer, "createCheckout"),
|
|
4313
4325
|
metadata: JSON.stringify(metadata)
|
|
4314
4326
|
});
|
|
@@ -4319,7 +4331,7 @@ var PaystackProvider = class extends AbstractPayKitProvider {
|
|
|
4319
4331
|
const txn = response.value.data;
|
|
4320
4332
|
return Checkout$inboundSchema(
|
|
4321
4333
|
{
|
|
4322
|
-
|
|
4334
|
+
authorizationUrl: "",
|
|
4323
4335
|
reference: txn.reference
|
|
4324
4336
|
},
|
|
4325
4337
|
txn
|
|
@@ -4515,23 +4527,19 @@ var PaystackProvider = class extends AbstractPayKitProvider {
|
|
|
4515
4527
|
item_id: data.item_id
|
|
4516
4528
|
})
|
|
4517
4529
|
};
|
|
4518
|
-
const reference = crypto.randomUUID();
|
|
4519
|
-
const body = {
|
|
4520
|
-
email,
|
|
4521
|
-
amount: data.amount,
|
|
4522
|
-
currency: data.currency,
|
|
4523
|
-
reference,
|
|
4524
|
-
metadata,
|
|
4525
|
-
...data.provider_metadata
|
|
4526
|
-
};
|
|
4527
4530
|
if (this.opts.debug) {
|
|
4528
4531
|
console.info("[Paystack] Initializing transaction", {
|
|
4529
4532
|
email,
|
|
4530
4533
|
amount: data.amount
|
|
4531
4534
|
});
|
|
4532
4535
|
}
|
|
4533
|
-
const
|
|
4534
|
-
|
|
4536
|
+
const initData = await this.initializeTransaction({
|
|
4537
|
+
email,
|
|
4538
|
+
amount: data.amount,
|
|
4539
|
+
currency: data.currency,
|
|
4540
|
+
metadata,
|
|
4541
|
+
providerMetadata: data.provider_metadata
|
|
4542
|
+
});
|
|
4535
4543
|
return {
|
|
4536
4544
|
id: initData.reference,
|
|
4537
4545
|
amount: data.amount,
|
|
@@ -4543,7 +4551,7 @@ var PaystackProvider = class extends AbstractPayKitProvider {
|
|
|
4543
4551
|
),
|
|
4544
4552
|
item_id: data.item_id ?? null,
|
|
4545
4553
|
requires_action: true,
|
|
4546
|
-
payment_url: initData.
|
|
4554
|
+
payment_url: initData.authorizationUrl
|
|
4547
4555
|
};
|
|
4548
4556
|
};
|
|
4549
4557
|
retrievePayment = async (id) => {
|
|
@@ -26,6 +26,7 @@ declare class PaystackProvider extends AbstractPayKitProvider implements PayKitP
|
|
|
26
26
|
get _native(): null;
|
|
27
27
|
private _toCamel;
|
|
28
28
|
private unwrap;
|
|
29
|
+
private initializeTransaction;
|
|
29
30
|
createCheckout: (params: CreateCheckoutSchema<PaystackMetadata["checkout"]>) => Promise<Checkout>;
|
|
30
31
|
retrieveCheckout: (id: string) => Promise<Checkout | null>;
|
|
31
32
|
updateCheckout: (_id: string, _params: UpdateCheckoutSchema<PaystackMetadata["checkout"]>) => Promise<Checkout>;
|
|
@@ -26,6 +26,7 @@ declare class PaystackProvider extends AbstractPayKitProvider implements PayKitP
|
|
|
26
26
|
get _native(): null;
|
|
27
27
|
private _toCamel;
|
|
28
28
|
private unwrap;
|
|
29
|
+
private initializeTransaction;
|
|
29
30
|
createCheckout: (params: CreateCheckoutSchema<PaystackMetadata["checkout"]>) => Promise<Checkout>;
|
|
30
31
|
retrieveCheckout: (id: string) => Promise<Checkout | null>;
|
|
31
32
|
updateCheckout: (_id: string, _params: UpdateCheckoutSchema<PaystackMetadata["checkout"]>) => Promise<Checkout>;
|
|
@@ -4135,7 +4135,7 @@ var Checkout$inboundSchema = (init, transaction) => {
|
|
|
4135
4135
|
return {
|
|
4136
4136
|
id: init.reference,
|
|
4137
4137
|
customer,
|
|
4138
|
-
payment_url: init.
|
|
4138
|
+
payment_url: init.authorizationUrl,
|
|
4139
4139
|
metadata: Object.keys(metadata).length > 0 ? metadata : null,
|
|
4140
4140
|
session_type: type ?? "one_time",
|
|
4141
4141
|
products: [{ id: itemId, quantity }],
|
|
@@ -4266,6 +4266,19 @@ var PaystackProvider = class extends core.AbstractPayKitProvider {
|
|
|
4266
4266
|
}
|
|
4267
4267
|
return this._toCamel(result.value.data);
|
|
4268
4268
|
}
|
|
4269
|
+
async initializeTransaction(params) {
|
|
4270
|
+
const body = {
|
|
4271
|
+
...params.providerMetadata,
|
|
4272
|
+
email: params.email,
|
|
4273
|
+
amount: params.amount,
|
|
4274
|
+
currency: params.currency.toUpperCase(),
|
|
4275
|
+
reference: crypto.randomUUID(),
|
|
4276
|
+
...params.callbackUrl && { callback_url: params.callbackUrl },
|
|
4277
|
+
metadata: core.stringifyMetadataValues(params.metadata)
|
|
4278
|
+
};
|
|
4279
|
+
const response = await this._client.post("/transaction/initialize", { body: JSON.stringify(body) });
|
|
4280
|
+
return this.unwrap(response, "initializeTransaction");
|
|
4281
|
+
}
|
|
4269
4282
|
createCheckout = async (params) => {
|
|
4270
4283
|
const { error, data } = core.createCheckoutSchema.safeParse(params);
|
|
4271
4284
|
if (error) {
|
|
@@ -4296,21 +4309,20 @@ var PaystackProvider = class extends core.AbstractPayKitProvider {
|
|
|
4296
4309
|
type: data.session_type
|
|
4297
4310
|
})
|
|
4298
4311
|
};
|
|
4299
|
-
const
|
|
4312
|
+
const parsedAmount = parseInt(amount, 10);
|
|
4313
|
+
const upperCurrency = currency.toUpperCase();
|
|
4314
|
+
const initData = await this.initializeTransaction({
|
|
4300
4315
|
email: data.customer.email,
|
|
4301
|
-
amount:
|
|
4302
|
-
currency:
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
};
|
|
4308
|
-
const response = await this._client.post("/transaction/initialize", { body: JSON.stringify(body) });
|
|
4309
|
-
const initData = await this.unwrap(response, "createCheckout");
|
|
4316
|
+
amount: parsedAmount,
|
|
4317
|
+
currency: upperCurrency,
|
|
4318
|
+
metadata,
|
|
4319
|
+
callbackUrl: data.success_url,
|
|
4320
|
+
providerMetadata: data.provider_metadata
|
|
4321
|
+
});
|
|
4310
4322
|
const rawCustomer = await this._client.get(`/customer/${encodeURIComponent(data.customer.email)}`);
|
|
4311
4323
|
return Checkout$inboundSchema(initData, {
|
|
4312
|
-
amount:
|
|
4313
|
-
currency:
|
|
4324
|
+
amount: parsedAmount,
|
|
4325
|
+
currency: upperCurrency,
|
|
4314
4326
|
customer: await this.unwrap(rawCustomer, "createCheckout"),
|
|
4315
4327
|
metadata: JSON.stringify(metadata)
|
|
4316
4328
|
});
|
|
@@ -4321,7 +4333,7 @@ var PaystackProvider = class extends core.AbstractPayKitProvider {
|
|
|
4321
4333
|
const txn = response.value.data;
|
|
4322
4334
|
return Checkout$inboundSchema(
|
|
4323
4335
|
{
|
|
4324
|
-
|
|
4336
|
+
authorizationUrl: "",
|
|
4325
4337
|
reference: txn.reference
|
|
4326
4338
|
},
|
|
4327
4339
|
txn
|
|
@@ -4517,23 +4529,19 @@ var PaystackProvider = class extends core.AbstractPayKitProvider {
|
|
|
4517
4529
|
item_id: data.item_id
|
|
4518
4530
|
})
|
|
4519
4531
|
};
|
|
4520
|
-
const reference = crypto.randomUUID();
|
|
4521
|
-
const body = {
|
|
4522
|
-
email,
|
|
4523
|
-
amount: data.amount,
|
|
4524
|
-
currency: data.currency,
|
|
4525
|
-
reference,
|
|
4526
|
-
metadata,
|
|
4527
|
-
...data.provider_metadata
|
|
4528
|
-
};
|
|
4529
4532
|
if (this.opts.debug) {
|
|
4530
4533
|
console.info("[Paystack] Initializing transaction", {
|
|
4531
4534
|
email,
|
|
4532
4535
|
amount: data.amount
|
|
4533
4536
|
});
|
|
4534
4537
|
}
|
|
4535
|
-
const
|
|
4536
|
-
|
|
4538
|
+
const initData = await this.initializeTransaction({
|
|
4539
|
+
email,
|
|
4540
|
+
amount: data.amount,
|
|
4541
|
+
currency: data.currency,
|
|
4542
|
+
metadata,
|
|
4543
|
+
providerMetadata: data.provider_metadata
|
|
4544
|
+
});
|
|
4537
4545
|
return {
|
|
4538
4546
|
id: initData.reference,
|
|
4539
4547
|
amount: data.amount,
|
|
@@ -4545,7 +4553,7 @@ var PaystackProvider = class extends core.AbstractPayKitProvider {
|
|
|
4545
4553
|
),
|
|
4546
4554
|
item_id: data.item_id ?? null,
|
|
4547
4555
|
requires_action: true,
|
|
4548
|
-
payment_url: initData.
|
|
4556
|
+
payment_url: initData.authorizationUrl
|
|
4549
4557
|
};
|
|
4550
4558
|
};
|
|
4551
4559
|
retrievePayment = async (id) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { schema, AbstractPayKitProvider, HTTPClient, OperationFailedError, createCheckoutSchema, ValidationError, isEmailCustomer, InvalidTypeError, validateRequiredKeys, PAYKIT_METADATA_KEY,
|
|
1
|
+
import { schema, AbstractPayKitProvider, HTTPClient, OperationFailedError, stringifyMetadataValues, createCheckoutSchema, ValidationError, isEmailCustomer, InvalidTypeError, validateRequiredKeys, PAYKIT_METADATA_KEY, ProviderNotSupportedError, createCustomerSchema, parseCustomerName, isIdCustomer, ResourceNotFoundError, createPaymentSchema, createRefundSchema, WebhookError, paykitEvent$InboundSchema, parseJSON, Schema, omitInternalMetadata, billingModeSchema } from '@paykit-sdk/core';
|
|
2
2
|
import { createHmac, timingSafeEqual } from 'crypto';
|
|
3
3
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -4133,7 +4133,7 @@ var Checkout$inboundSchema = (init, transaction) => {
|
|
|
4133
4133
|
return {
|
|
4134
4134
|
id: init.reference,
|
|
4135
4135
|
customer,
|
|
4136
|
-
payment_url: init.
|
|
4136
|
+
payment_url: init.authorizationUrl,
|
|
4137
4137
|
metadata: Object.keys(metadata).length > 0 ? metadata : null,
|
|
4138
4138
|
session_type: type ?? "one_time",
|
|
4139
4139
|
products: [{ id: itemId, quantity }],
|
|
@@ -4264,6 +4264,19 @@ var PaystackProvider = class extends AbstractPayKitProvider {
|
|
|
4264
4264
|
}
|
|
4265
4265
|
return this._toCamel(result.value.data);
|
|
4266
4266
|
}
|
|
4267
|
+
async initializeTransaction(params) {
|
|
4268
|
+
const body = {
|
|
4269
|
+
...params.providerMetadata,
|
|
4270
|
+
email: params.email,
|
|
4271
|
+
amount: params.amount,
|
|
4272
|
+
currency: params.currency.toUpperCase(),
|
|
4273
|
+
reference: crypto.randomUUID(),
|
|
4274
|
+
...params.callbackUrl && { callback_url: params.callbackUrl },
|
|
4275
|
+
metadata: stringifyMetadataValues(params.metadata)
|
|
4276
|
+
};
|
|
4277
|
+
const response = await this._client.post("/transaction/initialize", { body: JSON.stringify(body) });
|
|
4278
|
+
return this.unwrap(response, "initializeTransaction");
|
|
4279
|
+
}
|
|
4267
4280
|
createCheckout = async (params) => {
|
|
4268
4281
|
const { error, data } = createCheckoutSchema.safeParse(params);
|
|
4269
4282
|
if (error) {
|
|
@@ -4294,21 +4307,20 @@ var PaystackProvider = class extends AbstractPayKitProvider {
|
|
|
4294
4307
|
type: data.session_type
|
|
4295
4308
|
})
|
|
4296
4309
|
};
|
|
4297
|
-
const
|
|
4310
|
+
const parsedAmount = parseInt(amount, 10);
|
|
4311
|
+
const upperCurrency = currency.toUpperCase();
|
|
4312
|
+
const initData = await this.initializeTransaction({
|
|
4298
4313
|
email: data.customer.email,
|
|
4299
|
-
amount:
|
|
4300
|
-
currency:
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
};
|
|
4306
|
-
const response = await this._client.post("/transaction/initialize", { body: JSON.stringify(body) });
|
|
4307
|
-
const initData = await this.unwrap(response, "createCheckout");
|
|
4314
|
+
amount: parsedAmount,
|
|
4315
|
+
currency: upperCurrency,
|
|
4316
|
+
metadata,
|
|
4317
|
+
callbackUrl: data.success_url,
|
|
4318
|
+
providerMetadata: data.provider_metadata
|
|
4319
|
+
});
|
|
4308
4320
|
const rawCustomer = await this._client.get(`/customer/${encodeURIComponent(data.customer.email)}`);
|
|
4309
4321
|
return Checkout$inboundSchema(initData, {
|
|
4310
|
-
amount:
|
|
4311
|
-
currency:
|
|
4322
|
+
amount: parsedAmount,
|
|
4323
|
+
currency: upperCurrency,
|
|
4312
4324
|
customer: await this.unwrap(rawCustomer, "createCheckout"),
|
|
4313
4325
|
metadata: JSON.stringify(metadata)
|
|
4314
4326
|
});
|
|
@@ -4319,7 +4331,7 @@ var PaystackProvider = class extends AbstractPayKitProvider {
|
|
|
4319
4331
|
const txn = response.value.data;
|
|
4320
4332
|
return Checkout$inboundSchema(
|
|
4321
4333
|
{
|
|
4322
|
-
|
|
4334
|
+
authorizationUrl: "",
|
|
4323
4335
|
reference: txn.reference
|
|
4324
4336
|
},
|
|
4325
4337
|
txn
|
|
@@ -4515,23 +4527,19 @@ var PaystackProvider = class extends AbstractPayKitProvider {
|
|
|
4515
4527
|
item_id: data.item_id
|
|
4516
4528
|
})
|
|
4517
4529
|
};
|
|
4518
|
-
const reference = crypto.randomUUID();
|
|
4519
|
-
const body = {
|
|
4520
|
-
email,
|
|
4521
|
-
amount: data.amount,
|
|
4522
|
-
currency: data.currency,
|
|
4523
|
-
reference,
|
|
4524
|
-
metadata,
|
|
4525
|
-
...data.provider_metadata
|
|
4526
|
-
};
|
|
4527
4530
|
if (this.opts.debug) {
|
|
4528
4531
|
console.info("[Paystack] Initializing transaction", {
|
|
4529
4532
|
email,
|
|
4530
4533
|
amount: data.amount
|
|
4531
4534
|
});
|
|
4532
4535
|
}
|
|
4533
|
-
const
|
|
4534
|
-
|
|
4536
|
+
const initData = await this.initializeTransaction({
|
|
4537
|
+
email,
|
|
4538
|
+
amount: data.amount,
|
|
4539
|
+
currency: data.currency,
|
|
4540
|
+
metadata,
|
|
4541
|
+
providerMetadata: data.provider_metadata
|
|
4542
|
+
});
|
|
4535
4543
|
return {
|
|
4536
4544
|
id: initData.reference,
|
|
4537
4545
|
amount: data.amount,
|
|
@@ -4543,7 +4551,7 @@ var PaystackProvider = class extends AbstractPayKitProvider {
|
|
|
4543
4551
|
),
|
|
4544
4552
|
item_id: data.item_id ?? null,
|
|
4545
4553
|
requires_action: true,
|
|
4546
|
-
payment_url: initData.
|
|
4554
|
+
payment_url: initData.authorizationUrl
|
|
4547
4555
|
};
|
|
4548
4556
|
};
|
|
4549
4557
|
retrievePayment = async (id) => {
|
package/dist/schema.d.mts
CHANGED
|
@@ -202,15 +202,19 @@ interface PaystackTransaction {
|
|
|
202
202
|
*/
|
|
203
203
|
subaccount?: Record<string, unknown> | null;
|
|
204
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Shape as returned by `unwrap()`, i.e. *after* `_toCamel` has run on
|
|
207
|
+
* Paystack's raw (snake_case) `/transaction/initialize` response.
|
|
208
|
+
*/
|
|
205
209
|
interface PaystackInitializeResponse {
|
|
206
210
|
/**
|
|
207
211
|
* The authorization URL of the transaction
|
|
208
212
|
*/
|
|
209
|
-
|
|
213
|
+
authorizationUrl: string;
|
|
210
214
|
/**
|
|
211
215
|
* The access code of the transaction
|
|
212
216
|
*/
|
|
213
|
-
|
|
217
|
+
accessCode: string;
|
|
214
218
|
/**
|
|
215
219
|
* The reference of the transaction
|
|
216
220
|
*/
|
package/dist/schema.d.ts
CHANGED
|
@@ -202,15 +202,19 @@ interface PaystackTransaction {
|
|
|
202
202
|
*/
|
|
203
203
|
subaccount?: Record<string, unknown> | null;
|
|
204
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Shape as returned by `unwrap()`, i.e. *after* `_toCamel` has run on
|
|
207
|
+
* Paystack's raw (snake_case) `/transaction/initialize` response.
|
|
208
|
+
*/
|
|
205
209
|
interface PaystackInitializeResponse {
|
|
206
210
|
/**
|
|
207
211
|
* The authorization URL of the transaction
|
|
208
212
|
*/
|
|
209
|
-
|
|
213
|
+
authorizationUrl: string;
|
|
210
214
|
/**
|
|
211
215
|
* The access code of the transaction
|
|
212
216
|
*/
|
|
213
|
-
|
|
217
|
+
accessCode: string;
|
|
214
218
|
/**
|
|
215
219
|
* The reference of the transaction
|
|
216
220
|
*/
|
package/dist/utils/mapper.js
CHANGED
|
@@ -90,7 +90,7 @@ var Checkout$inboundSchema = (init, transaction) => {
|
|
|
90
90
|
return {
|
|
91
91
|
id: init.reference,
|
|
92
92
|
customer,
|
|
93
|
-
payment_url: init.
|
|
93
|
+
payment_url: init.authorizationUrl,
|
|
94
94
|
metadata: Object.keys(metadata).length > 0 ? metadata : null,
|
|
95
95
|
session_type: type ?? "one_time",
|
|
96
96
|
products: [{ id: itemId, quantity }],
|
package/dist/utils/mapper.mjs
CHANGED
|
@@ -88,7 +88,7 @@ var Checkout$inboundSchema = (init, transaction) => {
|
|
|
88
88
|
return {
|
|
89
89
|
id: init.reference,
|
|
90
90
|
customer,
|
|
91
|
-
payment_url: init.
|
|
91
|
+
payment_url: init.authorizationUrl,
|
|
92
92
|
metadata: Object.keys(metadata).length > 0 ? metadata : null,
|
|
93
93
|
session_type: type ?? "one_time",
|
|
94
94
|
products: [{ id: itemId, quantity }],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paykit-sdk/paystack",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Paystack provider for PayKit",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"tsup": "^8.5.0",
|
|
27
27
|
"typescript": "^5.9.2",
|
|
28
28
|
"zod": "^3.24.2",
|
|
29
|
-
"@paykit-sdk/core": "1.3.
|
|
29
|
+
"@paykit-sdk/core": "1.3.1"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|