1

we are doing andriod app for our site. in site we configured paypal successfully.

in app, customer will do payments, than using paypal sdk we are getting transaction id in app. than andriod team will pass the transaction id to magento & in magento we need to validate payment.

our andriod team want an API from magento side.

by default, is there any API is there for this?

how to achieve this ?

Edit

please visit github link & search for "server for verification" using CTRL +F ,

there they mentioned we have to verify with server, i want to know how to verify with server after payment is done through app?

i saw this , what i understood is we need to create an API for validating payments done through app. how to do this ?

Edit 2

paypal team sent Request Sample as below :

$apiContext = new ApiContext(new OAuthTokenCredential(
        "<CLIENT_ID>", "<CLIENT_SECRET>"));

$payment = Payment::get('PAY-5YK922393D847794YKER7MUI', $apiContext);

they telling we have to request to PayPal using above sample code.

once we pass pay id, then PayPal will respond with full payment details.

Edit 3

paypal team gave this git hub code & they are telling i have to use whole SDK for getting payment details. i want to know how i have to use it in magento ?

Reply from Paypal team

The following explanations are based on the use case that, you've PayPal (either Express Checkout or Payment Pro) enabled in your Magento Web store, yet additionally integrating Mobile Native SDK in your client APP (rather than using the exsing Magento PayPal flow, embedded into a webview in your APP).

  1. Verifying the payment (after your Client APP got the payment-id in the response) is important for fraud prevention. Mobile APP interacts with PayPal servers independently, and you would not want to deliver the goods/service upon a mobile API response (which is easy to replicate) without server (your Magento server) verification against the actual payment contents.

  2. Apparently Magento doesn't come with this part of codes in the PayPal module and you need to implement your own, but yet you won't necessarily have to import the whole RESTful SDK just for a single payment look-up API call. Everything is based on JSON requests & JSON parsing, it works as long as you follow the PayPal RESTful payload scheme HERE, and initiate the request with curl statements.

  3. Checklist on a payment after your server obtains the details can be also found HERE.

Additional best practice for server-end implementation:

  • Store the payment-id e.g. id": "PAY-564191241M8701234KL57LXI" in your database along with the order data entry;
  • Store the debug-id in the error object (if there's an error response) from the verification (payment lookup) API response into your database for further trouble shooting purpose with PayPal support.

Sample API tests by curl commands would be like:

Step#1 - Getting access token for authentication

curl -v https://api.sandbox.paypal.com/v1/oauth2/token \
  -H "Accept: application/json" \
  -H "Accept-Language: en_US" \
  -u "<your sandbox APP client>:<your sandbox APP secret>" \
  -d "grant_type=client_credentials"

Parse the sample response and obtain the access token:

{
  "scope": "https://api.paypal.com/v1/payments/.* https://api.paypal.com/v1/vault/credit-card https://api.paypal.com/v1/vault/credit-card/.*",
  "access_token": "<Your-Access-Token-for-further-calls>",
  "token_type": "Bearer",
  "app_id": "APP-6XR95014SS315863X",
  "expires_in": 28800
}

Step#2 - Making the look-up call with the access-token and payment ID (returned by you APP, e.g. PAY-123456789)

curl https://api.sandbox.paypal.com/v1/payments/payment/PAY-123456789 \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <the access token from Step#1>"

And you'll get the response similar with this, which contains the payment details you would compare & verify with your order information in the database

{
  "proof_of_payment": {
    "adaptive_payment": {
      "pay_key": "AP-70M68096ML426802W",
      "payment_exec_status": "COMPLETED",
      "timestamp": "2013-02-20T00:26:25Z",
      "app_id": "APP-91B933855X481767M"
    }
  },
  "payment": {
    "short_description": "Hipster t-shirt",
    "amount": "9.95",
    "currency_code": "USD"
  },
  "client": {
    "platform": "iOS",
    "paypal_sdk_version": "1.0.0",
    "environment": "live",
    "product_name": "PayPal iOS SDK"
  }
}

Replay from paypal team end

when i tried above step as above , i created payment successfully.

than we need to complete payment resource with payment id using link how to do this ?

  • 1
    Need more details about the topology of the applications configuration. What android app do and how is it integrated with Magento? Does the magento processes orders and payments? – martin_mageworx May 26 '16 at 8:57
  • we created andriod app for selling products through app. in backend System/Web services- we created users and roles. we created AP username & API key using backend. using this Andriod app is getting information. in both app and site also we are selling products. please let me know if you need more clarifcations. – Baby in Magento May 26 '16 at 9:22
  • @martin_mageworx please visit github link & search for "server for verification" , there they mentioned we have to verify with server, i want this. – Baby in Magento May 26 '16 at 9:43
  • When you process payments via App do you create a linked order in Magento, i.e. using this method? – martin_mageworx May 26 '16 at 13:55
  • @martin_mageworx yes, when someone placed an order through app, we will save in backend. our android team is using default magento api for getting all payment methods. we are using shoppingCartShippingList api – Baby in Magento May 26 '16 at 13:58
2
+50

If payment method doesn't support online capturing (like Paypal Standard) there is no way to get a full order creation flow like on Checkout via Magento API interface. It is impossible to change the order state and process payments. As a workaround try the following:

  1. create an order with "pending" status
  2. then get order info using sales_order.info API method
  3. use order info to validate all the necessary data as described here. It should be done on the Mobile App side.
  4. if it passed the validation step then create an invoice and capture it

UPD Some Payment methods support online capturing (i.e. Authorize or Paypal Payments Pro). In theory it means that, you can create a cart via API, add payment method data to it (i.e. CC details), create an order and capture it online. So all the order processing steps (including payment validation) will be on Magento side.

  • Android team said they will create an order in backend using apis. I think first 3 steps will done by Mobile app team, is it so ? i am not sure, i will check with them in morning, now in 4th step , app team is telling they will send transaction id , now i have to do validation from magento side that payment is succesfull or not. – Baby in Magento May 26 '16 at 18:29
  • are you telling i have to write an API for creating an invoice & capturing if payment is successfull ?after that how i can send reply back to android team that payment is successfull or not, so that android team will display message in app after payment done by customer. – Baby in Magento May 26 '16 at 18:33
  • You do not need to create an API for invoice, it exists already. See links in my answer. There is no sense to send a Paypal transaction id to Magento because Magento do not know anything about it. You process payments in Android app side, so you have to validate payment in App too. Just use data stored in Magento order. Creating orders via API is similar to creating the order in Magento Backend: you can create order, you can even select a Live payment (i.e. Paypal) but you won't be redirected to Payemt processor to complete the payment. – martin_mageworx May 27 '16 at 6:17
  • See my updated answer – martin_mageworx May 27 '16 at 6:44
  • yes, you are right. app team also should validate , after that they want validation from magento side.please check Edit 2 in question. – Baby in Magento May 27 '16 at 7:24
1

Paypal Express payment method doesn't support online capturing. There is no way to get a full order creation flow like on Checkout via Magento API interface. It is impossible to change the order state and process payments. As a workaround try the following:

  1. Create a custom payment method
  2. Enable for REST API only(Not on website checkout page)
  3. While making payment using rest api use this method (after successful payment using you android/ios SDK)
  4. After placing the order make send transaction id(PAY-xxxxx) return by paypal sdk payment to save trasaction.(tell your server side tio implement this call).

I am writting a complete atrticle regarding this step by step. I will let you know when it is done.

  • i got solution but Thanks for sharing knowledge , you can include complete article link here once it done, so that it may help for others – Baby in Magento Dec 16 '16 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.