Coder Social home page Coder Social logo

Comments (6)

tnmendex avatar tnmendex commented on August 16, 2024

Hello, i already found out how to make this


$tra = $gateway->updateCustomer(array('customerReference' => $clientID, 'card' => $formData));
        $response = $tra->send();

        if ($response->isSuccessful()) {
            echo $response->getCustomerReference()." ___ ".$response->getCardReference();
            return $response->getCardReference();
        } else {
            echo $response->getMessage(); //failed
        }
        return null;

But the problem now is that getCardReference() is giving the customer reference

echo $response->getCustomerReference()." ___ ".$response->getCardReference();
//cus_80wgOIqnxL5VvB ___ cus_80wgOIqnxL5VvB

from omnipay-stripe.

delatbabel avatar delatbabel commented on August 16, 2024

This is what works for me and I believe to be the correct flow:

    $response = $gateway->createCustomer(array(
        'description'       => 'Test Customer',
        'email'             => '[email protected]',
    ))->send();
    if ($response->isSuccessful()) {
        echo "Gateway createCustomer was successful.\n";

        // Find the card ID
        echo "\nfetch customer ID\n=================\n";
        $customer_id = $response->getCustomerReference();
        echo "Customer ID = " . $customer_id . "\n";

    } else {
        echo "Gateway createCustomer failed.\n";
        echo "Error message == " . $response->getMessage() . "\n";
    }

The createCard request now follows the above call. You do not need to call updateCustomer() to add a card to a customer, instead you should use createCard()

Note that this is just a cut and paste from the code in the CreateCardRequest class docblock, it's all documented there.

    $new_card = new CreditCard(array(
             'firstName'    => 'Example',
             'lastName'     => 'Customer',
             'number'       => '5555555555554444',
             'expiryMonth'  => '01',
             'expiryYear'   => '2020',
             'cvv'          => '456',
             'email'                 => '[email protected]',
             'billingAddress1'       => '1 Lower Creek Road',
             'billingCountry'        => 'AU',
             'billingCity'           => 'Upper Swan',
             'billingPostcode'       => '6999',
             'billingState'          => 'WA',
 ));

 // Do a create card transaction on the gateway
 $response = $gateway->createCard(array(
     'card'              => $new_card,
     'customerReference' => $customer_id,
 ))->send();
 if ($response->isSuccessful()) {
     echo "Gateway createCard was successful.\n";
     // Find the card ID
     $card_id = $response->getCardReference();
     echo "Card ID = " . $card_id . "\n";
 }

from omnipay-stripe.

tnmendex avatar tnmendex commented on August 16, 2024

Its not working also by this way.

$formInputData = array(
                'number' => $formData['number'],
                'expiryMonth' => $formData['expiry_month'],
                'expiryYear' => $formData['expiry_year'],
                'cvv' => $formData['cvv'],
            );
            $new_card = new CreditCard($formInputData);

            $response = $gateway->createCard(array(
                'card'              => $new_card,
                'customerReference' => $clientID,
            ))->send();

What stripe revived


    source:
        object: "card"
        number: "************4242"
        exp_month: "6"
        exp_year: "2019"
        cvc: "***"
        name: ""
        address_line1: ""
        address_line2: ""
        address_city: ""
        address_zip: ""
        address_state: ""
        address_country: ""
        email: ""

And this is the error

    error:
        type: "invalid_request_error"
        message: "Received unknown parameter: email"
        param: "card[email]"


from omnipay-stripe.

jlawrence-yellostudio avatar jlawrence-yellostudio commented on August 16, 2024

@delatbabel
I've just tried the full createCard example you provided and I get the error:

error: type: "invalid_request_error" message: "Received unknown parameter: email" param: "card[email]"

According to the docs: https://stripe.com/docs/api#create_card email is not a valid parameter for this call.

Omission of the email parameter in the CreditCard data does not work. Only way I've found to prevent this happening is to comment out:
$data['email'] = $card->getEmail();
on the last line of getCardData within AbstractRequest

from omnipay-stripe.

delatbabel avatar delatbabel commented on August 16, 2024

Are you sure you're running the latest code? The card[] parameters including the card[email] parameter was deprecated some versions ago.

Here is my card data as an example:

$card = new CreditCard(array(
    'firstName'             => 'Example',
    'lastName'              => 'Customer',
    'number'                => '4242424242424242',
    'expiryMonth'           => '01',
    'expiryYear'            => '2020',
    'cvv'                   => '123',
    'email'                 => '[email protected]',
    'billingAddress1'       => '1 Scrubby Creek Road',
    'billingCountry'        => 'AU',
    'billingCity'           => 'Scrubby Creek',
    'billingPostcode'       => '4999',
    'billingState'          => 'QLD',
));

The call to createCard works like this. Assume that $customer_id has been set by a previous call to createCustomer():

    $createCard = $gateway->createCard(array(
        'card'      => $card,
    ));
    if (! empty($customer_id)) {
        $createCard->setCustomerReference($customer_id);
    }
    $createCardData = $createCard->getData();
    echo "Gateway createCard request data == " . print_r($createCardData, true) . "\n";

The request data looks like this:

Gateway createCard request data == Array
(
    [source] => Array
        (
            [object] => card
            [number] => 4242424242424242
            [exp_month] => 1
            [exp_year] => 2020
            [cvc] => 123
            [name] => Example Customer
            [address_line1] => 1 Scrubby Creek Road
            [address_line2] => 
            [address_city] => Scrubby Creek
            [address_zip] => 4999
            [address_state] => QLD
            [address_country] => AU
            [email] => [email protected]
        )

)

There is no card parameter in the above at all, and no card[email] parameter either.

from omnipay-stripe.

CaptainQuirk avatar CaptainQuirk commented on August 16, 2024

Hi,

Facing the same issue here ! You don't have a card parameter but you have an email key in your source parameter which is basically the same.

It's reference in a fork repo's issue.

Could someone look into this ?

from omnipay-stripe.

Related Issues (20)

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.