iyzico / iyzipay-php

iyzipay api php client
MIT License
301 stars 87 forks source link

Trying to subscribe. Get error: Müşterinin kartı olmalı #117

Closed FrancescoMussi closed 4 years ago

FrancescoMussi commented 4 years ago

I am testing the API endpoints.

I have successfully created a customer:

$request = new \Iyzipay\Request\Subscription\SubscriptionCreateCustomerRequest();
$request->setLocale("tr");
$request->setConversationId("1234567789");
$customer = new \Iyzipay\Model\Customer();
$customer->setName("John");
$customer->setSurname("Doe");
$customer->setGsmNumber("+905555555555");
$customer->setEmail("johndoe@iyzicotest.com");
$customer->setIdentityNumber("11111111111");
$customer->setShippingContactName("John Doe");
$customer->setShippingCity("Istanbul");
$customer->setShippingCountry("Turkey");
$customer->setShippingAddress("Uskudar Burhaniye Mahallesi iyzico A.S");
$customer->setShippingZipCode("34660");
$customer->setBillingContactName("John Doe");
$customer->setBillingCity("Istanbul");
$customer->setBillingCountry("Turkey");
$customer->setBillingAddress("Uskudar Burhaniye Mahallesi iyzico A.S");
$customer->setBillingZipCode("34660");
$request->setCustomer($customer);

$result = \Iyzipay\Model\Subscription\SubscriptionCustomer::create($request,Config::options());

I have successfully created a card:

$request = new \Iyzipay\Request\CreateCardRequest();
$request->setLocale(\Iyzipay\Model\Locale::TR);
$request->setConversationId("1234567789");
$request->setCardUserKey("aaaaaaaa");

$cardInformation = new \Iyzipay\Model\CardInformation();
$cardInformation->setCardAlias("card alias");
$cardInformation->setCardHolderName("John Doe");
$cardInformation->setCardNumber("5528790000000008");
$cardInformation->setExpireMonth("12");
$cardInformation->setExpireYear("2030");
$request->setCard($cardInformation);

# make request
$card = \Iyzipay\Model\Card::create($request, Config::options());

And I get the cardUserKey in the response.

However when I try to subscribe the customer to a plan, I get the following error:

{"status":"failure","errorCode":"42205","errorMessage":"Ucs müşteri için aktif değil.","systemTime":1580224592946}

This is the code:

$request = new \Iyzipay\Request\Subscription\SubscriptionCreateWithCustomerRequest();
$request->setConversationId("1234567789");
$request->setLocale("tr");
$request->setPricingPlanReferenceCode("09543d2f-c5bb-4c40-8476-a67ab65eb614");
$request->setSubscriptionInitialStatus("ACTIVE");
$request->setCustomerReferenceCode("5ba7d928-181c-4120-9ba0-b395d95f1828");
$result = \Iyzipay\Model\Subscription\SubscriptionCreateWithCustomer::create($request,Config::options());

The question is: How can I actually link the created card with the previously created user?

iyzico-ci commented 4 years ago

Hi Francesco,

You can create subscriptions without having a card user key.

Could you send an email to integration@iyzico.com so we can explain details.

Thanks Caner Yazıcı Client Integration Engineer M: +90(532)440 58 36 T : +90(216)599 0100 W: www.iyzico.comhttps://www.iyzico.com/

iyzi Ödeme ve Elektronik Para Hizmetleri A.Ş. Burhaniye Mahallesi Atilla Sokak No:7 Üsküdar İstanbul

[https://www.iyzico.com/blog/wp-content/uploads/2018/11/img1-1.jpg] [iyzico mobil uygulaması ile tüm alışverişlerin tek bir yerde!]https://www.iyzico.com/kendim-icin/iyzico-app?utm_source=mailimza&utm_medium=iyzicoapp&utm_content=iyzicoApp

[https://www.iyzico.com/blog/wp-content/uploads/2018/11/img3-1.jpg]https://www.facebook.com/iyzico[https://www.iyzico.com/blog/wp-content/uploads/2018/11/img4-1.jpg]https://twitter.com/iyzico_com[https://www.iyzico.com/blog/wp-content/uploads/2018/11/img5-1.jpg]https://www.instagram.com/iyzico/[https://www.iyzico.com/blog/wp-content/uploads/2018/11/img6-1.jpg]https://www.youtube.com/channel/UCk4iPbGOno3mTSWEvQ1Rk5Q[https://www.iyzico.com/blog/wp-content/uploads/2018/11/img7-1.jpg]https://plus.google.com/+Iyzico[https://www.iyzico.com/blog/wp-content/uploads/2018/11/img8-1.jpg]https://www.linkedin.com/company/iyzi-payments

Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve gizlidir. Bu mesajın muhatabı olmamanıza rağmen tarafınıza ulaşmış olması halinde mesaj içeriğinin gizliliği ve bu gizlilik yükümlülüğüne uyulması zorunluluğu tarafınız için de söz konusudur. Mesaj ve eklerinde yer alan bilgilerin doğruluğu ve güncelliği konusunda iyzi Ödeme ve Elektronik Para Hizmetleri A.Ş.'nin herhangi bir sorumluluğu bulunmamaktadır. iyzi Ödeme ve Elektronik Para Hizmetleri A.Ş. mesajin ve bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından, iyzi Ödeme ve Elektronik Para Hizmetleri A.Ş. bütünlüğünün ve gizliliğinin korunamamasından, virus içermesinden ve bilgisayar sisteminize verebileceği herhangi bir zarardan sorumlu tutulamaz.


From: Francesco Mussi notifications@github.com Sent: Tuesday, January 28, 2020 6:25 PM To: iyzico/iyzipay-php iyzipay-php@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [iyzico/iyzipay-php] Trying to subscribe. Get error: Müşterinin kartı olmalı (#117)

I am testing the API endpoints.

I have successfully created a customer:

$request = new \Iyzipay\Request\Subscription\SubscriptionCreateCustomerRequest();

$request->setLocale("tr");

$request->setConversationId("1234567789");

$customer = new \Iyzipay\Model\Customer();

$customer->setName("John");

$customer->setSurname("Doe");

$customer->setGsmNumber("+905555555555");

$customer->setEmail("johndoe@iyzicotest.com");

$customer->setIdentityNumber("11111111111");

$customer->setShippingContactName("John Doe");

$customer->setShippingCity("Istanbul");

$customer->setShippingCountry("Turkey");

$customer->setShippingAddress("Uskudar Burhaniye Mahallesi iyzico A.S");

$customer->setShippingZipCode("34660");

$customer->setBillingContactName("John Doe");

$customer->setBillingCity("Istanbul");

$customer->setBillingCountry("Turkey");

$customer->setBillingAddress("Uskudar Burhaniye Mahallesi iyzico A.S");

$customer->setBillingZipCode("34660");

$request->setCustomer($customer);

$result = \Iyzipay\Model\Subscription\SubscriptionCustomer::create($request,Config::options());

I have successfully created a card:

$request = new \Iyzipay\Request\CreateCardRequest();

$request->setLocale(\Iyzipay\Model\Locale::TR);

$request->setConversationId("1234567789");

$request->setCardUserKey("aaaaaaaa");

$cardInformation = new \Iyzipay\Model\CardInformation();

$cardInformation->setCardAlias("card alias");

$cardInformation->setCardHolderName("John Doe");

$cardInformation->setCardNumber("5528790000000008");

$cardInformation->setExpireMonth("12");

$cardInformation->setExpireYear("2030");

$request->setCard($cardInformation);

make request

$card = \Iyzipay\Model\Card::create($request, Config::options());

And I get the cardUserKey in the response.

However when I try to subscribe he customer to a plan, I get the following error:

{"status":"failure","errorCode":"42205","errorMessage":"Ucs müşteri için aktif değil.","systemTime":1580224592946}

This is the code:

$request = new \Iyzipay\Request\Subscription\SubscriptionCreateWithCustomerRequest();

$request->setConversationId("1234567789");

$request->setLocale("tr");

$request->setPricingPlanReferenceCode("09543d2f-c5bb-4c40-8476-a67ab65eb614");

$request->setSubscriptionInitialStatus("ACTIVE");

$request->setCustomerReferenceCode("5ba7d928-181c-4120-9ba0-b395d95f1828");

$result = \Iyzipay\Model\Subscription\SubscriptionCreateWithCustomer::create($request,Config::options());

The question is: How can I actually link the created card with the previously created user?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/iyzico/iyzipay-php/issues/117?email_source=notifications&email_token=AECT5YU3VKK6UUWUPIFR3T3RABE7VA5CNFSM4KMUKRLKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IJIGVMQ, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AECT5YS27PZ52ALGUHNXPJ3RABE7VANCNFSM4KMUKRLA.

frkcn commented 4 years ago

Hi @FrancescoMussi,

You need to create a card for a customer using universal card storage for a subscription. Universal card storage documentation

Default credit card storage doesn't work with a subscription. There is no sample for universal card storage creation, so personally, I would recommend for you use checkout form. It returns the checkout form as an Html in response.

FrancescoMussi commented 4 years ago

Sorry @frkcn, but I really don't get how this part should work..

The html form I get in response has some issue, like some flickering. And I really would like to have control on my HTML and js, and just send data to the Iyzypay API.

Using iyzipay-laravel the subscription part was working very smoothly:

$user->addCreditCard([
    'alias'  => 'asd',
    'number' => '5526080000000006',
    'month'  => '01',
    'year'   => '2030',
    'holder' => 'Mehmet Aydın Bahadır'
]);
$user->subscribe(IyzipayLaravel::findPlan('premium-plan'));

It was that simple. Can I ask if there would be any problem using iyzipay-laravel for subscription? Besides the fact that the repo is no longer maintaned, the API should still work right?

Follow-up question: there is any plan to restart active development on the iyzipay-laravel? That would be great. It was very nice package.

frkcn commented 4 years ago

@FrancescoMussi old iyzico-laravel package provides custom subscription with scheduled jobs. And there is no option for a new native iyzico subscription.

If you do not want to worry about recurring payments then use the new subscription. But it is only working with universal card storage and there is no scenario for your use case.

There is a sample for API usage here: https://github.com/iyzico/iyzipay-php/blob/master/samples/subscription-samples/create_subscription_api.php

Also, I am working on a new laravel package and I hope it will be released soon.

FrancescoMussi commented 4 years ago

Okay I managed to get it working with the checkout form. It was not ideal with our setup: Laravel + Vue. In the end it was a hacky implementation.

Anyway thanks for replying. If there will be soon a Laravel Package that would be great!

frkcn commented 4 years ago

Hi @FrancescoMussi ,

Finally i can tag iyzico laravel package for pre-release. If you want to test it: https://github.com/frkcn/kasiyer

FrancescoMussi commented 4 years ago

Great! Thanks for the info @frkcn