Stripe payment gateway implementation - php

I want to validate the stripe payment gateway token id before charging customer using that token id.
Can we do this in stripe payment gateway?
Development language could be any for validating token id

There is one way to validate token, that is to retrieve token details
Check here https://stripe.com/docs/api#retrieve_token
\Stripe\Stripe::setApiKey("sk_test_*******lfQ2");
\Stripe\Token::retrieve("tok_******gxZwU");
It will throws an error if invalid token_id is passed
Hope this is helpful.

There is no API to validate a card token. Tokens are short-time lived and should be used right after it's created.
You have to use the token to ensure that the card is valid. When you create a customer via the API and pass the token as source: "tok_XXXX", Stripe will run a $0/$1 authorization on the card with the bank to make sure it's valid. Otherwise you call the Create Charge API to try and charge the card and the bank either accepts the charge or they decline it.

Related

How to validate a customer token in Braintree-Google Pay integration?

Our implementation is as follows:
Authorize a credit card associated with Google Pay. Get the nonce.
Using the nonce received, create a Customer account. Save the token for future reference.
Complete transaction using saved token.
The question is how to validate the token before starting a new transaction. Token verification is important because, transaction happens after a few days from customer creation.
Tried Braintree\CreditCard::find($token). This worked for customer accounts created with a credit card. Since we are using a nonce from Google Pay instead of Credit card, it will return a message of:
credit card with token $token not found
How to validate a token in above case?
PaymentMethod::find() will resolve the problem
Reference
https://developers.braintreepayments.com/reference/request/payment-method/find/php

Save card details while doing stripe payment

Hi i have been using stripe for the first time in my project where i ask user to provide their Credit card details for payment & i generate stripe token and charge the customer. I have provided a checkbox where customer can save the card details for future transactions & the requirement by the client is that if checkbox is checked, the details have to be saved once the payment successfully done. I am only getting the stripeToken in the processing via POST method and not the card details. Is it possible to get the card details back from the stripeToken in programming way or what can be an equivalent & convenient option to do it?
I tried adding the name attribute to the fields required by stripe for the token generation but in the form POST it is coming empty.
Stripe Only provides the Last 4 Digits of the card .
You can save the CustomerId provided by the Stripe API that can be used later for payments,
When the checkbox is checked you can use the token to create a new customer (or update if it already exist ).
Into the link of #vher2 you can find an example to follow.
EDIT:
Inside the token generated from Stripe.js do you have all the information you need. See the Example Response into Api Stripe of token creation.

Magento 2: How to change Payment Action Method on the fly in Paypal Express

I have already created Paypal/Developer/Sandbox Account. Already got API Credentials.
Downloaded PHP SDK http://paypal.github.io/PayPal-PHP-SDK/
Referring: https://developer.paypal.com/docs/api/
https://devtools-paypal.com/guide/expresscheckout/php?interactive=ON&env=sandbox
I have already done Sandbox One Transaction with Authorize Method using my PHP Script.
What i have to achieve. I need to get Authorize Payments, Convert "Authorize" payments to "Capture/Sale" Method & Notify Customer & Admin As well.
How to get Authorization Id?
By referring above document i need to use 3 Web Services
Get details of an authorized payment
Capture an authorized payment
Get details of a captured payment
Already have Transaction ID of "Authorize" Payment.
Please provide the steps to follow & if any example already available then please share
Need to integrate this functionality in Magento 2
[UPDATE]
I have changed my API Sandbox Credentials in PHP SDK in PayPal-PHP-SDK-master\sample\bootstrap.php file.
From sample/payments/AuthorizePayment.php i will get Authorized Payment with ID: PAY-0TV39791XXX02404VK7XD32I & it works fine.
When i input my Transaction Id it gives
{"name":"INVALID_RESOURCE_ID","message":"Requested resource ID was not
found.","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID","debug_id":"1f2b08ce88633"}
My Sandbox Transaction Id is 3AA32794KF48247AA. So question is how to convert your Transaction Id in to Payment Id?
https://magento.stackexchange.com/questions/138579/magento-2-change-paypal-action-method-on-the-fly
Below is the reply from Paypal
Transaction id can be generated after REST API execute payment,
Classic API [NVP/SOAP] DoEC API or normal button payment completion.
It will never work to reverse the search to find the Payment Id.
If you have paymentId, you can get details of authorized payment in this way:
$payment = Payment::get( $paymentId, $apiContext );
For all propeties of payment class take a look this - Payment.php
To change Sandbox/API Credentials edit the bootstrap.php in your project.
UPDATE
You don't need to use AuthorizePayment.php. Istead, do the following:
Create payment and get the url for authorization (your website side).
Print the url for authorization (your website side).
Cutomer follow the authorization url and go to PayPal and authorize the payment (PayPal side).
PayPal returns customer to your website with the paymentId (PayPal side).
Grab the paymentId and execute the payment (your website side).

Stripe api one customer with multiple card using php

I'm using the stripe api with php, and the basic process is as follows:
Submitted with the payment form and a stripe token is created via php stripe sdk.
If the customer exists in the local database, I grab their customer_id and fingerprint. Otherwise a new customer is created using the token as the source/card.
If the customer and same fingerprint exists in the local database, if the token object response fingerprint and my local database fingerprint different means.
I retrieve the customer details using existing customer id and I create a new card using customer source create api($customer->sources->create(array("source" => "tok_18hAe4DdoStEhOoYr2TTQlaL")); ).
Card creation time: how can I validate cvc, expmonth and year?
Yes, you can create multiple cards with a single customer in Stripe.
To validate the basic card details you can use Stripe.js library. It by default check for CVC, expiry date, and card details. A user is not allowed to enter wrong details.
If you are creating token directly from backend code then still Stripe verify the details and not return's the token in case of wrong details.
Backend and js also checking cvc length only .
Example: If i put my real card details and cvc for 123 means stripe returning the token object.

Paypal transfer money from one account to another

I am aware of this recommendation How to send money to any paypal account but what I've tried so far seems unsatisfiable to me...
I am working on a social networking site on which I want to allow users to pay for services via paypal account. The actual payment should transfer money from a user's paypal account to my paypal account.
Here is what I came up so far. I tried to use adaptive api and PAY option and it works if I use my account and my credentials to send money to some other user. I have biz account and this is known as implicit approval. If some other user wants to pay me in this way he has to have business account and to allow my app to save his credentials like his paypal userid, password and signature which is not good.
Next thing I tried is to use permissions api for that purpose. As far as I understand this should work similar to generating token that allows my app to post on facebook on behalf of user. I've managed to create a signature as specified in the permissions api documentation for the following permissions:
$permissions = array('DIRECT_PAYMENT', 'MASS_PAY', 'TRANSACTION_DETAILS');
And now I don't know how to use this signature to transfer money to my paypal account from the paypal account that granted my app the above mentioned permissions.
Any suggestion on what I am doing wrong or better way to do this?
Um, correct me if I'm wrong here, but what you propose is a fairly regular checkout flow with one buyer and one seller (recipient).
You can use PayPal Express Checkout for this and simply set NOSHIPPING=2, which will turn shipping address collection off.
Alternatively, if you have a US PayPal account, sign up for PayPal Express Checkout for Digital Goods at https://www.paypal.com/digitalgoods and you'll be able to use a fancy JavaScript-based LightBox checkout experience (also referred to as 'inline checkout').
Express Checkout is fairly in that it only requires a minimum of two API calls; SetExpressCheckout and DoExpressCheckoutPayment.
SEND: SetExpressCheckout and supply a RETURNURL, CANCELURL, AMT (amount to be charged) and your API credentials.
RECEIVE: You'll receive a TOKEN back from PayPal. Append this token to the following link: https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-XXXXXX (where EC-XXXXX is your token).
Once the buyer agrees to the payment, he'll be redirected back to your RETURNURL, after which you can either automatically, or after showing a purchase summary, call DoExpressCheckoutPayment. Supply the TOKEN again and include the PayerID (returned in GET appended to RETURNURL, or available by calling GetExpressCheckoutDetails with the TOKEN).
Once DoExpressCheckoutPayment acknowledges with ACK=Success, the funds will have been transferred from the buyerÅ› PayPal account balance and/or card.
Take a look at https://www.x.com/ > Dev Tools as well for further documentation, sample code and their SDK's

Categories