@paystack/checkout-js 1.20.0-dev.7 → 1.20.0-dev.9

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/checkout.js CHANGED
@@ -17237,7 +17237,55 @@ var Paystack = (function (exports) {
17237
17237
  return jsEncrypt.encrypt(toEncrypt);
17238
17238
  }
17239
17239
 
17240
+ var DESCRIPTORS = descriptors;
17241
+ var uncurryThis$1 = functionUncurryThis;
17242
+ var objectKeys = objectKeys$3;
17243
+ var toIndexedObject = toIndexedObject$8;
17244
+ var $propertyIsEnumerable = objectPropertyIsEnumerable.f;
17245
+
17246
+ var propertyIsEnumerable = uncurryThis$1($propertyIsEnumerable);
17247
+ var push = uncurryThis$1([].push);
17248
+
17249
+ // `Object.{ entries, values }` methods implementation
17250
+ var createMethod = function (TO_ENTRIES) {
17251
+ return function (it) {
17252
+ var O = toIndexedObject(it);
17253
+ var keys = objectKeys(O);
17254
+ var length = keys.length;
17255
+ var i = 0;
17256
+ var result = [];
17257
+ var key;
17258
+ while (length > i) {
17259
+ key = keys[i++];
17260
+ if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
17261
+ push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
17262
+ }
17263
+ }
17264
+ return result;
17265
+ };
17266
+ };
17267
+
17268
+ var objectToArray = {
17269
+ // `Object.entries` method
17270
+ // https://tc39.es/ecma262/#sec-object.entries
17271
+ entries: createMethod(true),
17272
+ // `Object.values` method
17273
+ // https://tc39.es/ecma262/#sec-object.values
17274
+ values: createMethod(false)
17275
+ };
17276
+
17240
17277
  var $$2 = _export;
17278
+ var $values = objectToArray.values;
17279
+
17280
+ // `Object.values` method
17281
+ // https://tc39.es/ecma262/#sec-object.values
17282
+ $$2({ target: 'Object', stat: true }, {
17283
+ values: function values(O) {
17284
+ return $values(O);
17285
+ }
17286
+ });
17287
+
17288
+ var $$1 = _export;
17241
17289
  var $find = arrayIteration.find;
17242
17290
  var addToUnscopables = addToUnscopables$3;
17243
17291
 
@@ -17249,7 +17297,7 @@ var Paystack = (function (exports) {
17249
17297
 
17250
17298
  // `Array.prototype.find` method
17251
17299
  // https://tc39.es/ecma262/#sec-array.prototype.find
17252
- $$2({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
17300
+ $$1({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
17253
17301
  find: function find(callbackfn /* , that = undefined */) {
17254
17302
  return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
17255
17303
  }
@@ -18197,54 +18245,69 @@ var Paystack = (function (exports) {
18197
18245
  creditCardType: creditCardType_1
18198
18246
  };
18199
18247
 
18200
- var DESCRIPTORS = descriptors;
18201
- var uncurryThis$1 = functionUncurryThis;
18202
- var objectKeys = objectKeys$3;
18203
- var toIndexedObject = toIndexedObject$8;
18204
- var $propertyIsEnumerable = objectPropertyIsEnumerable.f;
18205
-
18206
- var propertyIsEnumerable = uncurryThis$1($propertyIsEnumerable);
18207
- var push = uncurryThis$1([].push);
18208
-
18209
- // `Object.{ entries, values }` methods implementation
18210
- var createMethod = function (TO_ENTRIES) {
18211
- return function (it) {
18212
- var O = toIndexedObject(it);
18213
- var keys = objectKeys(O);
18214
- var length = keys.length;
18215
- var i = 0;
18216
- var result = [];
18217
- var key;
18218
- while (length > i) {
18219
- key = keys[i++];
18220
- if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
18221
- push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
18222
- }
18223
- }
18224
- return result;
18225
- };
18226
- };
18227
-
18228
- var objectToArray = {
18229
- // `Object.entries` method
18230
- // https://tc39.es/ecma262/#sec-object.entries
18231
- entries: createMethod(true),
18232
- // `Object.values` method
18233
- // https://tc39.es/ecma262/#sec-object.values
18234
- values: createMethod(false)
18235
- };
18236
-
18237
- var $$1 = _export;
18238
- var $values = objectToArray.values;
18248
+ var testCards = [{
18249
+ type: 'bank_auth',
18250
+ name: 'Bank authorization',
18251
+ number: '4084080000000409',
18252
+ cvv: '000',
18253
+ month: '01',
18254
+ year: '30'
18255
+ }, {
18256
+ type: 'success',
18257
+ name: 'Success',
18258
+ number: '4084084084084081',
18259
+ cvv: '408',
18260
+ month: '12',
18261
+ year: '30'
18262
+ }, {
18263
+ type: 'declined',
18264
+ name: 'Declined',
18265
+ number: '4084080000005408',
18266
+ cvv: '001',
18267
+ month: '12',
18268
+ year: '30'
18269
+ }, {
18270
+ type: 'pin',
18271
+ name: 'Pin only validation',
18272
+ number: '507850785078507812',
18273
+ cvv: '884',
18274
+ month: '01',
18275
+ year: '30'
18276
+ }, {
18277
+ type: 'pin+otp',
18278
+ name: 'Pin and OTP validation',
18279
+ number: '5060666666666666666',
18280
+ cvv: '123',
18281
+ month: '01',
18282
+ year: '30'
18283
+ }, {
18284
+ type: 'pin+phone+otp',
18285
+ name: 'Pin, phone and OTP validation',
18286
+ number: '507850785078507812',
18287
+ cvv: '884',
18288
+ month: '01',
18289
+ year: '30'
18290
+ }, {
18291
+ type: 'default',
18292
+ name: 'No validation',
18293
+ number: '4084084084084081',
18294
+ cvv: '408',
18295
+ month: '01',
18296
+ year: '30'
18297
+ }];
18239
18298
 
18240
- // `Object.values` method
18241
- // https://tc39.es/ecma262/#sec-object.values
18242
- $$1({ target: 'Object', stat: true }, {
18243
- values: function values(O) {
18244
- return $values(O);
18299
+ cardValidator.creditCardType.addCard({
18300
+ niceType: 'Verve',
18301
+ type: 'verve',
18302
+ patterns: [[506000, 507999], [650000, 650009]],
18303
+ gaps: [4, 8, 12, 16],
18304
+ lengths: [16, 18, 19],
18305
+ code: {
18306
+ name: 'CVV',
18307
+ size: 3
18245
18308
  }
18246
18309
  });
18247
-
18310
+ cardValidator.creditCardType.changeOrder('verve', 0);
18248
18311
  var Card$2 = {
18249
18312
  getEncryptedPin: function getEncryptedPin(pin) {
18250
18313
  return pin ? encrypt(pin) : undefined;
@@ -18325,73 +18388,15 @@ var Paystack = (function (exports) {
18325
18388
  },
18326
18389
  isExpiryValid: function isExpiryValid(value) {
18327
18390
  return Card$2.validateExpiry(value).isValid;
18391
+ },
18392
+ findTestCard: function findTestCard(cardType) {
18393
+ var type = cardType || 'default';
18394
+ return testCards.find(function (card) {
18395
+ return card.type === type;
18396
+ });
18328
18397
  }
18329
18398
  };
18330
18399
 
18331
- var testCards = [{
18332
- type: 'bank_auth',
18333
- name: 'Bank authorization',
18334
- number: '4084080000000409',
18335
- cvv: '000',
18336
- month: '01',
18337
- year: '30'
18338
- }, {
18339
- type: 'success',
18340
- name: 'Success',
18341
- number: '4084084084084081',
18342
- cvv: '408',
18343
- month: '12',
18344
- year: '30'
18345
- }, {
18346
- type: 'declined',
18347
- name: 'Declined',
18348
- number: '4084080000005408',
18349
- cvv: '001',
18350
- month: '12',
18351
- year: '30'
18352
- }, {
18353
- type: 'pin',
18354
- name: 'Pin only validation',
18355
- number: '507850785078507812',
18356
- cvv: '884',
18357
- month: '01',
18358
- year: '30'
18359
- }, {
18360
- type: 'pin+otp',
18361
- name: 'Pin and OTP validation',
18362
- number: '5060666666666666666',
18363
- cvv: '123',
18364
- month: '01',
18365
- year: '30'
18366
- }, {
18367
- type: 'pin+phone+otp',
18368
- name: 'Pin, phone and OTP validation',
18369
- number: '507850785078507812',
18370
- cvv: '884',
18371
- month: '01',
18372
- year: '30'
18373
- }, {
18374
- type: 'default',
18375
- name: 'No validation',
18376
- number: '4084084084084081',
18377
- cvv: '408',
18378
- month: '01',
18379
- year: '30'
18380
- }];
18381
-
18382
- cardValidator.creditCardType.addCard({
18383
- niceType: 'Verve',
18384
- type: 'verve',
18385
- patterns: [[506000, 507999], [650000, 650009]],
18386
- gaps: [4, 8, 12, 16],
18387
- lengths: [16, 18, 19],
18388
- code: {
18389
- name: 'CVV',
18390
- size: 3
18391
- }
18392
- });
18393
- cardValidator.creditCardType.changeOrder('verve', 0);
18394
-
18395
18400
  var Card$1 = /*#__PURE__*/function () {
18396
18401
  function Card(_ref) {
18397
18402
  var number = _ref.number,
@@ -18481,11 +18486,7 @@ var Paystack = (function (exports) {
18481
18486
  }, {
18482
18487
  key: "generateTestCard",
18483
18488
  value: function generateTestCard(cardType) {
18484
- var type = cardType || 'default';
18485
- var cardParams = testCards.find(function (card) {
18486
- return card.type === type;
18487
- });
18488
- return new Card(cardParams);
18489
+ return new Card(Card$2.findTestCard(cardType));
18489
18490
  }
18490
18491
  }]);
18491
18492
 
@@ -18669,7 +18670,7 @@ var Paystack = (function (exports) {
18669
18670
  return ChargeResponses.parse(response.data);
18670
18671
  });
18671
18672
  },
18672
- requestSavedCardsOTP: function requestSavedCardsOTP(phoneNumber) {
18673
+ sendSavedCardsOTP: function sendSavedCardsOTP(email) {
18673
18674
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
18674
18675
  var url, language, headers, _yield$axiosInstance$, data;
18675
18676
 
@@ -18677,13 +18678,15 @@ var Paystack = (function (exports) {
18677
18678
  while (1) {
18678
18679
  switch (_context.prev = _context.next) {
18679
18680
  case 0:
18680
- url = new URL("/authorize/".concat(phoneNumber), configToUse.savedCardsApiUrl).toString();
18681
+ url = new URL("/authorize", configToUse.savedCardsApiUrl).toString();
18681
18682
  language = getLanguage();
18682
18683
  headers = _objectSpread2({}, language && {
18683
18684
  'Accept-Language': language
18684
18685
  });
18685
18686
  _context.next = 5;
18686
18687
  return axiosInstance.post(url, {
18688
+ email: email
18689
+ }, {
18687
18690
  headers: headers
18688
18691
  });
18689
18692
 
@@ -19050,8 +19053,8 @@ var Paystack = (function (exports) {
19050
19053
  };
19051
19054
  return this.listenForCharge(listenerOptions, callback);
19052
19055
  },
19053
- requestSavedCardsOTP: function requestSavedCardsOTP(phoneNumber) {
19054
- return CardAPI$1.requestSavedCardsOTP(phoneNumber);
19056
+ sendSavedCardsOTP: function sendSavedCardsOTP() {
19057
+ return CardAPI$1.sendSavedCardsOTP(this.email);
19055
19058
  },
19056
19059
  addUserToSavedCards: function addUserToSavedCards(_ref4) {
19057
19060
  var phone = _ref4.phone;
@@ -20788,19 +20791,6 @@ var Paystack = (function (exports) {
20788
20791
  return Toolkit;
20789
20792
  }();
20790
20793
 
20791
- cardValidator.creditCardType.addCard({
20792
- niceType: 'Verve',
20793
- type: 'verve',
20794
- patterns: [[506000, 507999], [650000, 650009]],
20795
- gaps: [4, 8, 12, 16],
20796
- lengths: [16, 18, 19],
20797
- code: {
20798
- name: 'CVV',
20799
- size: 3
20800
- }
20801
- });
20802
- cardValidator.creditCardType.changeOrder('verve', 0);
20803
-
20804
20794
  var Card = /*#__PURE__*/function () {
20805
20795
  function Card(_ref) {
20806
20796
  var number = _ref.number,
@@ -20890,11 +20880,7 @@ var Paystack = (function (exports) {
20890
20880
  }, {
20891
20881
  key: "generateTestCard",
20892
20882
  value: function generateTestCard(cardType) {
20893
- var type = cardType || 'default';
20894
- var cardParams = testCards.find(function (card) {
20895
- return card.type === type;
20896
- });
20897
- return new Card(cardParams);
20883
+ return new Card(Card$2.findTestCard(cardType));
20898
20884
  }
20899
20885
  }]);
20900
20886
 
@@ -20925,120 +20911,7 @@ var Paystack = (function (exports) {
20925
20911
  }).then(function (response) {
20926
20912
  return ChargeResponses.parse(response.data);
20927
20913
  });
20928
- } // charge({
20929
- // clientdata,
20930
- // last4,
20931
- // pin,
20932
- // trans,
20933
- // device,
20934
- // rememberCard,
20935
- // transactionType,
20936
- // subscription,
20937
- // customFields,
20938
- // }) {
20939
- // const url = `${config.paymentBaseUrl}charge/`;
20940
- // const language = getLanguage();
20941
- // const headers = {
20942
- // 'Content-Type': 'application/x-www-form-urlencoded',
20943
- // ...(language && { 'Accept-Language': language }),
20944
- // };
20945
- // const chargeParams = {
20946
- // clientdata,
20947
- // last4,
20948
- // trans,
20949
- // device,
20950
- // offset: new Date().getTimezoneOffset(),
20951
- // remember_card: rememberCard,
20952
- // ...(transactionType && { transaction_type: transactionType }),
20953
- // ...(subscription && { subscription }),
20954
- // ...(customFields && customFields),
20955
- // };
20956
- // if (pin) {
20957
- // chargeParams.handle = pin;
20958
- // }
20959
- // const urlEncodedParams = formurlencoded(chargeParams);
20960
- // return axiosInstance
20961
- // .post(url, urlEncodedParams, { headers })
20962
- // .then((response) => ChargeResponses.parse(response.data));
20963
- // },
20964
- // resumeCardCharge({ device, accessCode, pin }) {
20965
- // const url = `${config.paymentBaseUrl}charge/resume/${accessCode}`;
20966
- // const language = getLanguage();
20967
- // const headers = {
20968
- // 'Content-Type': 'application/x-www-form-urlencoded',
20969
- // ...(language && { 'Accept-Language': language }),
20970
- // };
20971
- // const data = { device, ...(pin && { handle: pin }) };
20972
- // const urlEncodedData = formurlencoded(data);
20973
- // return axiosInstance
20974
- // .post(url, urlEncodedData, { headers })
20975
- // .then((response) => ChargeResponses.parse(response.data));
20976
- // },
20977
- // chargeRememberedCard({
20978
- // last4,
20979
- // trans,
20980
- // device,
20981
- // authorizationCode,
20982
- // cvv,
20983
- // pin,
20984
- // transactionType,
20985
- // subscription,
20986
- // }) {
20987
- // const url = `${config.paymentBaseUrl}charge/`;
20988
- // const language = getLanguage();
20989
- // const headers = {
20990
- // 'Content-Type': 'application/x-www-form-urlencoded',
20991
- // ...(language && { 'Accept-Language': language }),
20992
- // };
20993
- // const chargeParams = {
20994
- // last4,
20995
- // trans,
20996
- // device,
20997
- // cvv,
20998
- // handle: pin,
20999
- // authorization_code: authorizationCode,
21000
- // ...(transactionType && { transaction_type: transactionType }),
21001
- // ...(subscription && { subscription }),
21002
- // };
21003
- // const urlEncodedParams = formurlencoded(chargeParams);
21004
- // return axiosInstance
21005
- // .post(url, urlEncodedParams, { headers })
21006
- // .then((response) => ChargeResponses.parse(response.data));
21007
- // },
21008
- // verifyAddress({ address, city, state, zipCode, transactionId }) {
21009
- // const url = `${config.paymentBaseUrl}charge/avs`;
21010
- // const language = getLanguage();
21011
- // const headers = {
21012
- // 'Content-Type': 'application/x-www-form-urlencoded',
21013
- // ...(language && { 'Accept-Language': language }),
21014
- // };
21015
- // const data = {
21016
- // city,
21017
- // state,
21018
- // address,
21019
- // zip_code: zipCode,
21020
- // trans: transactionId,
21021
- // };
21022
- // const urlEncodedData = formurlencoded(data);
21023
- // return axiosInstance
21024
- // .post(url, urlEncodedData, { headers })
21025
- // .then((response) => ChargeResponses.parse(response.data));
21026
- // },
21027
- // forgetRememberedCard({ authorizationId, publicKey }) {
21028
- // const language = getLanguage();
21029
- // const headers = {
21030
- // Authorization: `Bearer ${publicKey}`,
21031
- // ...(language && { 'Accept-Language': language }),
21032
- // };
21033
- // const params = {
21034
- // authorization_id: authorizationId,
21035
- // };
21036
- // const url = `${config.paystackApiUrl}rememberme/forget_card`;
21037
- // return axiosInstance
21038
- // .post(url, params, { headers })
21039
- // .then((response) => ChargeResponses.parse(response.data));
21040
- // },
21041
-
20914
+ }
21042
20915
  };
21043
20916
 
21044
20917
  var paymentMethod = 'card';
@@ -21098,112 +20971,7 @@ var Paystack = (function (exports) {
21098
20971
  paymentMethod: paymentMethod
21099
20972
  };
21100
20973
  return this.listenForCharge(listenerOptions, callback);
21101
- } // rememberCard() {
21102
- // this.remember_card = true;
21103
- // },
21104
- // chargeCard(customFields = {}) {
21105
- // if (!this.card.number && this.card.pin) {
21106
- // return this.chargeCardWithPin(customFields);
21107
- // }
21108
- // return validate(this.card).then(() => {
21109
- // this.logAttempt(paymentMethod);
21110
- // const chargeParams = {
21111
- // clientdata: this.card.tokenize(),
21112
- // last4: this.card.getLast4(),
21113
- // pin: this.card.getEncryptedPin(),
21114
- // trans: this.id,
21115
- // device: this.deviceFingerprint,
21116
- // rememberCard: this.remember_card,
21117
- // transactionType: this.transactionType,
21118
- // subscription: this.subscription,
21119
- // customFields,
21120
- // };
21121
- // return CardAPI.charge(chargeParams).then((response) => {
21122
- // this.logAPIResponse(response, paymentMethod);
21123
- // return response;
21124
- // });
21125
- // });
21126
- // },
21127
-
21128
- /**
21129
- * Handles submitting a card pin after
21130
- * other card details have been previously submitted.
21131
- */
21132
- // chargeCardWithPin(customFields = {}) {
21133
- // this.logAttempt(paymentMethod);
21134
- // const chargeParams = {
21135
- // pin: encrypt(this.card.pin),
21136
- // trans: this.id,
21137
- // device: this.deviceFingerprint,
21138
- // rememberCard: this.remember_card,
21139
- // transactionType: this.transactionType,
21140
- // subscription: this.subscription,
21141
- // customFields,
21142
- // };
21143
- // return CardAPI.charge(chargeParams).then((response) => {
21144
- // this.logAPIResponse(response, paymentMethod);
21145
- // return response;
21146
- // });
21147
- // },
21148
- // chargeRememberedCard({ cvv, authorizationCode, cardLast4, pin }) {
21149
- // this.logAttempt(paymentMethod);
21150
- // const encryptedPin = encrypt(pin);
21151
- // const chargeParams = {
21152
- // authorizationCode,
21153
- // cvv,
21154
- // last4: cardLast4,
21155
- // trans: this.id,
21156
- // device: this.deviceFingerprint,
21157
- // pin: encryptedPin,
21158
- // transactionType: this.transactionType,
21159
- // subscription: this.subscription,
21160
- // };
21161
- // return CardAPI.chargeRememberedCard(chargeParams).then((response) => {
21162
- // this.logAPIResponse(response, paymentMethod);
21163
- // return response;
21164
- // });
21165
- // },
21166
- // resumeCardCharge({ accessCode, pin }) {
21167
- // const params = {
21168
- // ...(pin && { pin: encrypt(pin) }),
21169
- // accessCode,
21170
- // device: this.deviceFingerprint,
21171
- // };
21172
- // return CardAPI.resumeCardCharge(params).then((response) => {
21173
- // this.logAPIResponse(response, paymentMethod);
21174
- // return response;
21175
- // });
21176
- // },
21177
- // forgetRememberedCard(authorizationId) {
21178
- // const params = {
21179
- // authorizationId,
21180
- // publicKey: this.merchant.key,
21181
- // };
21182
- // return CardAPI.forgetRememberedCard(params).then((response) => {
21183
- // this.logAPIResponse(response, paymentMethod);
21184
- // return response;
21185
- // });
21186
- // },
21187
- // authenticateCard(token) {
21188
- // return CardAPI.authenticate(this.id, token).then((response) => {
21189
- // this.logAPIResponse(response, paymentMethod);
21190
- // return response;
21191
- // });
21192
- // },
21193
- // verifyAddress({ address, city, state, zipCode }) {
21194
- // const payload = {
21195
- // city,
21196
- // state,
21197
- // address,
21198
- // zipCode,
21199
- // transactionId: this.id,
21200
- // };
21201
- // return CardAPI.verifyAddress(payload).then((response) => {
21202
- // this.logAPIResponse(response, paymentMethod);
21203
- // return response;
21204
- // });
21205
- // },
21206
-
20974
+ }
21207
20975
  };
21208
20976
 
21209
20977
  var PreauthorizationInstance = /*#__PURE__*/function () {
@@ -21264,8 +21032,6 @@ var Paystack = (function (exports) {
21264
21032
  });
21265
21033
  },
21266
21034
  requery: function requery() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
21267
- },
21268
- reserveFunds: function reserveFunds() {// TODO: https://paystack.atlassian.net/browse/RAILS-2887
21269
21035
  }
21270
21036
  };
21271
21037