2014-03-06 123 views
1

我們使用Paypal Pro直接進行信用卡處理。當我在一個請求中放置兩個交易時會發生什麼情況,並且信用卡會批准一個交易對象,但由於資金不足而拒絕另一個交易對象。 PayPal是否會拋棄整個交易並返回錯誤?貝寶的交易對象失敗交易

看看下面的代碼直接從paypals REST API用於node.js的

var payment_details = { 
    "intent": "sale", 
    "payer": { 
    "payment_method": "credit_card", 
    "funding_instruments": [{ 
     "credit_card": { 
     "type": "visa", 
     "number": "4417119669820331", 
     "expire_month": "11", 
     "expire_year": "2018", 
     "cvv2": "874", 
     "first_name": "Joe", 
     "last_name": "Shopper", 
     "billing_address": { 
      "line1": "52 N Main ST", 
      "city": "Johnstown", 
      "state": "OH", 
      "postal_code": "", 
      "country_code": "US" }}}]}, 
    "transactions": [{ 
    "amount": { 
     "total": "7.47", 
     "currency": "USD", 
     "details": { 
     "subtotal": "7.41", 
     "tax": "0.03", 
     "shipping": "0.03"}}, 
    "description": "This is the payment transaction description." }]}; 

paypal_sdk.payment.create(payment_details, function(error, payment){ 
    if(error){ 
    console.error(error); 
    } else { 
    console.log(payment); 
    } 
}); 

當我們把在那裏2交易對象會發生什麼情況,我們將不得不辦理信用卡的第二下降的情況下交易?

+0

剛剛意識到您必須使用paypal中的列表項目對象。沒有在文檔中提到。每個請求只能有一個事務對象。 –

回答

0

這就是我們最終使用的。我們使用項目feild來告訴paypal關於交易中的多個項目。項目是一系列項目:

items.push({ 
    quantity: "1", 
    name: classList[i].name, 
    price: price.toFixed(2), 
    currency: "USD" 
}); 

var create_payment_json = { 
    "intent": "sale", 
    "payer": { 
     "payment_method": "paypal" 
    }, 
    "redirect_urls": { 
     "return_url": "http://"+config.host+"/payment/success/"+paymentId, 
     "cancel_url": "http://"+config.host+"/payment/cancel/"+paymentId 
    }, 
    "transactions": [{ 
     "item_list": { 
      "items": items 
     }, 
     "amount": { 
      "currency": "USD", 
      "total": (total.toFixed(2)) 
     }, 
     "description": description 
    }] 
};