vikas dhiman
vikas dhiman

Reputation: 274

React Native Paypal Payment Gateway using react-native-paypal-lib

I have spent more then 6 hours in integrating paypal in React Native. I am using react-native-paypal-lib library.

Code:

RNPaypal.paymentRequest({
    clientId: 'MY ID I KNOW',
    environment: RNPaypal.ENVIRONMENT.SANDBOX,
    intent: RNPaypal.INTENT.SALE,
    price: 60,
    currency: 'USD',
    description: 'Android testing',
      acceptCreditCards: true
    }).then(response => {
       console.log(response)
    }).catch(err => {
       console.log(err.message)
 })

Response:

{response_type: "payment", response: {…}, client: {…}}
        client:
            environment: "mock"
            paypal_sdk_version: "2.15.3"
            platform: "Android"
            product_name: "PayPal-Android-SDK"

        response:
            create_time: "2014-07-18T18:46:55Z"
            id: "PAY-18X32451H0459092JKO7KFUI"
            intent: "sale"
            state: "approved"
        response_type: "payment"

I am getting the response too. But, I cannot see the transactions in my sandbox account. Also, I am getting the same response id every time.

Upvotes: 3

Views: 976

Answers (1)

Preston PHX
Preston PHX

Reputation: 30477

An approved v1/payment (or v2/order) does not create a transaction. The customer has merely passed through the PayPal.com portion of the process, to give their approval.

After your app is notified of this approval, by e.g. their return from PayPal.com to your app with the details, you must execute the v1/payment (or capture the v2/order), which will create a PayPal transaction. The transaction will have its own new unique ID, which is what you should store for accounting purposes.

(The ID used during the approval process, PAY-##### with v1/payments, or just 17 characters for v2/orders, is only worth keeping around about ~1 month for debug purposes. It has no business/accounting value.)

Upvotes: 2

Related Questions