@xyo-network/rebilly-payment-card-authorization-plugin 4.2.0 → 5.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/rebilly-payment-card-authorization-plugin",
3
- "version": "4.2.0",
3
+ "version": "5.0.1",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -28,25 +28,29 @@
28
28
  },
29
29
  "module": "dist/neutral/index.mjs",
30
30
  "types": "dist/neutral/index.d.ts",
31
+ "files": [
32
+ "dist",
33
+ "src"
34
+ ],
31
35
  "dependencies": {
32
- "@xylabs/assert": "^4.15.1",
33
- "@xylabs/axios": "^4.15.1",
34
- "@xyo-network/module-model": "^4.3.0",
35
- "@xyo-network/payload-builder": "^4.3.0",
36
- "@xyo-network/payload-model": "^4.3.0",
37
- "@xyo-network/payment-payload-plugins": "^4.2.0",
38
- "@xyo-network/rebilly-payment-payload-plugin": "^4.2.0",
39
- "@xyo-network/sentinel-abstract": "^4.3.0",
40
- "@xyo-network/sentinel-model": "^4.3.0",
41
- "axios": "^1.11.0"
36
+ "@xylabs/assert": "~5.0.7",
37
+ "@xylabs/axios": "~5.0.7",
38
+ "@xyo-network/module-model": "~5.0.2",
39
+ "@xyo-network/payload-builder": "~5.0.2",
40
+ "@xyo-network/payload-model": "~5.0.2",
41
+ "@xyo-network/payment-payload-plugins": "~5.0.1",
42
+ "@xyo-network/rebilly-payment-payload-plugin": "~5.0.1",
43
+ "@xyo-network/sentinel-abstract": "~5.0.2",
44
+ "@xyo-network/sentinel-model": "~5.0.2",
45
+ "axios": "~1.11.0"
42
46
  },
43
47
  "devDependencies": {
44
- "@xylabs/ts-scripts-yarn3": "^7.0.1",
45
- "@xylabs/tsconfig": "^7.0.1",
46
- "@xylabs/vitest-extended": "^4.15.1",
47
- "@xyo-network/boundwitness-model": "^4.3.0",
48
- "typescript": "^5.8.3",
49
- "vitest": "^3.2.4"
48
+ "@xylabs/ts-scripts-yarn3": "~7.1.0",
49
+ "@xylabs/tsconfig": "~7.1.0",
50
+ "@xylabs/vitest-extended": "~5.0.7",
51
+ "@xyo-network/boundwitness-model": "~5.0.2",
52
+ "typescript": "~5.9.2",
53
+ "vitest": "~3.2.4"
50
54
  },
51
55
  "publishConfig": {
52
56
  "access": "public"
@@ -0,0 +1,94 @@
1
+ import '@xylabs/vitest-extended'
2
+
3
+ import { assertEx } from '@xylabs/assert'
4
+ import type { BoundWitness } from '@xyo-network/boundwitness-model'
5
+ import { isBoundWitness } from '@xyo-network/boundwitness-model'
6
+ import { PayloadBuilder } from '@xyo-network/payload-builder'
7
+ import type { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins'
8
+ import { BillingAddressSchema, PaymentCardSchema } from '@xyo-network/payment-payload-plugins'
9
+ import { isRebillyPaymentAuthorizationTokenWithSources } from '@xyo-network/rebilly-payment-payload-plugin'
10
+ import {
11
+ beforeAll, describe, expect,
12
+ it,
13
+ } from 'vitest'
14
+
15
+ import { RebillyPaymentCardAuthorizationSentinelConfigSchema } from '../Config.ts'
16
+ import type { RebillyPaymentCardAuthorizationSentinelParams } from '../Params.ts'
17
+ import { RebillyPaymentCardAuthorizationSentinel } from '../Sentinel.ts'
18
+
19
+ const getTestPaymentCardRequest = (cardNumber: string, cvv: string): [PaymentCard, BillingAddress] => {
20
+ const paymentCard: PaymentCard = {
21
+ cardNumber,
22
+ cvv,
23
+ expMonth: new Date().getMonth() + 1,
24
+ expYear: new Date().getFullYear() + 1,
25
+ schema: PaymentCardSchema,
26
+ }
27
+ // https://simpsons.fandom.com/wiki/123_Fake_Street
28
+ const billingAddress: BillingAddress = {
29
+ address: '123 Fake Street',
30
+ city: 'Oak Lawn',
31
+ country: 'US',
32
+ firstName: 'Marge',
33
+ lastName: 'Simpson',
34
+ postalCode: '60453',
35
+ region: 'IL',
36
+ schema: BillingAddressSchema,
37
+ }
38
+ return [paymentCard, billingAddress]
39
+ }
40
+
41
+ describe.skipIf(!process.env.REB_PUB_APIKEY)('RebillyPaymentCardAuthorizationSentinel', () => {
42
+ const publishableApiKey = assertEx(process.env.REB_PUB_APIKEY)
43
+ assertEx(publishableApiKey.includes('sandbox'), () => 'RebillyPaymentCardAuthorizationSentinel should only be tested in sandbox environment')
44
+ const organizationId = assertEx(process.env.REB_ORGANIZATION_ID)
45
+ let sentinel: RebillyPaymentCardAuthorizationSentinel
46
+ beforeAll(async () => {
47
+ const config = {
48
+ schema: RebillyPaymentCardAuthorizationSentinelConfigSchema, synchronous: true, tasks: [],
49
+ }
50
+ const domain = 'https://api-sandbox.rebilly.com'
51
+ sentinel = await RebillyPaymentCardAuthorizationSentinel.create({
52
+ account: 'random',
53
+ config,
54
+ domain,
55
+ organizationId,
56
+ publishableApiKey,
57
+ } as RebillyPaymentCardAuthorizationSentinelParams)
58
+ })
59
+
60
+ const cases = [
61
+ ['Visa', '4111111111111111', '123'],
62
+ ['Mastercard', '5555555555554444', '123'],
63
+ ['American Express', '378282246310005', '1234'],
64
+ ['Discover', '6011111111111117', '123'],
65
+ ]
66
+ describe('report', () => {
67
+ it.each(cases)('returns created payment token for %s', async (_, pan, cvv) => {
68
+ // Arrange
69
+ const [paymentCard, billingAddress] = getTestPaymentCardRequest(pan, cvv)
70
+
71
+ // Act
72
+ const response = await sentinel.report([paymentCard, billingAddress])
73
+
74
+ // Assert
75
+ expect(response).toBeDefined()
76
+ expect(response).toBeArray()
77
+ const [bw, ...payloads] = response
78
+ expect(bw).toBeDefined()
79
+ expect(isBoundWitness(bw)).toBeTrue()
80
+ const boundWitness: BoundWitness = assertEx([bw].find(isBoundWitness))
81
+ expect(boundWitness.addresses).toContain(sentinel.address)
82
+
83
+ expect(payloads).toBeArray()
84
+ expect(payloads.length).toBeGreaterThanOrEqual(1)
85
+
86
+ const payload = payloads.find(isRebillyPaymentAuthorizationTokenWithSources)
87
+ expect(payload).toBeDefined()
88
+ const token = assertEx(payload)
89
+ expect(token.id).toBeString()
90
+ expect(token.$sources).toBeArrayOfSize(2)
91
+ expect(token.$sources).toEqual(await PayloadBuilder.dataHashes([paymentCard, billingAddress]))
92
+ })
93
+ })
94
+ })
@@ -0,0 +1,22 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`toTokenRequest > convert a payment card and billing address to a token request 1`] = `
4
+ {
5
+ "billingAddress": {
6
+ "address": "123 Fake Street",
7
+ "city": "Oak Lawn",
8
+ "country": "US",
9
+ "firstName": "Marge",
10
+ "lastName": "Simpson",
11
+ "postalCode": "60453",
12
+ "region": "IL",
13
+ },
14
+ "method": "payment-card",
15
+ "paymentInstrument": {
16
+ "cvv": "123",
17
+ "expMonth": 1,
18
+ "expYear": 3030,
19
+ "pan": "4111111111111111",
20
+ },
21
+ }
22
+ `;
@@ -0,0 +1,37 @@
1
+ import type { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins'
2
+ import { BillingAddressSchema, PaymentCardSchema } from '@xyo-network/payment-payload-plugins'
3
+ import {
4
+ describe, expect,
5
+ it,
6
+ } from 'vitest'
7
+
8
+ import { toTokenRequest } from '../toTokenRequest.ts'
9
+
10
+ describe('toTokenRequest', () => {
11
+ const cases: [PaymentCard, BillingAddress][] = [
12
+ [
13
+ {
14
+ cardNumber: '4111111111111111',
15
+ cvv: '123',
16
+ expMonth: 1,
17
+ expYear: 3030,
18
+ schema: PaymentCardSchema,
19
+ },
20
+ {
21
+ // https://simpsons.fandom.com/wiki/123_Fake_Street
22
+ address: '123 Fake Street',
23
+ city: 'Oak Lawn',
24
+ country: 'US',
25
+ firstName: 'Marge',
26
+ lastName: 'Simpson',
27
+ postalCode: '60453',
28
+ region: 'IL',
29
+ schema: BillingAddressSchema,
30
+ },
31
+ ],
32
+ ]
33
+ it.each(cases)('convert a payment card and billing address to a token request', (paymentCard, billingAddress) => {
34
+ const result = toTokenRequest(paymentCard, billingAddress)
35
+ expect(result).toMatchSnapshot()
36
+ })
37
+ })
package/typedoc.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "$schema": "https://typedoc.org/schema.json",
3
- "entryPoints": ["./src/index.ts"],
4
- "tsconfig": "./tsconfig.typedoc.json"
5
- }
package/xy.config.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
2
- const config: XyTsupConfig = {
3
- compile: {
4
- browser: {},
5
- node: {},
6
- neutral: { src: true },
7
- },
8
- }
9
-
10
- export default config