我最近使用以下教程实现了paypal移动支付教程:http://androiddevelopmentanddiscussion.blogspot.com/2014/05/paypal-integration-in-android.html
作为回应,我得到以下信息:
{
"response": {
"state": "approved",
"id": "PAY-1GM934738N157023RKR7OWYI",
"create_time": "2014-12-03T10:52:17Z",
"intent": "sale"
},
"client": {
"platform": "Android",
"paypal_sdk_version": "2.1.0",
"product_name": "PayPal-Android-SDK",
"environment": "sandbox"
},
"response_type": "payment"
}
{
"short_description": "Painting 1",
"amount": "8",
"intent": "sale",
"currency_code": "USD"
}任何一个指导我如何获得交易id和其他信息移动sdk?正如我所看到的,从paypal移动sdk id支付是不同的,而实际的交易id。
任何帮助都将不胜感激。
发布于 2014-12-08 13:37:58
可以使用SDK:https://developer.paypal.com/webapps/developer/docs/api/#look-up-a-payment-resource返回的支付ID检索支付资源。
通常,这将在您的服务器而不是移动设备上完成。GET操作将需要使用client_id和client_secret生成的访问令牌。
更新链接:
发布于 2020-06-04 22:07:18
您可以先在单独的调用中获取令牌,然后在另一个调用中使用它来获取事务id,或者只需在一个步骤中组合两个步骤,如下所示:
public void getPayPalTransactionId(String payPalPaymentId) {
String PAYPAL_PAYMENT = "https://api.sandbox.paypal.com/v1/payments/payment/%s";
String url = String.format(PAYPAL_PAYMENT, payPalPaymentId);
Call<PayPalPaymentResponse> callPayment = webApiInterface.getPayPalTransactionId(url, Credentials.basic(PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET));
callPayment.enqueue(new Callback<PayPalPaymentResponse>() {
@Override
public void onResponse(@NonNull Call<PayPalPaymentResponse> call, @NonNull Response<PayPalPaymentResponse> response) {
if (response.isSuccessful() && response.body() != null)
String payPalOrderId = response.body().getTransactions().get(0).getRelatedResources().get(0).getSale().getId();
}
@Override
public void onFailure(@NonNull Call<PayPalPaymentResponse> call, @NonNull Throwable t) {
}
});
}在WebApiInterface中
@GET
Call<PayPalPaymentResponse> getPayPalTransactionId(@Url String url, @Header("Authorization") String authorization);发布于 2022-10-04 22:42:27
转到下面代码中的onApprove函数,然后转到它所表示的事务ID:
<!-- Include the PayPal JavaScript SDK -->
<script src="https://www.paypal.com/sdk/js?client-id=CLIENT ID IS CORRECTLY ADDED¤cy=USD"></script>
<script>
paypal.Buttons({
// Sets up the transaction when a payment button is clicked
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '1'
},
}],
application_context: {
shipping_preference: "NO_SHIPPING",
}
});
},
// Finalize the transaction after payer approval
onApprove: function(data, actions) {
return actions.order.capture().then(function(orderData) {
// Successful capture! For dev/demo purposes:
// console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
// the transaction id is below this comment in the alert
var transaction = orderData.purchase_units[0].payments.captures[0];
alert('Transaction '+ transaction.status + ': ' + transaction.id + '\n\nSee console for all available details');
// When ready to go live, remove the alert and show a success message within this page. For example:
// var element = document.getElementById('paypal-button-container');
// element.innerHTML = '';
// element.innerHTML = '<h3>Thank you for your payment!</h3>';
actions.redirect('https://wwwwebsite.com/att_thanks.php?id=1640035591');
});
}
}).render('#paypal-button-container');
</script> https://stackoverflow.com/questions/27270414
复制相似问题