|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Globalization; |
| 4 | + |
| 5 | +using CyberSource.Api; |
| 6 | +using CyberSource.Model; |
| 7 | + |
| 8 | +namespace Cybersource_rest_samples_dotnet.Samples.Payments |
| 9 | +{ |
| 10 | + public class AuthorizationUsingBluefinPCIP2PEForCardPresentEnabledAcquirer |
| 11 | + { |
| 12 | + public static PtsV2PaymentsPost201Response Run() |
| 13 | + { |
| 14 | + string clientReferenceInformationCode = "demomerchant"; |
| 15 | + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( |
| 16 | + Code: clientReferenceInformationCode |
| 17 | + ); |
| 18 | + |
| 19 | + bool processingInformationCapture = false; |
| 20 | + string processingInformationCommerceIndicator = "retail"; |
| 21 | + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( |
| 22 | + Capture: processingInformationCapture, |
| 23 | + CommerceIndicator: processingInformationCommerceIndicator |
| 24 | + ); |
| 25 | + |
| 26 | + string paymentInformationCardExpirationMonth = "12"; |
| 27 | + string paymentInformationCardExpirationYear = "2050"; |
| 28 | + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( |
| 29 | + ExpirationMonth: paymentInformationCardExpirationMonth, |
| 30 | + ExpirationYear: paymentInformationCardExpirationYear |
| 31 | + ); |
| 32 | + |
| 33 | + string paymentInformationFluidDataDescriptor = "Ymx1ZWZpbg=="; |
| 34 | + string paymentInformationFluidDataValue = "02d700801f3c20008383252a363031312a2a2a2a2a2a2a2a303030395e46444d53202020202020202020202020202020202020202020205e323231322a2a2a2a2a2a2a2a3f2a3b363031312a2a2a2a2a2a2a2a303030393d323231322a2a2a2a2a2a2a2a3f2a7a75ad15d25217290c54b3d9d1c3868602136c68d339d52d98423391f3e631511d548fff08b414feac9ff6c6dede8fb09bae870e4e32f6f462d6a75fa0a178c3bd18d0d3ade21bc7a0ea687a2eef64551751e502d97cb98dc53ea55162cdfa395431323439323830303762994901000001a000731a8003"; |
| 35 | + Ptsv2paymentsPaymentInformationFluidData paymentInformationFluidData = new Ptsv2paymentsPaymentInformationFluidData( |
| 36 | + Descriptor: paymentInformationFluidDataDescriptor, |
| 37 | + Value: paymentInformationFluidDataValue |
| 38 | + ); |
| 39 | + |
| 40 | + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( |
| 41 | + Card: paymentInformationCard, |
| 42 | + FluidData: paymentInformationFluidData |
| 43 | + ); |
| 44 | + |
| 45 | + string orderInformationAmountDetailsTotalAmount = "100.00"; |
| 46 | + string orderInformationAmountDetailsCurrency = "USD"; |
| 47 | + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( |
| 48 | + TotalAmount: orderInformationAmountDetailsTotalAmount, |
| 49 | + Currency: orderInformationAmountDetailsCurrency |
| 50 | + ); |
| 51 | + |
| 52 | + string orderInformationBillToFirstName = "John"; |
| 53 | + string orderInformationBillToLastName = "Deo"; |
| 54 | + string orderInformationBillToAddress1 = "201 S. Division St."; |
| 55 | + string orderInformationBillToLocality = "Ann Arbor"; |
| 56 | + string orderInformationBillToAdministrativeArea = "MI"; |
| 57 | + string orderInformationBillToPostalCode = "48104-2201"; |
| 58 | + string orderInformationBillToCountry = "US"; |
| 59 | + string orderInformationBillToDistrict = "MI"; |
| 60 | + string orderInformationBillToEmail = "[email protected]"; |
| 61 | + string orderInformationBillToPhoneNumber = "999999999"; |
| 62 | + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( |
| 63 | + FirstName: orderInformationBillToFirstName, |
| 64 | + LastName: orderInformationBillToLastName, |
| 65 | + Address1: orderInformationBillToAddress1, |
| 66 | + Locality: orderInformationBillToLocality, |
| 67 | + AdministrativeArea: orderInformationBillToAdministrativeArea, |
| 68 | + PostalCode: orderInformationBillToPostalCode, |
| 69 | + Country: orderInformationBillToCountry, |
| 70 | + District: orderInformationBillToDistrict, |
| 71 | + Email: orderInformationBillToEmail, |
| 72 | + PhoneNumber: orderInformationBillToPhoneNumber |
| 73 | + ); |
| 74 | + |
| 75 | + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( |
| 76 | + AmountDetails: orderInformationAmountDetails, |
| 77 | + BillTo: orderInformationBillTo |
| 78 | + ); |
| 79 | + |
| 80 | + int pointOfSaleInformationCatLevel = 1; |
| 81 | + string pointOfSaleInformationEntryMode = "keyed"; |
| 82 | + int pointOfSaleInformationTerminalCapability = 2; |
| 83 | + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( |
| 84 | + CatLevel: pointOfSaleInformationCatLevel, |
| 85 | + EntryMode: pointOfSaleInformationEntryMode, |
| 86 | + TerminalCapability: pointOfSaleInformationTerminalCapability |
| 87 | + ); |
| 88 | + |
| 89 | + var requestObj = new CreatePaymentRequest( |
| 90 | + ClientReferenceInformation: clientReferenceInformation, |
| 91 | + ProcessingInformation: processingInformation, |
| 92 | + PaymentInformation: paymentInformation, |
| 93 | + OrderInformation: orderInformation, |
| 94 | + PointOfSaleInformation: pointOfSaleInformation |
| 95 | + ); |
| 96 | + |
| 97 | + try |
| 98 | + { |
| 99 | + var configDictionary = new Configuration().GetConfiguration(); |
| 100 | + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); |
| 101 | + |
| 102 | + var apiInstance = new PaymentsApi(clientConfig); |
| 103 | + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); |
| 104 | + Console.WriteLine(result); |
| 105 | + return result; |
| 106 | + } |
| 107 | + catch (Exception e) |
| 108 | + { |
| 109 | + Console.WriteLine("Exception on calling the API : " + e.Message); |
| 110 | + return null; |
| 111 | + } |
| 112 | + } |
| 113 | + } |
| 114 | +} |
0 commit comments