Skip to content

Commit 7383275

Browse files
authored
Merge pull request #1609 from Adyen/sdk-automation/checkout
[checkout] Code generation: update services and models
2 parents b8e6e2c + 31b4a9d commit 7383275

File tree

106 files changed

+2433
-52
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+2433
-52
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"pspReference": "PSP123456789",
3+
"response": {
4+
"body": "{\"data\": {\"tokenizeCreditCard\": {\"paymentMethod\": {\"id\": \"PAYMENT_METHOD_ID\"}}}}",
5+
"headers": {
6+
"Content-Type": "application/json"
7+
},
8+
"status": 200
9+
},
10+
"storedPaymentMethodId": "PAYMENT_METHOD_ID"
11+
}

src/__tests__/checkout.spec.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { SessionResultResponse } from "../typings/checkout/sessionResultResponse
1515
import { payments3DS2NativeAction } from "../__mocks__/checkout/payments3DS2NativeAction";
1616
import { EnvironmentEnum } from "../config";
1717
import { Types } from "..";
18+
import forwardResponse from "../__mocks__/checkout/forwardResponse.json";
1819

1920
const merchantAccount = process.env.ADYEN_MERCHANT!;
2021
const reference = "Your order number";
@@ -683,4 +684,48 @@ describe("Checkout", (): void => {
683684
expect(resultOfPaymentSessionResponse.id).toEqual("CS12345678");
684685
expect(resultOfPaymentSessionResponse.status).toEqual(SessionResultResponse.StatusEnum.Completed);
685686
});
687+
688+
test("Should forward token", async (): Promise<void> => {
689+
scope.post("/forward")
690+
.reply(200, forwardResponse);
691+
692+
const body = {
693+
amount: {
694+
value: 100,
695+
currency: "USD"
696+
},
697+
paymentMethod: {
698+
creditCard: {
699+
holderName: "{{holderName}}",
700+
number: "{{number}}",
701+
expiryMonth: "{{expiryMonth}}",
702+
expiryYear: "{{expiryYear}}"
703+
}
704+
}
705+
};
706+
707+
const checkoutForwardRequest: Types.checkout.CheckoutForwardRequest = {
708+
merchantAccount: "YOUR_MERCHANT_ACCOUNT",
709+
shopperReference: "YOUR_SHOPPER_REFERENCE",
710+
storedPaymentMethodId: "M12345677890",
711+
baseUrl: "http://thirdparty.example.com",
712+
request: {
713+
httpMethod: Types.checkout.CheckoutOutgoingForwardRequest.HttpMethodEnum.Post,
714+
urlSuffix: "/payments",
715+
credentials: "YOUR_CREDENTIALS_FOR_THE_THIRD_PARTY",
716+
headers: {
717+
"Authorization": "Basic {{credentials}}",
718+
},
719+
body: JSON.stringify(body),
720+
}
721+
};
722+
723+
const response: Types.checkout.CheckoutForwardResponse = await checkoutService.RecurringApi.forward(checkoutForwardRequest);
724+
725+
expect(response.pspReference).toEqual("PSP123456789");
726+
expect(response.storedPaymentMethodId).toEqual("PAYMENT_METHOD_ID");
727+
expect(response.response).toBeDefined();
728+
expect(response.response.status).toEqual(200);
729+
expect(response.response.body).toContain("PAYMENT_METHOD_ID");
730+
});
686731
});

src/services/checkout/recurringApi.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { IRequest } from "../../typings/requestOptions";
1515
import Resource from "../resource";
1616

1717
import { ObjectSerializer } from "../../typings/checkout/objectSerializer";
18+
import { CheckoutForwardRequest } from "../../typings/checkout/models";
19+
import { CheckoutForwardResponse } from "../../typings/checkout/models";
1820
import { ListStoredPaymentMethodsResponse } from "../../typings/checkout/models";
1921
import { StoredPaymentMethodRequest } from "../../typings/checkout/models";
2022
import { StoredPaymentMethodResource } from "../../typings/checkout/models";
@@ -58,6 +60,26 @@ export class RecurringApi extends Service {
5860
);
5961
}
6062

63+
/**
64+
* @summary Forward stored payment details
65+
* @param checkoutForwardRequest {@link CheckoutForwardRequest }
66+
* @param requestOptions {@link IRequest.Options }
67+
* @return {@link CheckoutForwardResponse }
68+
*/
69+
public async forward(checkoutForwardRequest: CheckoutForwardRequest, requestOptions?: IRequest.Options): Promise<CheckoutForwardResponse> {
70+
const endpoint = `${this.baseUrl}/forward`;
71+
const resource = new Resource(this, endpoint);
72+
73+
const request: CheckoutForwardRequest = ObjectSerializer.serialize(checkoutForwardRequest, "CheckoutForwardRequest");
74+
const response = await getJsonResponse<CheckoutForwardRequest, CheckoutForwardResponse>(
75+
resource,
76+
request,
77+
{ ...requestOptions, method: "POST" }
78+
);
79+
80+
return ObjectSerializer.deserialize(response, "CheckoutForwardResponse");
81+
}
82+
6183
/**
6284
* @summary Get tokens for stored payment details
6385
* @param requestOptions {@link IRequest.Options }

src/typings/checkout/achDetails.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export class AchDetails {
4949
*/
5050
"recurringDetailReference"?: string;
5151
/**
52+
* Base64-encoded JSON object containing SDK related parameters required by the SDK
53+
*/
54+
"sdkData"?: string;
55+
/**
5256
* This is the `recurringDetailReference` returned in the response when you created the token.
5357
*/
5458
"storedPaymentMethodId"?: string;
@@ -120,6 +124,12 @@ export class AchDetails {
120124
"type": "string",
121125
"format": ""
122126
},
127+
{
128+
"name": "sdkData",
129+
"baseName": "sdkData",
130+
"type": "string",
131+
"format": ""
132+
},
123133
{
124134
"name": "storedPaymentMethodId",
125135
"baseName": "storedPaymentMethodId",

src/typings/checkout/additionalDataLevel23.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class AdditionalDataLevel23 {
3434
*/
3535
"enhancedSchemeData_freightAmount"?: string;
3636
/**
37-
* The code that identifies the item in a standardized commodity coding scheme. There are different commodity coding schemes: * [UNSPSC commodity codes](https://www.unspsc.org/) * [HS commodity codes](https://www.wcoomd.org/en/topics/nomenclature/overview.aspx) * [NAICS commodity codes](https://www.census.gov/naics/) * [NAPCS commodity codes](https://www.census.gov/naics/napcs/) * Encoding: ASCII * Max length: 12 characters * Must not start with a space or be all spaces. * Must not be all zeros.
37+
* The code that identifies the item in a standardized commodity coding scheme. There are different commodity coding schemes: * [UNSPSC commodity codes](https://www.ungm.org/public/unspsc) * [HS commodity codes](https://www.wcoomd.org/en/topics/nomenclature/overview.aspx) * [NAICS commodity codes](https://www.census.gov/naics/) * [NAPCS commodity codes](https://www.census.gov/naics/napcs/) * Encoding: ASCII * Max length: 12 characters * Must not start with a space or be all spaces. * Must not be all zeros.
3838
*/
3939
"enhancedSchemeData_itemDetailLine_itemNr_commodityCode"?: string;
4040
/**

src/typings/checkout/affirmDetails.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export class AffirmDetails {
1414
*/
1515
"checkoutAttemptId"?: string;
1616
/**
17+
* Base64-encoded JSON object containing SDK related parameters required by the SDK
18+
*/
19+
"sdkData"?: string;
20+
/**
1721
* **affirm**
1822
*/
1923
"type"?: AffirmDetails.TypeEnum;
@@ -29,6 +33,12 @@ export class AffirmDetails {
2933
"type": "string",
3034
"format": ""
3135
},
36+
{
37+
"name": "sdkData",
38+
"baseName": "sdkData",
39+
"type": "string",
40+
"format": ""
41+
},
3242
{
3343
"name": "type",
3444
"baseName": "type",

src/typings/checkout/afterpayDetails.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export class AfterpayDetails {
3333
*/
3434
"recurringDetailReference"?: string;
3535
/**
36+
* Base64-encoded JSON object containing SDK related parameters required by the SDK
37+
*/
38+
"sdkData"?: string;
39+
/**
3640
* This is the `recurringDetailReference` returned in the response when you created the token.
3741
*/
3842
"storedPaymentMethodId"?: string;
@@ -76,6 +80,12 @@ export class AfterpayDetails {
7680
"type": "string",
7781
"format": ""
7882
},
83+
{
84+
"name": "sdkData",
85+
"baseName": "sdkData",
86+
"type": "string",
87+
"format": ""
88+
},
7989
{
8090
"name": "storedPaymentMethodId",
8191
"baseName": "storedPaymentMethodId",

src/typings/checkout/amazonPayDetails.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export class AmazonPayDetails {
2222
*/
2323
"checkoutSessionId"?: string;
2424
/**
25+
* Base64-encoded JSON object containing SDK related parameters required by the SDK
26+
*/
27+
"sdkData"?: string;
28+
/**
2529
* **amazonpay**
2630
*/
2731
"type"?: AmazonPayDetails.TypeEnum;
@@ -49,6 +53,12 @@ export class AmazonPayDetails {
4953
"type": "string",
5054
"format": ""
5155
},
56+
{
57+
"name": "sdkData",
58+
"baseName": "sdkData",
59+
"type": "string",
60+
"format": ""
61+
},
5262
{
5363
"name": "type",
5464
"baseName": "type",

src/typings/checkout/amount.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
export class Amount {
1212
/**
13-
* The three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes#currency-codes).
13+
* The three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes#currency-codes) of the amount.
1414
*/
1515
"currency": string;
1616
/**
17-
* The amount of the transaction, in [minor units](https://docs.adyen.com/development-resources/currency-codes#minor-units).
17+
* The numeric value of the amount, in [minor units](https://docs.adyen.com/development-resources/currency-codes#minor-units).
1818
*/
1919
"value": number;
2020

src/typings/checkout/ancvDetails.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export class AncvDetails {
2525
*/
2626
"recurringDetailReference"?: string;
2727
/**
28+
* Base64-encoded JSON object containing SDK related parameters required by the SDK
29+
*/
30+
"sdkData"?: string;
31+
/**
2832
* This is the `recurringDetailReference` returned in the response when you created the token.
2933
*/
3034
"storedPaymentMethodId"?: string;
@@ -56,6 +60,12 @@ export class AncvDetails {
5660
"type": "string",
5761
"format": ""
5862
},
63+
{
64+
"name": "sdkData",
65+
"baseName": "sdkData",
66+
"type": "string",
67+
"format": ""
68+
},
5969
{
6070
"name": "storedPaymentMethodId",
6171
"baseName": "storedPaymentMethodId",

0 commit comments

Comments
 (0)