Giter Club home page Giter Club logo

iyzipay-java's Introduction

iyzipay-java

Maven Central

You can sign up for an iyzico account at https://iyzico.com

Requirements

Java 1.8 or newer

Installation

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>com.iyzipay</groupId>
  <artifactId>iyzipay-java</artifactId>
  <version>2.0.125</version>
</dependency>

Gradle users

Add this dependency to your project's build file:

compile "com.iyzipay:iyzipay-java:2.0.125"

Others

You'll need to manually install the following JARs:

If you want to run samples you'll need to manually install Junit JAR:

Build

If you don't have Maven installed in your local environment, you can use Maven Wrapper script:

./mvnw clean install

Usage

Options options = new Options();
options.setApiKey("your api key");
options.setSecretKey("your secret key");
options.setBaseUrl("https://sandbox-api.iyzipay.com");

CreatePaymentRequest request = new CreatePaymentRequest();
request.setLocale(Locale.TR.getValue());
request.setConversationId("123456789");
request.setPrice(new BigDecimal("1"));
request.setPaidPrice(new BigDecimal("1.2"));
request.setCurrency(Currency.TRY.name());
request.setInstallment(1);
request.setBasketId("B67832");
request.setPaymentChannel(PaymentChannel.WEB.name());
request.setPaymentGroup(PaymentGroup.PRODUCT.name());

PaymentCard paymentCard = new PaymentCard();
paymentCard.setCardHolderName("John Doe");
paymentCard.setCardNumber("5528790000000008");
paymentCard.setExpireMonth("12");
paymentCard.setExpireYear("2030");
paymentCard.setCvc("123");
paymentCard.setRegisterCard(0);
request.setPaymentCard(paymentCard);

Buyer buyer = new Buyer();
buyer.setId("BY789");
buyer.setName("John");
buyer.setSurname("Doe");
buyer.setGsmNumber("+905350000000");
buyer.setEmail("[email protected]");
buyer.setIdentityNumber("74300864791");
buyer.setLastLoginDate("2015-10-05 12:43:35");
buyer.setRegistrationDate("2013-04-21 15:12:09");
buyer.setRegistrationAddress("Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1");
buyer.setIp("85.34.78.112");
buyer.setCity("Istanbul");
buyer.setCountry("Turkey");
buyer.setZipCode("34732");
request.setBuyer(buyer);

Address shippingAddress = new Address();
shippingAddress.setContactName("Jane Doe");
shippingAddress.setCity("Istanbul");
shippingAddress.setCountry("Turkey");
shippingAddress.setAddress("Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1");
shippingAddress.setZipCode("34742");
request.setShippingAddress(shippingAddress);

Address billingAddress = new Address();
billingAddress.setContactName("Jane Doe");
billingAddress.setCity("Istanbul");
billingAddress.setCountry("Turkey");
billingAddress.setAddress("Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1");
billingAddress.setZipCode("34742");
request.setBillingAddress(billingAddress);

List<BasketItem> basketItems = new ArrayList<BasketItem>();
BasketItem firstBasketItem = new BasketItem();
firstBasketItem.setId("BI101");
firstBasketItem.setName("Binocular");
firstBasketItem.setCategory1("Collectibles");
firstBasketItem.setCategory2("Accessories");
firstBasketItem.setItemType(BasketItemType.PHYSICAL.name());
firstBasketItem.setPrice(new BigDecimal("0.3"));
basketItems.add(firstBasketItem);

BasketItem secondBasketItem = new BasketItem();
secondBasketItem.setId("BI102");
secondBasketItem.setName("Game code");
secondBasketItem.setCategory1("Game");
secondBasketItem.setCategory2("Online Game Items");
secondBasketItem.setItemType(BasketItemType.VIRTUAL.name());
secondBasketItem.setPrice(new BigDecimal("0.5"));
basketItems.add(secondBasketItem);

BasketItem thirdBasketItem = new BasketItem();
thirdBasketItem.setId("BI103");
thirdBasketItem.setName("Usb");
thirdBasketItem.setCategory1("Electronics");
thirdBasketItem.setCategory2("Usb / Cable");
thirdBasketItem.setItemType(BasketItemType.PHYSICAL.name());
thirdBasketItem.setPrice(new BigDecimal("0.2"));
basketItems.add(thirdBasketItem);
request.setBasketItems(basketItems);

Payment payment = Payment.create(request, options);

See other samples under src/test/java/com/iyzipay/sample package.

Mock test cards

Test cards that can be used to simulate a successful payment:

Card Number Bank Card Type
5890040000000016 Akbank Master Card (Debit)
5526080000000006 Akbank Master Card (Credit)
4766620000000001 Denizbank Visa (Debit)
4603450000000000 Denizbank Visa (Credit)
4729150000000005 Denizbank Bonus Visa (Credit)
4987490000000002 Finansbank Visa (Debit)
5311570000000005 Finansbank Master Card (Credit)
9792020000000001 Finansbank Troy (Debit)
9792030000000000 Finansbank Troy (Credit)
5170410000000004 Garanti Bankası Master Card (Debit)
5400360000000003 Garanti Bankası Master Card (Credit)
374427000000003 Garanti Bankası American Express
4475050000000003 Halkbank Visa (Debit)
5528790000000008 Halkbank Master Card (Credit)
4059030000000009 HSBC Bank Visa (Debit)
5504720000000003 HSBC Bank Master Card (Credit)
5892830000000000 Türkiye İş Bankası Master Card (Debit)
4543590000000006 Türkiye İş Bankası Visa (Credit)
4910050000000006 Vakıfbank Visa (Debit)
4157920000000002 Vakıfbank Visa (Credit)
5168880000000002 Yapı ve Kredi Bankası Master Card (Debit)
5451030000000000 Yapı ve Kredi Bankası Master Card (Credit)

Cross border test cards:

Card Number Country
4054180000000007 Non-Turkish (Debit)
5400010000000004 Non-Turkish (Credit)

Loyalty test cards:

Card Number Card Family
5549607159333771 Bonus
5451030000000000 World

Test cards to get specific error codes:

Card Number Description
5406670000000009 Success but cannot be cancelled, refund or post auth
4111111111111129 Not sufficient funds
4129111111111111 Do not honour
4128111111111112 Invalid transaction
4127111111111113 Lost card
4126111111111114 Stolen card
4125111111111115 Expired card
4124111111111116 Invalid cvc2
4123111111111117 Not permitted to card holder
4122111111111118 Not permitted to terminal
4121111111111119 Fraud suspect
4130111111111118 General error
4131111111111117 Success but mdStatus is 0
4141111111111115 Success but mdStatus is 4
4151111111111112 3dsecure initialize failed
4151111111111393 Restricted for online transactions

Testing

If you have Maven installed, you can run particular sample by passing -Dtest=Class#method. For example:

mvn test -Dtest=PaymentSample -DbaseUrl=https://sandbox-api.iyzipay.com -DapiKey=yourApiKey -DsecretKey=yourSecretKey
mvn test -Dtest=PaymentSample#should_create_payment -DbaseUrl=https://sandbox-api.iyzipay.com -DapiKey=yourApiKey -DsecretKey=yourSecretKey

If you don't have Maven installed, you can also run:

./mvnw test -Dtest=PaymentSample -DbaseUrl=https://sandbox-api.iyzipay.com -DapiKey=yourApiKey -DsecretKey=yourSecretKey
./mvnw test -Dtest=PaymentSample#should_create_payment -DbaseUrl=https://sandbox-api.iyzipay.com -DapiKey=yourApiKey -DsecretKey=yourSecretKey

Mock APM Accounts

Mock APM Accounts that can be used to simulate a payment with alternative payment method:

Account Holder Name Description
success Succeeded payment after succeeded initialize
fail-after-init Failed payment after succeeded initialize
error Failed initialize

Testing

If you have Maven installed, you can run particular sample by passing -Dtest=Class#method. For example:

mvn test -Dtest=ApmSample -DbaseUrl=https://sandbox-api.iyzipay.com -DapiKey=yourApiKey -DsecretKey=yourSecretKey
mvn test -Dtest=ApmSample#should_initialize_apm_payment -DbaseUrl=https://sandbox-api.iyzipay.com -DapiKey=yourApiKey -DsecretKey=yourSecretKey

If you don't have Maven installed, you can also run:

./mvnw test -Dtest=ApmSample -DbaseUrl=https://sandbox-api.iyzipay.com -DapiKey=yourApiKey -DsecretKey=yourSecretKey
./mvnw test -Dtest=ApmSample#should_initialize_apm_payment -DbaseUrl=https://sandbox-api.iyzipay.com -DapiKey=yourApiKey -DsecretKey=yourSecretKey

iyzipay-java's People

Contributors

alicanakkus avatar aripddev avatar aydogmusb avatar caglarp avatar canpekdemir avatar dependabot[bot] avatar erdemdmr avatar gulcabuk avatar hakanas avatar hakanoklay avatar iyzico-ci avatar kadriyedogan avatar kahramani avatar kurttaylan avatar kurtulussahin avatar mersancengiz avatar mustafacantekir avatar nurettinbakkal avatar okanbisgin avatar onur1993 avatar onurcankarabulut avatar ramazangirgin avatar recaifurkan avatar ryumer avatar semihhakkioglu avatar shuetisha avatar sotuzun avatar umit avatar yildirimismail avatar yyenigun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iyzipay-java's Issues

Readme points to dependency that does not work

In the README of the current release version (v2.0.113) there is a reference to an incorrect maven dependency

<dependency>
  <groupId>com.iyzipay</groupId>
  <artifactId>iyzipay-java</artifactId>
  <version>2.0.113</version>
</dependency>

The latest version on mvnrepository is still v2.0.84. Same for the maven central reference in the README of the current release version.

[Release 2.0.85] "pom.xml" Dependency Problem

After updating dependency as 2.0.85, pom.xml throws an error, which is Missing artifact com.iyzipay:iyzipay-java:jar:2.0.85. After changing version to 2.0.84 everything works fine.

Screenshot:
error

BasicPayment.create command triggers an error in Android Java.

Exact error is: Caused by: java.lang.NoSuchMethodError: No static method encodeBase64String([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar)

I guess it's necessary to use android.util.Base64 library instead of Apache Base64. Do you have a working version of java codes provided for Android exactly? Or am I doing something wrong?

Unable to use a proxy

Hello,

I found no way to tell this api to use a proxy to reach iyzico servers.

I would like to be able to provide the proxy settings (host, port , username, password) so that the HTTPClient might be able to open a connection using the proxy

Upgrade subscription ilgili datayı içermiyor

English Below,

Selamlar,

Iyzicoya python üzerinden abonelik yükseltmesi istek attığımızda aşağıdaki formatta cevap alıyoruz.

{ "status": "success", "systemTime": 1678446184680, "data": { "referenceCode": "abcd", "parentReferenceCode": "abcd", "pricingPlanReferenceCode": "abcd", "customerReferenceCode": "abcd", "subscriptionStatus": "ACTIVE", "trialDays": 0, "createdDate": 1678446184629, "startDate": 1678446184623 } }

bu dataya iyzipay-java'daki SubscriptionOperation.upgrade metodundan gelen cevap ile erişemiyoruz. data fieldına erişim mi istenmiyor? source kodunuzu incelediğimde dataya erişmek için bir method eklememişsiniz ama o zaman fieldda neden var?
Aynı durum SubscriptionSearch'te de geçerli. Kullanıdığım sürüm 2.0.115.

İyi çalışmalar dilerim.


Hi,

We achieve the response below when sending request to Iyzico via python for subscription upgrade.

{ "status": "success", "systemTime": 1678446184680, "data": { "referenceCode": "abcd", "parentReferenceCode": "abcd", "pricingPlanReferenceCode": "abcd", "customerReferenceCode": "abcd", "subscriptionStatus": "ACTIVE", "trialDays": 0, "createdDate": 1678446184629, "startDate": 1678446184623 } }

However, we can not access this data from response of SubscriptionOperation.upgrade method. Is data field hidden? If yes, why does data field exist? This problem also occurs when using SubscriptionSearch. Used version is 2.0.115.

Good day.

CheckoutFormInitialize.create Returns Invalid Signature (geçersiz imza)

I'm getting this error when initializing CheckoutForm using the method CheckoutFormInitialize.create

status=failure
errorCode=1000
errorMessage=Invalid signature

The error appears when running under windows only, but it works fine on Linux (Ubuntu).
I've tried on different machines, different Java versions, different servers (Tomcat and Wildfly) but got the same error, it only works on Linux.

The same code worked on windows but using junit test.

javadoc generation fails with JDK 11+

Problem

The following error occurs during JavaDoc generation with JDK 11+.

Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.3:jar (attach-javadocs) on project iyzipay-java: MavenReportException: Error while generating Javadoc:
Exit code: 1 - javadoc: error - The code being documented uses modules but the packages defined in http://docs.oracle.com/javase/6/docs/api/ are in the unnamed module.

Solution

It looks like an OpenJDK bug. Check this issue. The solution is adding the following configuration as suggested in the issue.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
  <source>8</source>
</configuration>
 ...
</plugin>

notificationUrl

Could you add notificationUrl parameter to the relevant requests please?

Are there any contribute way

We are currently using iyzipay java library and we would like to help improve usage. I could not to any contact address for contribution that's why I'm wrote on here. Thank you

About the error message: "Geçersiz imza"

Hello,

I am not sure if this error is about the integration department of Iyzico, but we needed to inform you about the issue.
The code below is just copied and pasted from the Iyzico Readme.

Indeed, it works quite well when we implement it as a JUnit test. We can even see the transaction on SandBox.
But when we try it as a Spring Boot @service method; the same method returns the aforementioned error message.

We try it on a Spring Boot project and on another pure Java project and got the same result.

Could you help us, please?

Kind regards.

 void testSamplePayment() {
        Options options = new Options();
        options.setApiKey("sandbox-xxxx");
        options.setSecretKey("sandbox-xxxx");
        options.setBaseUrl("https://sandbox-api.iyzipay.com");

        CreatePaymentRequest request = new CreatePaymentRequest();
        request.setLocale(Locale.TR.getValue());
        request.setConversationId("123456789");
        request.setPrice(new BigDecimal("1"));
        request.setPaidPrice(new BigDecimal("100"));
        request.setCurrency(Currency.TRY.name());
        request.setInstallment(1);
        request.setBasketId("B67832");
        request.setPaymentChannel(PaymentChannel.WEB.name());
        request.setPaymentGroup(PaymentGroup.PRODUCT.name());

        PaymentCard paymentCard = new PaymentCard();
        paymentCard.setCardHolderName("John Doe");
        paymentCard.setCardNumber("5528790000000008");
        paymentCard.setExpireMonth("12");
        paymentCard.setExpireYear("2030");
        paymentCard.setCvc("123");
        paymentCard.setRegisterCard(0);
        request.setPaymentCard(paymentCard);

        Buyer buyer = new Buyer();
        buyer.setId("BY789");
        buyer.setName("John");
        buyer.setSurname("Doe");
        buyer.setGsmNumber("+905350000000");
        buyer.setEmail("[email protected]");
        buyer.setIdentityNumber("74300864791");
        buyer.setLastLoginDate("2015-10-05 12:43:35");
        buyer.setRegistrationDate("2013-04-21 15:12:09");
        buyer.setRegistrationAddress("Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1");
        buyer.setIp("85.34.78.112");
        buyer.setCity("Istanbul");
        buyer.setCountry("Turkey");
        buyer.setZipCode("34732");
        request.setBuyer(buyer);

        Address shippingAddress = new Address();
        shippingAddress.setContactName("Jane Doe");
        shippingAddress.setCity("Istanbul");
        shippingAddress.setCountry("Turkey");
        shippingAddress.setAddress("Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1");
        shippingAddress.setZipCode("34742");
        request.setShippingAddress(shippingAddress);

        Address billingAddress = new Address();
        billingAddress.setContactName("Jane Doe");
        billingAddress.setCity("Istanbul");
        billingAddress.setCountry("Turkey");
        billingAddress.setAddress("Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1");
        billingAddress.setZipCode("34742");
        request.setBillingAddress(billingAddress);

        List<BasketItem> basketItems = new ArrayList<BasketItem>();
        BasketItem firstBasketItem = new BasketItem();
        firstBasketItem.setId("BI101");
        firstBasketItem.setName("Binocular");
        firstBasketItem.setCategory1("Collectibles");
        firstBasketItem.setCategory2("Accessories");
        firstBasketItem.setItemType(BasketItemType.PHYSICAL.name());
        firstBasketItem.setPrice(new BigDecimal("0.3"));
        basketItems.add(firstBasketItem);

        BasketItem secondBasketItem = new BasketItem();
        secondBasketItem.setId("BI102");
        secondBasketItem.setName("Game code");
        secondBasketItem.setCategory1("Game");
        secondBasketItem.setCategory2("Online Game Items");
        secondBasketItem.setItemType(BasketItemType.VIRTUAL.name());
        secondBasketItem.setPrice(new BigDecimal("0.5"));
        basketItems.add(secondBasketItem);

        BasketItem thirdBasketItem = new BasketItem();
        thirdBasketItem.setId("BI103");
        thirdBasketItem.setName("Usb");
        thirdBasketItem.setCategory1("Electronics");
        thirdBasketItem.setCategory2("Usb / Cable");
        thirdBasketItem.setItemType(BasketItemType.PHYSICAL.name());
        thirdBasketItem.setPrice(new BigDecimal("0.2"));
        basketItems.add(thirdBasketItem);
        request.setBasketItems(basketItems);

        Payment payment = Payment.create(request, options);
    }

java.xml.bind module does no longer exist with Java 11. FileBase64Encoder has reference!

Edit:

Thanks to the @kuscan for his suggestion. The problem can be removed by introducing "javax.xml.bind:jaxb-api" dependency so that the source code will not need to be modified.

Problem:

java.xml.bind module does no longer exists for Java 11+.
However, com.iyzipay.FileBase64Encoder class has a reference to this module.
Since Java 1.7+ is supported in this repository, that reference causes a compilation problem for Java 11+.

See Java 11 Release Notes. Search for ''JAXB".

Solution:

Suggestion 1:

java.util.Base64 class was introduced with Java 1.8. It is a self-contained class. Its OpenJDK implementation may be directly copied into the repository since we cannot refer to this class in Java 1.7.~~

Suggestion 2:

Apache Common Codec API lets such a conversion. A new dependency may be introduced to overcome the problem.

Suggestion 3: (@kuscan )

By introducing dependency to javax.xml.bind module and using it's JAXP API. Requires no modification on the source code.

Resolution:

@yyenigun which approach would be better or do you have a better suggestion? I will open a PR once we determine the approach. Thanks.

Invalid signature using `commons-lang3:3.11`

Context

We are using:

  • JDK 14
  • com.iyzipay:iyzipay-java:2.0.69

Case

We updated our org.apache.commons:commons-lang3 from 3.10 to 3.11 and now are facing:

status=failure
errorCode=1000
errorMessage=Invalid signature

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.